List of usage examples for org.xml.sax Attributes getValue
public abstract String getValue(String uri, String localName);
From source file:Main.java
public static final String getAttributeOrThrow(final Attributes pAttributes, final String pAttributeName) { final String value = pAttributes.getValue("", pAttributeName); if (value != null) { return value; } else {//from w ww .j a v a 2 s . c o m throw new IllegalArgumentException("No value found for attribute: '" + pAttributeName + "'"); } }
From source file:com.adobe.acs.commons.rewriter.impl.SaxElementUtils.java
public static boolean isCss(final String elementName, final Attributes attrs) { final String type = attrs.getValue("", "type"); final String href = attrs.getValue("", "href"); if (StringUtils.equals("link", elementName) && StringUtils.equals(type, CSS_TYPE) && StringUtils.startsWith(href, "/") && !StringUtils.startsWith(href, "//") && StringUtils.endsWith(href, LibraryType.CSS.extension)) { return true; }/*from w w w .j a va 2 s . co m*/ return false; }
From source file:com.adobe.acs.commons.rewriter.impl.SaxElementUtils.java
public static boolean isJavaScript(final String elementName, final Attributes attrs) { final String type = attrs.getValue("", "type"); final String src = attrs.getValue("", "src"); if (StringUtils.equals("script", elementName) && StringUtils.equals(type, JS_TYPE) && StringUtils.startsWith(src, "/") && !StringUtils.startsWith(src, "//") && StringUtils.endsWith(src, LibraryType.JS.extension)) { return true; }/*from w w w. ja va 2 s .c o m*/ return false; }
From source file:Main.java
/** * Sometimes parsers do not preserve the namespace for attributes. This * attempts to use the namespace and localname, and, if not available using * the namespace, checks for an attribute using only localname. * * @param attributes/* w ww .ja va 2 s .com*/ * Attributes object to search. * @param uri * namespace of attribute. * @param localName * local name of attribute. * @return value of attribute. */ public static String getAttribute(final Attributes attributes, final String uri, final String localName) { String value = attributes.getValue(uri, localName); if (value == null) { value = attributes.getValue(localName); } return value; }
From source file:Main.java
public static final int getIntAttribute(final Attributes pAttributes, final String pAttributeName, final int pDefaultValue) { final String value = pAttributes.getValue("", pAttributeName); return (value != null) ? Integer.parseInt(value) : pDefaultValue; }
From source file:Main.java
public static final byte getByteAttribute(final Attributes pAttributes, final String pAttributeName, final byte pDefaultValue) { final String value = pAttributes.getValue("", pAttributeName); return (value != null) ? Byte.parseByte(value) : pDefaultValue; }
From source file:Main.java
public static final float getFloatAttribute(final Attributes pAttributes, final String pAttributeName, final float pDefaultValue) { final String value = pAttributes.getValue("", pAttributeName); return (value != null) ? Float.parseFloat(value) : pDefaultValue; }
From source file:Main.java
public static final boolean getBooleanAttribute(final Attributes pAttributes, final String pAttributeName, final boolean pDefaultValue) { final String value = pAttributes.getValue("", pAttributeName); return (value != null) ? Boolean.parseBoolean(value) : pDefaultValue; }
From source file:com.terradue.jcatalogue.client.internal.digester.PriorityParamRule.java
@Override public void begin(String namespace, String name, Attributes attributes) throws Exception { Integer priority = MIN_PRIORITY; String priorityValue = attributes.getValue("urn:ietf:params:xml:ns:metalink", "priority"); if (priorityValue != null) { priority = Integer.valueOf(priorityValue); }/*from w ww. j a v a2 s .com*/ getDigester().peekParams()[paramIndex] = priority; }
From source file:net.bible.service.format.osistohtml.osishandlers.OsisToCanonicalTextSaxHandler.java
@Override public void startElement(String namespaceURI, String sName, // simple name String qName, // qualified name Attributes attrs) { String name = getName(sName, qName); // element name debug(name, attrs, true);/*w w w . ja v a 2 s . c o m*/ // if encountering either a verse tag or if the current tag is marked as being canonical then turn on writing if (isAttrValue(attrs, "canonical", "true")) { writeContentStack.push(CONTENT_STATE.WRITE); } else if (name.equals(OSISUtil.OSIS_ELEMENT_VERSE)) { if (attrs != null) { currentVerseNo = TagHandlerHelper.osisIdToVerseNum(attrs.getValue("", OSISUtil.OSIS_ATTR_OSISID)); } writeContentStack.push(CONTENT_STATE.WRITE); } else if (name.equals(OSISUtil.OSIS_ELEMENT_NOTE)) { writeContentStack.push(CONTENT_STATE.IGNORE); } else if (name.equals(OSISUtil.OSIS_ELEMENT_TITLE)) { writeContentStack.push(CONTENT_STATE.IGNORE); } else if (name.equals(OSISUtil.OSIS_ELEMENT_REFERENCE)) { // text content of top level references should be output but in notes it should not writeContentStack.push(writeContentStack.peek()); } else if (name.equals(OSISUtil.OSIS_ELEMENT_L) || name.equals(OSISUtil.OSIS_ELEMENT_LB) || name.equals(OSISUtil.OSIS_ELEMENT_P)) { // these occur in Psalms to separate different paragraphs. // A space is needed for TTS not to be confused by punctuation with a missing space like 'toward us,and the' write(" "); //if writing then continue. Also if ignoring then continue writeContentStack.push(writeContentStack.peek()); } else { // unknown tags rely on parent tag to determine if content is canonical e.g. the italic tag in the middle of canonical text writeContentStack.push(writeContentStack.peek()); } }