public void parse() { if (isImplicitCollection()) { Object val = GoConfigClassLoader.classParser(e, field.getType(), configCache, new GoCipher(), registry, configReferenceElements).parseImplicitCollection(); setValue(val); } else if (isSubtag(field)) { Object val = subtagParser(e, field, configCache, registry, configReferenceElements).parse(); setValue(val); } else if (isAttribute(field)) { Object val = attributeParser(e, field).parse(defaultValue()); setValue(val); } else if (isConfigValue()) { Object val = e.getText(); setValue(val); } else if (isAnnotationPresent(field, ConfigReferenceElement.class)) { ConfigReferenceElement referenceField = field.getAnnotation(ConfigReferenceElement.class); Attribute attribute = e.getAttribute(referenceField.referenceAttribute()); if (attribute == null) { bomb(String.format("Expected attribute `%s` to be present for %s.", referenceField.referenceAttribute(), e.getName())); } String refId = attribute.getValue(); Object referredObject = configReferenceElements.get(referenceField.referenceCollection(), refId); setValue(referredObject); } }
@SuppressWarnings( "unchecked" ) private void appendElement( Element source, Element target ) { for ( Iterator<Attribute> itr = source.getAttributes().iterator(); itr.hasNext(); ) { Attribute a = itr.next(); itr.remove(); Attribute mergedAtt = target.getAttribute( a.getName(), a.getNamespace() ); if ( mergedAtt == null ) { target.setAttribute( a ); } } for ( Iterator<Element> itr = source.getChildren().iterator(); itr.hasNext(); ) { Content n = itr.next(); itr.remove(); target.addContent( n ); } }
/** * <p> * This sets an attribute value for this element. Any existing attribute * with the same name and namespace URI is removed. * </p> * * @param name name of the attribute to set * @param value value of the attribute to set * @return this element modified * @throws IllegalNameException if the given name is illegal as an * attribute name. * @throws IllegalDataException if the given attribute value is * illegal character data (as determined by * {@link org.jdom2.Verifier#checkCharacterData}). */ public Element setAttribute(final String name, final String value) { final Attribute attribute = getAttribute(name); if (attribute == null) { final Attribute newAttribute = new Attribute(name, value); setAttribute(newAttribute); } else { attribute.setValue(value); } return this; }
List<Element> encryptedPasswordElements = xpathExpression.evaluate(document); for (Element element : encryptedPasswordElements) { Attribute encryptedPassword = element.getAttribute(attributeName); encryptedPassword.setValue(reEncryptUsingNewKey(decodeHex(oldCipher), decodeHex(newCipher), encryptedPassword.getValue())); LOGGER.debug("Replaced encrypted value at {}", element.toString()); List<Element> encryptedNode = xpathExpression.evaluate(document); for (Element element : encryptedNode) { element.setText(reEncryptUsingNewKey(decodeHex(oldCipher), decodeHex(newCipher), element.getValue())); LOGGER.debug("Replaced encrypted value at {}", element.toString());
@Override public final String getAttributeQName(Object att) { Attribute attribute = (Attribute)att; if (attribute.getNamespacePrefix().length() == 0) { return attribute.getName(); } return attribute.getNamespacePrefix() + ":" + attribute.getName(); }
@Override public boolean isMyType(final Document document) { final Element rssRoot = document.getRootElement(); final Attribute version = rssRoot.getAttribute("version"); return rssRoot.getName().equals("rss") && version != null && version.getValue().equals(getRSSVersion()); }
Element rootNode = doc.getRootElement(); Iterator<Element> cs = rootNode.getChildren().iterator(); while (cs.hasNext()) { Element concept = cs.next(); String id = concept.getAttributeValue("brainInfoID"); String canonical = concept.getAttributeValue("standardName"); canonical = canonical.replaceAll("\\(.*\\)$", "").trim(); List<Element> variants = concept.getChild("synonyms").getChildren(); for (Element variant : variants) { if (variant.getAttribute("synonymLanguage").getValue() .matches("Latin|English")) {
protected Element generateSourceElement(final Source source) { final Element sourceElement = new Element("source", getFeedNamespace()); final String url = source.getUrl(); if (url != null) { sourceElement.setAttribute(new Attribute("url", url)); } sourceElement.addContent(source.getValue()); return sourceElement; }
final Attribute typeAttribute = new Attribute("type", type); contentElement.setAttribute(typeAttribute); final Attribute modeAttribute = new Attribute("mode", mode); contentElement.setAttribute(modeAttribute); contentElement.addContent(value); final List<org.jdom2.Content> children = tmpDoc.getRootElement().removeContent(); contentElement.addContent(children);
static public FeatureDataset factory(FeatureType wantFeatureType, String endpoint) throws IOException { if (endpoint.startsWith(SCHEME)) endpoint = endpoint.substring(SCHEME.length()); Document doc = getCapabilities(endpoint); Element root = doc.getRootElement(); Element elem = root.getChild("featureDataset"); String fType = elem.getAttribute("type").getValue(); // LOOK, may be multiple types String uri = elem.getAttribute("url").getValue(); if (debug) System.out.printf("CdmrFeatureDataset endpoint %s%n ftype= %s url=%s%n", endpoint, fType, uri); FeatureType ft = FeatureType.getType(fType); if (ft == null || ft == FeatureType.NONE || ft == FeatureType.GRID) { CdmRemote ncremote = new CdmRemote(uri); NetcdfDataset ncd = new NetcdfDataset(ncremote, null); return new GridDataset(ncd); } else { List<VariableSimpleIF> dataVars = FeatureDatasetPointXML.getDataVariables(doc); LatLonRect bb = FeatureDatasetPointXML.getSpatialExtent(doc); CalendarDateRange dr = FeatureDatasetPointXML.getTimeSpan(doc); return new PointDatasetRemote(ft, uri, dataVars, bb, dr); } }
for ( final Element propertyElement : propertyElements ) propertyElement.detach(); final Element propertyElement = new Element( XML_ELEMENT_PROPERTY ); propertyElement.setAttribute( new Attribute( XML_ATTRIBUTE_KEY, propertyName.getKey() ) ); propertyElement.setContent( new Text( value ) ); final Element configProperties = new Element( XML_ELEMENT_PROPERTIES ); configProperties.setAttribute( new Attribute( XML_ATTRIBUTE_TYPE, XML_ATTRIBUTE_VALUE_CONFIG ) ); document.getRootElement().addContent( configProperties );
final Element rootElement = doc.getRootElement(); for ( final Element hrElement : rootElement.getChildren( XML_NODE_RECORD ) ) final long timeStamp = hrElement.getAttribute( XML_ATTR_TIMESTAMP ).getLongValue(); final String transactionCode = hrElement.getAttribute( XML_ATTR_TRANSACTION ).getValue(); final AuditEvent eventCode = AuditEvent.forKey( transactionCode ); final String srcAddr = hrElement.getAttribute( XML_ATTR_SRC_IP ) != null ? hrElement.getAttribute( XML_ATTR_SRC_IP ).getValue() : ""; final String srcHost = hrElement.getAttribute( XML_ATTR_SRC_HOST ) != null ? hrElement.getAttribute( XML_ATTR_SRC_HOST ).getValue() : ""; final String message = hrElement.getText(); final StoredEvent storedEvent = new StoredEvent( eventCode, timeStamp, message, srcAddr, srcHost );
@Override protected Element createRootElement(final Channel channel) { final Element root = new Element("rss", getFeedNamespace()); final Attribute version = new Attribute("version", getVersion()); root.setAttribute(version); root.addNamespaceDeclaration(getContentNamespace()); generateModuleNamespaceDefs(root); return root; }
/** Deserialize a Atom workspace XML element into an object */ protected void parseWorkspaceElement(final Element element, final String baseURI) throws ProponoException { final Element titleElem = element.getChild("title", AtomService.ATOM_FORMAT); setTitle(titleElem.getText()); if (titleElem.getAttribute("type", AtomService.ATOM_FORMAT) != null) { setTitleType(titleElem.getAttribute("type", AtomService.ATOM_FORMAT).getValue()); } final List<Element> collections = element.getChildren("collection", AtomService.ATOM_PROTOCOL); for (final Element e : collections) { addCollection(new ClientCollection(e, this, baseURI)); } }
final SAXBuilder sxb = new SAXBuilder(); document = sxb.build(fichierContext); context = document.getRootElement(); } else { LOG.debug("Le fichier context n'existe pas dans la webapps : {}.", fichierContext.getAbsolutePath()); context = new Element("Context"); document = new Document(context); final Attribute docBase = new Attribute("docBase", webappDirectory.getAbsolutePath()); final Attribute workDir = new Attribute("workDir", webappDirectory.getAbsolutePath() + "-workDir"); context.setAttribute(docBase); context.setAttribute(workDir);
for(Element e: element.getChildren()) { if(e.getName().equals(colorElement)){ String name = e.getAttributeValue(colorNameAttribute); String terrain = e.getAttributeValue(colorTerrainAttribute); String elevation = e.getAttributeValue(colorElevationAttribute); e.getAttribute(colorRedAttribute).getIntValue(), e.getAttribute(colorGreenAttribute).getIntValue(), e.getAttribute(colorBlueAttribute).getIntValue() );
if (element.hasAttributes()) { for (Attribute a : element.getAttributes()) { if (!a.isSpecified() && fstack.isSpecifiedAttributesOnly()) { continue; atts.addAttribute(a.getNamespaceURI(), a.getName(), a.getQualifiedName(), getAttributeTypeName(a.getAttributeType()), a.getValue()); ch.startElement(element.getNamespaceURI(), element.getName(), element.getQualifiedName(), atts);
private boolean versionMatches(final Document document) { final Attribute version = document.getRootElement().getAttribute("version"); return (version != null) && version.getValue().trim().startsWith(getRSSVersion()); }
/** * A convienience function used for displaying information in _Debug mode. * Prints an XML element's name, content (if any) and Attributes to * System.out */ private void showXMLElement(Element e, String indent) { System.out.print(parseLevel + indent + "Element: " + e.getName() + " "); String text = e.getTextNormalize(); if (!text.equals("")) System.out.print(" = " + text + " "); //System.out.println(""); for (Attribute att : e.getAttributes()) { //System.out.print(parseLevel + indent + " "); System.out.print(att.getName() + ": " + att.getValue() + " "); } System.out.println(""); for (Element kid : e.getChildren()) { showXMLElement(kid, indent + " "); } }
private Element loadElement(String resourceName) throws OfxAuthoringException { try { InputStream is = mrl.searchIs(resourceName); org.jdom2.Document doc = JDomUtil.load(is); Element root = doc.getRootElement(); List<Element> list = build().evaluate(root); logger.debug("Now processing childs: "+list.size()); for(Element childElement : list) { String source = childElement.getAttribute("include").getValue(); String resourceChild = FilenameUtils.getFullPath(resourceName)+source; logger.debug("Found external in "+resourceChild); ExternalContentEagerLoader em = new ExternalContentEagerLoader(); Element eExternal = em.loadElement(resourceChild); eExternal.detach(); int index = childElement.getParentElement().indexOf(childElement); childElement.getParentElement().setContent(index, eExternal); childElement.detach(); } root.detach(); return root; } catch (FileNotFoundException e) {throw new OfxAuthoringException(e.getMessage());} }