public String getAttribute(Element e, String attribute) { Attribute attr = e.getAttribute(attribute); if(attr == null) { throw bomb("Error finding attribute '" + attribute + "' in config: " + configFile + elementOutput(e)); } return attr.getValue(); }
@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 ); } }
public FieldObject(Element element){ this.type = element.getAttributeValue("type"); this.name = element.getAttributeValue("name"); this.comment =element.getAttributeValue("comment"); Attribute genericAttr = element.getAttribute("generic"); if(genericAttr != null){ this.generic = genericAttr.getValue(); } MacroObject macroObj = MacroObject.getAllMacros().get(this.type); if(macroObj != null){ this.selfObj = macroObj; } macroObj = MacroObject.getAllMacros().get(this.generic); if(macroObj != null){ this.genericObj = macroObj; } }
protected void parseCategoriesElement(final Element catsElem) { if (catsElem.getAttribute("href", AtomService.ATOM_PROTOCOL) != null) { setHref(catsElem.getAttribute("href", AtomService.ATOM_PROTOCOL).getValue()); } if (catsElem.getAttribute("fixed", AtomService.ATOM_PROTOCOL) != null) { if ("yes".equals(catsElem.getAttribute("fixed", AtomService.ATOM_PROTOCOL).getValue())) { setFixed(true); } } if (catsElem.getAttribute("scheme", AtomService.ATOM_PROTOCOL) != null) { setScheme(catsElem.getAttribute("scheme", AtomService.ATOM_PROTOCOL).getValue()); } // Loop to parse <atom:category> elemenents to Category objects final List<Element> catElems = catsElem.getChildren("category", AtomService.ATOM_FORMAT); for (final Element catElem : catElems) { final Category cat = new Category(); cat.setTerm(catElem.getAttributeValue("term", AtomService.ATOM_FORMAT)); cat.setLabel(catElem.getAttributeValue("label", AtomService.ATOM_FORMAT)); cat.setScheme(catElem.getAttributeValue("scheme", AtomService.ATOM_FORMAT)); addCategory(cat); } }
/** Use feed links and/or xml:base attribute to determine baseURI of feed */ private static URL findBaseURI(final Element root) { URL baseURI = null; final List<Element> linksList = root.getChildren("link", OS_NS); if (linksList != null) { for (final Element element : linksList) { final Element link = element; if (!root.equals(link.getParent())) { break; } String href = link.getAttribute("href").getValue(); if (link.getAttribute("rel", OS_NS) == null || link.getAttribute("rel", OS_NS).getValue().equals("alternate")) { href = resolveURI(null, link, href); try { baseURI = new URL(href); break; } catch (final MalformedURLException e) { System.err.println("Base URI is malformed: " + href); } } } } return baseURI; } }
if (element.getChild("treatAs", NS) == null) { return null; sle.setTreatAs(element.getChildText("treatAs", NS)); final Element listInfo = element.getChild("listinfo", NS); ArrayList<Object> values = new ArrayList<Object>(); for (final Element ge : listInfo.getChildren("group", NS)) { final Namespace ns = ge.getAttribute("ns") == null ? element.getNamespace() : Namespace.getNamespace(ge.getAttributeValue("ns")); final String elementName = ge.getAttributeValue("element"); final String label = ge.getAttributeValue("label"); values = values.size() == 0 ? values : new ArrayList<Object>(); for (final Element se : listInfo.getChildren("sort", NS)) { LOG.debug("Parse cf:sort {}{}", se.getAttributeValue("element"), se.getAttributeValue("data-type")); final Namespace ns = se.getAttributeValue("ns") == null ? element.getNamespace() : Namespace.getNamespace(se.getAttributeValue("ns")); insertValues(sle, element.getChildren());
/** * Returns the version string stored in the file. */ public String getVersion() { return root.getChild( "trackfile" ).getAttribute( "version" ).getValue(); }
for(Element e: element.getChildren()) { e.getAttribute(colorRedAttribute).getIntValue(), e.getAttribute(colorGreenAttribute).getIntValue(), e.getAttribute(colorBlueAttribute).getIntValue() );
private static final double readDistanceCutoffAttribute( final Element element ) { double val = 0; try { val = element.getChild( TRACKER_SETTINGS_DISTANCE_CUTOFF_ELEMENT ) .getAttribute( TRACKER_SETTINGS_DISTANCE_CUTOFF_ATTNAME_v12 ).getDoubleValue(); } catch ( final DataConversionException e ) {} return val; }
protected List<String> parseRevision(URI resource, String requestUrl, Model model, ValueFactory valueFactory, Element revisions, Context context) throws RepositoryException { List<String> followUp = Collections.emptyList(); if (revisions == null) return followUp; final Element rev = revisions.getChild("rev"); if (rev == null) return followUp; final Resource subject = resource; if (context == Context.META && "0".equals(rev.getAttributeValue("parentid"))) { // This is the first revision, so we use the creation date addLiteralTriple(subject, Namespaces.NS_DC_TERMS + "created", rev.getAttributeValue("timestamp"), Namespaces.NS_XSD + "dateTime", model, valueFactory); } if (context == Context.CONTENT && rev.getValue() != null && rev.getValue().trim().length() > 0) { final String content = rev.getValue().trim(); final Matcher m = REDIRECT_PATTERN.matcher(content); if (((Element) revisions.getParent()).getAttribute("redirect") != null && m.find()) { followUp = Collections.singletonList(buildApiPropQueryUrl(requestUrl, m.group(1), "info", getDefaultParams("info", null), Context.REDIRECT)); } else { addLiteralTriple(subject, Namespaces.NS_RSS_CONTENT + "encoded", content, Namespaces.NS_XSD + "string", model, valueFactory); } } return followUp; }
final Element allTracksElement = root.getChild( TRACK_COLLECTION_ELEMENT_KEY_v12 ); if ( null == allTracksElement ) { return null; } final List< Element > trackElements = allTracksElement.getChildren( TRACK_ELEMENT_KEY_v12 ); for ( final Element trackElement : trackElements ) try trackID = trackElement.getAttribute( TRACK_ID_ATTRIBUTE_NAME_v12 ).getIntValue();
public CustomLinkValue fromXmlElement( final PwmSetting pwmSetting, final Element settingElement, final PwmSecurityKey key ) throws PwmOperationalException { final List valueElements = settingElement.getChildren( "value" ); final List<CustomLinkConfiguration> values = new ArrayList<>(); for ( final Object loopValue : valueElements ) { final Element loopValueElement = ( Element ) loopValue; final String value = loopValueElement.getText(); if ( value != null && value.length() > 0 && loopValueElement.getAttribute( "locale" ) == null ) { values.add( JsonUtil.deserialize( value, CustomLinkConfiguration.class ) ); } } return new CustomLinkValue( values ); } };
/** 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)); } }
/** Use feed links and/or xml:base attribute to determine baseURI of feed */ private static URL findBaseURI(final Element root) { URL baseURI = null; final List<Element> linksList = root.getChildren("link", OS_NS); if (linksList != null) { for (final Element element : linksList) { final Element link = element; if (!root.equals(link.getParent())) { break; } String href = link.getAttribute("href").getValue(); if (link.getAttribute("rel", OS_NS) == null || link.getAttribute("rel", OS_NS).getValue().equals("alternate")) { href = resolveURI(null, link, href); try { baseURI = new URL(href); break; } catch (final MalformedURLException e) { System.err.println("Base URI is malformed: " + href); } } } } return baseURI; } }
if (element.getChild("treatAs", NS) == null) { return null; sle.setTreatAs(element.getChildText("treatAs", NS)); final Element listInfo = element.getChild("listinfo", NS); ArrayList<Object> values = new ArrayList<Object>(); for (final Element ge : listInfo.getChildren("group", NS)) { final Namespace ns = ge.getAttribute("ns") == null ? element.getNamespace() : Namespace.getNamespace(ge.getAttributeValue("ns")); final String elementName = ge.getAttributeValue("element"); final String label = ge.getAttributeValue("label"); values = values.size() == 0 ? values : new ArrayList<Object>(); for (final Element se : listInfo.getChildren("sort", NS)) { LOG.debug("Parse cf:sort {}{}", se.getAttributeValue("element"), se.getAttributeValue("data-type")); final Namespace ns = se.getAttributeValue("ns") == null ? element.getNamespace() : Namespace.getNamespace(se.getAttributeValue("ns")); insertValues(sle, element.getChildren());
/** * Returns the version string stored in the file. */ public String getVersion() { return root.getChild( "trackfile" ).getAttribute( "version" ).getValue(); }
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());
public FormValue fromXmlElement( final PwmSetting pwmSetting, final Element settingElement, final PwmSecurityKey key ) throws PwmOperationalException { final boolean oldType = PwmSettingSyntax.LOCALIZED_STRING_ARRAY.toString().equals( settingElement.getAttributeValue( "syntax" ) ); final List valueElements = settingElement.getChildren( "value" ); final List<FormConfiguration> values = new ArrayList<>(); for ( final Object loopValue : valueElements ) { final Element loopValueElement = ( Element ) loopValue; final String value = loopValueElement.getText(); if ( value != null && value.length() > 0 && loopValueElement.getAttribute( "locale" ) == null ) { if ( oldType ) { values.add( FormConfiguration.parseOldConfigString( value ) ); } else { values.add( JsonUtil.deserialize( value, FormConfiguration.class ) ); } } } final FormValue formValue = new FormValue( values ); formValue.needsXmlUpdate = oldType; return formValue; } };
private static final double readTimeCutoffAttribute( final Element element ) { double val = 0; try { val = element.getChild( TRACKER_SETTINGS_TIME_CUTOFF_ELEMENT ) .getAttribute( TRACKER_SETTINGS_TIME_CUTOFF_ATTNAME_v12 ).getDoubleValue(); } catch ( final DataConversionException e ) {} return val; }
protected List<String> parseRevision(URI resource, String requestUrl, Model model, ValueFactory valueFactory, Element revisions, Context context) throws RepositoryException { List<String> followUp = Collections.emptyList(); if (revisions == null) return followUp; final Element rev = revisions.getChild("rev"); if (rev == null) return followUp; final Resource subject = resource; if (context == Context.META && "0".equals(rev.getAttributeValue("parentid"))) { // This is the first revision, so we use the creation date addLiteralTriple(subject, Namespaces.NS_DC_TERMS + "created", rev.getAttributeValue("timestamp"), Namespaces.NS_XSD + "dateTime", model, valueFactory); } if (context == Context.CONTENT && rev.getValue() != null && rev.getValue().trim().length() > 0) { final String content = rev.getValue().trim(); final Matcher m = REDIRECT_PATTERN.matcher(content); if (((Element) revisions.getParent()).getAttribute("redirect") != null && m.find()) { followUp = Collections.singletonList(buildApiPropQueryUrl(requestUrl, m.group(1), "info", getDefaultParams("info", null), Context.REDIRECT)); } else { addLiteralTriple(subject, Namespaces.NS_RSS_CONTENT + "encoded", content, Namespaces.NS_XSD + "string", model, valueFactory); } } return followUp; }