public void buildFromXMLElement(Element aElement, XMLParser aParser, ParsingOptions aOptions) throws InvalidXMLException { super.buildFromXMLElement(aElement, aParser, aOptions); // set key from attributes mKey = aElement.getAttribute("key"); }
MetaDataAttr[] theseAttrs = this.getAttributes(); MetaDataAttr[] thoseAttrs = mdo.getAttributes(); Object val1 = this.getAttributeValue(attr); Object val2 = mdo.getAttributeValue(attr); if (!valuesEqual(val1, val2)) { return false;
/** * Overridden to handle "href" attributes. * * @return the XML attributes * @see org.apache.uima.resource.metadata.impl.MetaDataObject_impl#getXMLAttributes() */ @Override protected AttributesImpl getXMLAttributes() { AttributesImpl attrs = super.getXMLAttributes(); attrs.addAttribute("", "href", "href", "CDATA", getHref()); return attrs; }
MetaDataAttr[] attrs = getAttributes(); for (MetaDataAttr attr : attrs) { Object val = getAttributeValue(attr); if (val instanceof MetaDataObject_impl) { ((MetaDataObject_impl) val).setSourceUrl(aUrl); } else if (val != null && val.getClass().isArray()) { Object[] arrayVal = (Object[]) val; for (Object item : arrayVal) { if (item instanceof MetaDataObject_impl) { ((MetaDataObject_impl) item).setSourceUrl(aUrl); for (Object value : values) { if (value instanceof MetaDataObject_impl) { ((MetaDataObject_impl) value).setSourceUrl(aUrl);
final Serializer serializer = sc.serializer; Object val = getAttributeValue(aPropInfo.propertyName); elementNode = getMatchingNode(sc, aPropInfo.xmlElementName); if (serializer.startElementProperty()) { // skip for JSON serializer.outputStartElement(elementNode, aNamespace, aPropInfo.xmlElementName, aPropInfo.xmlElementName, EMPTY_ATTRIBUTES); Class propClass = getAttributeClass(aPropInfo.propertyName); writeArrayPropertyAsElement(aPropInfo.propertyName, propClass, val, aPropInfo.arrayElementTagName, aNamespace); } else { writePrimitiveValue(val); } else {
XMLParser.ParsingOptions aOptions) throws InvalidXMLException { if (!aElement.getTagName().equals(getXmlizationInfo().elementTagName)) throw new InvalidXMLException(InvalidXMLException.INVALID_ELEMENT_TYPE, new Object[] { getXmlizationInfo().elementTagName, aElement.getTagName() }); PropertyXmlInfo propXmlInfo = getPropertyXmlInfo(elemName); if (propXmlInfo != null) { readPropertyValueFromXMLElement(propXmlInfo, curElem, aParser, aOptions); foundProperties.add(elemName); } else { if (getXmlizationInfo().propertyInfo.length == 1) { readPropertyValueFromXMLElement(getXmlizationInfo().propertyInfo[0], aElement, aParser, aOptions); } else { readUnknownPropertyValueFromXMLElement(curElem, aParser, aOptions, foundProperties);
PropertyXmlInfo[] props = getXmlizationInfo().propertyInfo; for (int i = 0; i < props.length; i++) { String propName = props[i].propertyName; Class<?> propClass = getAttributeClass(propName); if (propClass.isAssignableFrom(valueObj.getClass())) { setAttributeValue(propName, valueObj); success = true; break; && propClass.getComponentType().isAssignableFrom(valueObj.getClass())) { Object curVal = getAttributeValue(propName); int curLen = curVal == null ? 0 : Array.getLength(curVal); Object newVal = Array.newInstance(propClass.getComponentType(), curLen + 1); setAttributeValue(propName, newVal); success = true; break;
MetaDataAttr[] attrs = getAttributes(); for (MetaDataAttr attr : attrs) { Object val = getAttributeValue(attr); if (val instanceof MetaDataObject) { Object clonedVal = ((MetaDataObject) val).clone(); clone.setAttributeValue(attr, clonedVal); } else if (val != null && val.getClass().isArray()) { clone.setAttributeValue(attr, arrayClone);
private void toXMLcommon(boolean aWriteDefaultNamespaceAttribute) throws SAXException { XmlizationInfo inf = getXmlizationInfo(); final Serializer serializer = serialContext.get().serializer; AttributesImpl attrs = getXMLAttributes(); serializer.insertNl(); writePropertyAsElement(propInf, inf.namespace);
/** * Dump this metadata object's attributes and values to a String. This is useful for debugging. */ public String toString() { StringBuffer buf = new StringBuffer(); buf.append(getClass().getName()).append(": \n"); MetaDataAttr[] attrList = getAttributes(); for (MetaDataAttr attr : attrList) { buf.append(attr.name + " = "); Object val = getAttributeValue(attr); if (val == null) buf.append("NULL"); else if (val instanceof Object[]) { Object[] array = (Object[]) val; buf.append("Array{"); for (int j = 0; j < array.length; j++) { buf.append(j).append(": ").append(array[j].toString()).append('\n'); } buf.append("}\n"); } else buf.append(val.toString()); buf.append('\n'); } return buf.toString(); }
String propName = aPropXmlInfo.propertyName; Class propClass = getAttributeClass(propName); readArrayPropertyValueFromXMLElement(aPropXmlInfo, propClass, aElement, aParser, aOptions); } else if (propClass == String.class) // special processing to handle env vars setAttributeValue(propName, text); } else { readArrayPropertyValueFromXMLElement(aPropXmlInfo, Object.class, objElem, aParser, aOptions); } else { setAttributeValue(propName, aParser.buildObjectOrPrimitive(objElem, aOptions)); setAttributeValue(propName, val); } catch (Exception e) { throw new InvalidXMLException(InvalidXMLException.UNKNOWN_ELEMENT,
Map<String, Object> theMap = (Map<String, Object>) getAttributeValue(aPropName); Node matchingNode = getMatchingNode(sc, aXmlElementName); Node innerMatchingNode = getMatchingNode(sc, aValueTagName); serializer.outputStartElement(innerMatchingNode, aNamespace, aValueTagName, aValueTagName, attrs);
/** * Convert from ae meta data. * * @param p the p * @return the processing resource meta data */ private ProcessingResourceMetaData convertFromAeMetaData(AnalysisEngineMetaData p) { ProcessingResourceMetaData d = UIMAFramework.getResourceSpecifierFactory() .createProcessingResourceMetaData(); d.setCapabilities(p.getCapabilities()); d.setConfigurationParameterDeclarations(p.getConfigurationParameterDeclarations()); d.setConfigurationParameterSettings(p.getConfigurationParameterSettings()); d.setCopyright(p.getCopyright()); d.setDescription(p.getDescription()); d.setFsIndexCollection(p.getFsIndexCollection()); d.setName(p.getName()); d.setTypePriorities(p.getTypePriorities()); d.setTypeSystem(p.getTypeSystem()); d.setVendor(p.getVendor()); d.setVersion(p.getVersion()); d.setOperationalProperties(p.getOperationalProperties()); ((MetaDataObject_impl)d).setInfoset(((MetaDataObject_impl)p).getInfoset()); return d; }
private boolean hasXMLizableChild(PropertyXmlInfo[] ia, MetaDataObject_impl mdo) { for (PropertyXmlInfo pi : ia) { Object val = mdo.getAttributeValue(pi.propertyName); if (val != null && val instanceof XMLizable) { return true; } } return false; }
@Override public boolean shouldBeSkipped(PropertyXmlInfo propInfo, Object val, MetaDataObject_impl mdo) { return mdo.valueIsNullOrEmptyArray(val); }
private void callBuildFromXMLElement(Element aElement, XMLizable object, ParsingOptions aOptions) throws InvalidXMLException { if (aOptions.preserveComments && (object instanceof MetaDataObject_impl)) { ((MetaDataObject_impl)object).setInfoset(aElement); } object.buildFromXMLElement(aElement, this, aOptions); }
@Override protected void readUnknownPropertyValueFromXMLElement(Element aElement, XMLParser aParser, ParsingOptions aOptions, List aKnownPropertyNames) throws InvalidXMLException { if (aElement.getNodeName().equals("resourceManagerConfiguration")) { resourceMgrConfig = new CpeResourceManagerConfigurationImpl(); resourceMgrConfig.buildFromXMLElement(aElement, aParser, aOptions); } else { super .readUnknownPropertyValueFromXMLElement(aElement, aParser, aOptions, aKnownPropertyNames); } }
propClass = getWrapperClass(propClass); resultList.addAll(getAdditionalAttributes()); resultListUnfiltered.addAll(getAdditionalAttributes()); MetaDataAttr[] attrs = resultList.toArray(new MetaDataAttr[resultList.size()]); MetaDataAttr[] otherAttrs = class2attrsMap.putIfAbsent(clazz, attrs);
public synchronized Object clone() { //surprise: super.clone sets the final field to the same array list as the original TypePriorityList_impl clone = (TypePriorityList_impl) super.clone(); clone.mTypeNames = new ArrayList<>(); // because above clone has set it to the == object for (String name : mTypeNames) { clone.addType(name); } return clone; }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (!super.equals(obj)) { return false; } if (getClass() != obj.getClass()) { return false; } TypeOrFeature_impl other = (TypeOrFeature_impl) obj; if (mAllAnnotatorFeatures != other.mAllAnnotatorFeatures) { return false; } if (mName == null) { if (other.mName != null) { return false; } } else if (!mName.equals(other.mName)) { return false; } if (mType != other.mType) { return false; } return true; } }