/** * Predicate to determine if this attribute has a value. * @return <code>true</code> if this attribute has a value. * <code>false</code> if it is empty or standalone. */ public boolean isValued () { return (null != getValue ()); }
/** * Predicate to determine if this attribute has a value. * @return <code>true</code> if this attribute has a value. * <code>false</code> if it is empty or standalone. */ public boolean isValued () { return ((null != super.getValue ()) // an explicit value provided // or it is coming from a page and has a non-empty value || ((null != mPage) && ((0 <= mValueStart) && (0 <= mValueEnd)) && (mValueStart != mValueEnd))); }
/** * Predicate to determine if this attribute has a value. * @return <code>true</code> if this attribute has a value. * <code>false</code> if it is empty or standalone. */ public boolean isValued () { return ((null != super.getValue ()) // an explicit value provided // or it is coming from a page and has a non-empty value || ((null != mPage) && ((0 <= mValueStart) && (0 <= mValueEnd)) && (mValueStart != mValueEnd))); }
/** * Predicate to determine if this attribute has a value. * @return <code>true</code> if this attribute has a value. * <code>false</code> if it is empty or standalone. */ public boolean isValued () { return (null != getValue ()); }
/** * Predicate to determine if this attribute has an equals sign but no value. * @return <code>true</code> if this attribute is an empty attribute. * <code>false</code> if has an equals sign and a value. */ public boolean isEmpty () { return ((null != getAssignment ()) && (null == getValue ())); }
/** * Predicate to determine if this attribute has an equals sign but no value. * @return <code>true</code> if this attribute is an empty attribute. * <code>false</code> if has an equals sign and a value. */ public boolean isEmpty () { return ((null != getAssignment ()) && (null == getValue ())); }
/** * Returns the value of an attribute. * @param name Name of attribute, case insensitive. * @return The value associated with the attribute or null if it does * not exist, or is a stand-alone or */ public String getAttribute (String name) { Attribute attribute; String ret; ret = null; attribute = getAttributeEx (name); if (null != attribute) ret = attribute.getValue (); return (ret); }
/** * Get the value of the attribute. * @param buffer The buffer to place the value in. * @see #getValue() */ public void getValue (StringBuilder buffer) { String value; value = super.getValue (); if (null == value) { if ((null != mPage) && (0 <= mValueEnd)) mPage.getText (buffer, mNameStart, mNameEnd); } else buffer.append (value); }
/** * Get the value of the attribute. * @param buffer The buffer to place the value in. * @see #getValue() */ public void getValue (StringBuffer buffer) { String value; value = super.getValue (); if (null == value) { if ((null != mPage) && (0 <= mValueEnd)) mPage.getText (buffer, mValueStart, mValueEnd); } else buffer.append (value); }
@Override public boolean accept(Node node) { if (!(node instanceof Tag)) { return false; } if (mValue == null) { return false; } Tag tag = (Tag) node; if (tag.getAttributeEx(mAttribute) == null) { return false; } return tag.getAttributeEx(mAttribute).getValue().startsWith(mValue); } }
@Override public boolean accept(Node node) { if (!(node instanceof Tag)) { return false; } if (mValue == null) { return false; } Tag tag = (Tag) node; if (tag.getAttributeEx(mAttribute) == null) { return false; } return tag.getAttributeEx(mAttribute).getValue().startsWith(mValue); } }
private static Vector cloneAttributes(Vector<Attribute> attributes) { Vector<Attribute> newAttributes = new Vector<>(attributes.size()); for (Attribute a : attributes) { newAttributes.add(new Attribute(a.getName(), a.getAssignment(), a.getValue(), a.getQuote())); } return newAttributes; }
/** * Predicate to determine if this attribute has an equals sign but no value. * @return <code>true</code> if this attribute is an empty attribute. * <code>false</code> if has an equals sign and a value. */ public boolean isEmpty () { return (!isWhitespace () // not whitespace && !isStandAlone () // and not standalone && (null == super.getValue ()) // and no explicit value provided && ((null == mPage) // and either its not coming from a page // or it is coming from a page and has no value || ((null != mPage) && (0 > mValueEnd)))); }
/** * Get the raw value of the attribute. * The part after the equals sign, or the text if it's just a whitepace * 'attribute'. This includes the quotes around the value if any. * @param buffer The string buffer to append the attribute value to. * @see #getRawValue() */ public void getRawValue (StringBuilder buffer) { getQuote (buffer); getValue (buffer); getQuote (buffer); }
private static Vector cloneAttributes(Vector<Attribute> attributes) { Vector<Attribute> newAttributes = new Vector<>(attributes.size()); for (Attribute a : attributes) { newAttributes.add(new Attribute(a.getName(), a.getAssignment(), a.getValue(), a.getQuote())); } return newAttributes; }
/** * Get the raw value of the attribute. * The part after the equals sign, or the text if it's just a whitepace * 'attribute'. This includes the quotes around the value if any. * @param buffer The string buffer to append the attribute value to. * @see #getRawValue() * @see #setRawValue */ public void getRawValue (StringBuffer buffer) { getQuote (buffer); getValue (buffer); getQuote (buffer); }
/** * Predicate to determine if this attribute has an equals sign but no value. * @return <code>true</code> if this attribute is an empty attribute. * <code>false</code> if has an equals sign and a value. */ public boolean isEmpty () { return (!isWhitespace () // not whitespace && !isStandAlone () // and not standalone && (null == super.getValue ()) // and no explicit value provided && ((null == mPage) // and either its not coming from a page // or it is coming from a page and has no value || ((null != mPage) && (0 > mValueEnd)))); }
@SuppressWarnings("unchecked") private Map<String, String> getAttributes(org.htmlparser.Tag tag) { Map<String, String> result = new HashMap<String, String>(); List<?> original = tag.getAttributesEx(); List<Attribute> list = new ArrayList<Attribute>((Collection<? extends Attribute>) original .subList(1, original.size())); for (Attribute a : list) { if (a.getName() != null && !a.getName().equals("/") && !a.isWhitespace()) { result.put(a.getName(), a.getValue()); } } return result; } }
private void processAttributes(AnnotationFS annotation, Tag tag) { int size = tag.getAttributesEx().size() - 1; StringArray attributeName = new StringArray(jcas, size); StringArray attributeValue = new StringArray(jcas, size); for (int i = 0; i < size; i++) { Attribute attribute = (Attribute) tag.getAttributesEx().elementAt(i + 1); attributeName.set(i, attribute.getName()); attributeValue.set(i, attribute.getValue()); } Feature feature1 = annotation.getType().getFeatureByBaseName("attributeName"); annotation.setFeatureValue(feature1, attributeName); Feature feature2 = annotation.getType().getFeatureByBaseName("attributeValue"); annotation.setFeatureValue(feature2, attributeValue); }
private void processAttributes(AnnotationFS annotation, Tag tag) { int size = tag.getAttributesEx().size() - 1; StringArray attributeName = new StringArray(jcas, size); StringArray attributeValue = new StringArray(jcas, size); for (int i = 0; i < size; i++) { Attribute attribute = (Attribute) tag.getAttributesEx().elementAt(i + 1); attributeName.set(i, attribute.getName()); attributeValue.set(i, attribute.getValue()); } Feature feature1 = annotation.getType().getFeatureByBaseName("attributeName"); annotation.setFeatureValue(feature1, attributeName); Feature feature2 = annotation.getType().getFeatureByBaseName("attributeValue"); annotation.setFeatureValue(feature2, attributeValue); }