org.htmlparser.Tag.getAttributesEx()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(8.8k)|赞(0)|评价(0)|浏览(133)

本文整理了Java中org.htmlparser.Tag.getAttributesEx()方法的一些代码示例,展示了Tag.getAttributesEx()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Tag.getAttributesEx()方法的具体详情如下:
包路径:org.htmlparser.Tag
类名称:Tag
方法名:getAttributesEx

Tag.getAttributesEx介绍

[英]Gets the attributes in the tag.
[中]获取标记中的属性。

代码示例

代码示例来源:origin: org.opencms/opencms-solr

/**
 * @see org.htmlparser.Tag#getAttributesEx()
 */
public Vector getAttributesEx() {
  return m_decorated.getAttributesEx();
}

代码示例来源:origin: org.opencms/opencms-core

/**
 * @see org.htmlparser.Tag#getAttributesEx()
 */
@SuppressWarnings("unchecked")
public Vector<Attribute> getAttributesEx() {
  return m_decorated.getAttributesEx();
}

代码示例来源:origin: com.bbossgroups.pdp/pdp-cms

/**
 * @see org.htmlparser.Tag#getAttributesEx()
 */
public List getAttributesEx() {
  return m_decorated.getAttributesEx();
}

代码示例来源:origin: com.bbossgroups/bboss-htmlparser

/**
 * 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);
}

代码示例来源:origin: brix-cms/brix-cms

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("/");
  }
}

代码示例来源:origin: org.htmlparser/htmlparser

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);
}

代码示例来源:origin: com.bbossgroups/bboss-htmlparser

/**
 * 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);
}

代码示例来源:origin: org.opencms/org.opencms.workplace.tools.content

/**
 * 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();
}

代码示例来源:origin: com.bbossgroups/bboss-htmlparser

/**
 * 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);
}

代码示例来源:origin: brix-cms/brix-cms

@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;
  }
}

代码示例来源:origin: com.bbossgroups/bboss-htmlparser

attributes = mTag.getAttributesEx ();
if (null != attributes)

代码示例来源:origin: com.github.tcnh/fitnesse

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;
}

代码示例来源:origin: org.fitnesse/fitnesse

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;
}

代码示例来源:origin: com.bbossgroups/bboss-htmlparser

/**
 * 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));
    }
  }
}

代码示例来源:origin: org.opencms/opencms-solr

/**
 * 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, '"'));
  }
}

代码示例来源:origin: org.apache.uima/ruta-core

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);
}

代码示例来源:origin: org.apache.uima/textmarker-core

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);
}

代码示例来源:origin: org.opencms/opencms-core

Vector<Attribute> attrs = tag.getAttributesEx();

代码示例来源:origin: com.bbossgroups/bboss-htmlparser

attributes = ((Tag)node).getAttributesEx ();
for (int i = 1; i < attributes.size (); i++)

代码示例来源:origin: org.everit.templating/org.everit.templating.html

@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);
  }
 }
}

相关文章