/** * @see org.htmlparser.Tag#getAttributesEx() */ public Vector getAttributesEx() { return m_decorated.getAttributesEx(); }
/** * @see org.htmlparser.Tag#getAttributesEx() */ @SuppressWarnings("unchecked") public Vector<Attribute> getAttributesEx() { return m_decorated.getAttributesEx(); }
/** * @see org.htmlparser.Tag#getAttributesEx() */ public List getAttributesEx() { return m_decorated.getAttributesEx(); }
/** * Return the number of attributes in the list. * * <p>Once you know the number of attributes, you can iterate * through the list.</p> * * @return The number of attributes in the list. * @see #getURI(int) * @see #getLocalName(int) * @see #getQName(int) * @see #getType(int) * @see #getValue(int) */ public int getLength () { return (mTag.getAttributesEx ().size () - 1); }
private boolean isOpenClose(org.htmlparser.Tag tag) { if (tag.getRawTagName().endsWith("/")) { return true; } else { List<?> atts = tag.getAttributesEx(); Attribute a = (Attribute) atts.get(atts.size() - 1); return a.getName() != null && a.getName().equals("/"); } }
protected Vector getAttributes () { Vector attributes; int size; Attribute attribute; String string; if (null == mAttributes) { mAttributes = new Vector (); attributes = mTag.getAttributesEx (); if (null != attributes) { size = attributes.size (); for (int i = 1; i < size; i++) { attribute = (Attribute)attributes.elementAt (i); string = attribute.getName (); if (null != string) // not whitespace mAttributes.add (attribute); } } } return (mAttributes); }
/** * Look up an attribute's value by index. * * <p>If the attribute value is a list of tokens (IDREFS, * ENTITIES, or NMTOKENS), the tokens will be concatenated * into a single string with each token separated by a * single space.</p> * * @param index The attribute index (zero-based). * @return The attribute's value as a string, or null if the * index is out of range. * @see #getLength */ public String getValue (int index) { Attribute attribute; String ret; attribute = (Attribute)(mTag.getAttributesEx ().get (index + 1)); ret = attribute.getValue (); if (null == ret) ret = ""; return (ret); }
/** * Overridden to also return the attributes of the Tag. * <p> * * @see org.opencms.util.CmsHtmlParser#getTagHtml(org.htmlparser.Tag) */ @Override public String getTagHtml(Tag tag) { if (CmsStringUtil.isEmpty(tag.getTagName())) { return ""; } StringBuffer result = new StringBuffer(32); result.append('<'); // Tag name is the first "Attribute"... Iterator itAttributes = tag.getAttributesEx().iterator(); while (itAttributes.hasNext()) { result.append(itAttributes.next().toString()); // avoid trailing whitespaces like <H1 > // in 2nd run htmlparser 1.5 would turn the whitespace into an Attribute with null name if (itAttributes.hasNext()) { result.append(' '); } } result.append('>'); return result.toString(); }
/** * Look up an attribute's XML qualified (prefixed) name by index. * * @param index The attribute index (zero-based). * @return The XML qualified name, or the empty string * if none is available, or null if the index * is out of range. * @see #getLength */ public String getQName (int index) { Attribute attribute; String ret; attribute = (Attribute)(mTag.getAttributesEx ().get (index + 1)); if (attribute.isWhitespace ()) ret = "#text"; else ret = attribute.getName (); return (ret); }
@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; } }
attributes = mTag.getAttributesEx (); if (null != attributes)
private static Node cloneOnlyNode(Node node, Node clonedParent) { Node newNode; try { newNode = (Node) node.clone(); } catch (CloneNotSupportedException e) { throw new IllegalStateException("Node must be cloneable", e); } node.setParent(clonedParent); if (newNode instanceof Tag) { Tag newTag = (Tag) newNode; newTag.setAttributesEx(cloneAttributes(((Tag) node).getAttributesEx())); } return newNode; }
private static Node cloneOnlyNode(Node node, Node clonedParent) { Node newNode; try { newNode = (Node) node.clone(); } catch (CloneNotSupportedException e) { throw new IllegalStateException("Node must be cloneable", e); } node.setParent(clonedParent); if (newNode instanceof Tag) { Tag newTag = (Tag) newNode; newTag.setAttributesEx(cloneAttributes(((Tag) node).getAttributesEx())); } return newNode; }
/** * Add the attribute names from the node to the set of attribute names. * @param set The set to add to. * @param node The node with attributes to add. */ protected void addAttributes (Set set, Node node) { List attributes; Attribute attribute; String name; NodeList children; if (node instanceof Tag) { attributes = ((Tag)node).getAttributesEx (); for (int i = 1; i < attributes.size (); i++) { attribute = (Attribute)attributes.get (i); name = attribute.getName (); if (null != name) set.add (name); } if (node instanceof CompositeTag) { children = ((CompositeTag)node).getChildren (); if (null != children) for (int i = 0; i < children.size (); i++) addAttributes (set, children.elementAt (i)); } } }
/** * Ensures that the given tag has the "alt" attribute set.<p> * * if not set, it will be set from the title of the given resource.<p> * * @param tag the tag to set the alt attribute for * @param internalUri the internal URI to get the title from */ protected void setAltAttributeFromTitle(Tag tag, String internalUri) { boolean hasAltAttrib = (tag.getAttribute("alt") != null); if (!hasAltAttrib) { String value = null; if ((internalUri != null) && (m_rootCms != null)) { // internal image: try to read the "alt" text from the "Title" property try { value = m_rootCms.readPropertyObject(internalUri, CmsPropertyDefinition.PROPERTY_TITLE, false).getValue(); } catch (CmsException e) { // property can't be read, ignore } } // some editors add a "/" at the end of the tag, we must make sure to insert before that Vector attrs = tag.getAttributesEx(); // first element is always the tag name attrs.add(1, new Attribute(" ")); attrs.add(2, new Attribute("alt", value == null ? "" : value, '"')); } }
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); }
Vector<Attribute> attrs = tag.getAttributesEx();
attributes = ((Tag)node).getAttributesEx (); for (int i = 1; i < attributes.size (); i++)
@Override public void visitTag(final Tag tag) { if (fakeTag(tag)) { handleFakeTag(tag); return; } else if (handleTageInNoneAndInlineMode(tag)) { return; } else if (handleRenderNoneTag(tag)) { return; } @SuppressWarnings("unchecked") Vector<PageAttribute> attributes = tag.getAttributesEx(); if (isEwtNode(attributes)) { handleEWTNode(tag, attributes); } else { handleNonEWTNode(tag); } } }