Package org.htmlparser

Examples of org.htmlparser.Attribute


        CompositeTag oCTag = (CompositeTag) oNode;
        oBuffer.append("<");
        Vector oAttrs = oCTag.getAttributesEx();
        int nAttrs = oAttrs.size();
        for (int a=0; a<nAttrs; a++) {
          Attribute oAttr = (Attribute) oAttrs.get(a);
          oAttr.toString(oBuffer);
        }
        oBuffer.append(">");
        NodeList oChilds = oNode.getChildren();
        if (oChilds!=null) {
          for (NodeIterator i = oNode.getChildren().elements(); i.hasMoreNodes(); ) {
View Full Code Here


          int n = attributes.size();
          StringBuffer buf = new StringBuffer();
          buf.append("<");
          String tagName = null;
          for (int i = 0; i < n; ++i){
              Attribute attribute = attributes.elementAt(i);
              if (i == 0) {
                tagName = attribute.getName();
              } else if (isLocalizableAttribute(tagName, attribute)) {
                attribute.getName(buf);
                attribute.getAssignment(buf);
                char quote = attribute.getQuote();
                if (quote != 0) {
                  buf.append(quote);
                }
                if (buf.length() > 0) {
                  result.add(ctx.createNonlocalizableTextFragment(buf.toString()));
                }
                result.add(ctx.createTextFragment(attribute.getValue()));
                buf = new StringBuffer();
                if (quote != 0) {
                  buf.append(quote);
                }
                continue;
              }
              attribute.toString(buf);
          }
          buf.append(">");
          result.add(ctx.createNonlocalizableTextFragment(buf.toString()));
        }

        /**
         * Check if a particular attribute contains localizable content.
         *
         * @param tagName
         * @param attribute
         * @return true if the attribute's value is localizable, false otherwise
         */
        private boolean isLocalizableAttribute(String tagName, Attribute attribute) {
          if (!attribute.isValued()) {
            return false;
          }
          String attrName = attribute.getName();
          return LOCALIZABLE_ATTRIBUTES.contains(attrName)
              || LOCALIZABLE_ATTRIBUTES.contains(tagName + "/" + attrName);
        }
      });
      ctx.replaceFragment(text, result);
View Full Code Here

  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);
View Full Code Here

     * @return <code>true</code> if the node has the attribute
     * (and value if that is being checked too), <code>false</code> otherwise.
     */
    public boolean accept(Node node) {
    Tag tag;
    Attribute attribute;

    if (node instanceof Tag) {
      tag = (Tag)node;
      attribute = tag.getAttributeEx("class");
      if (attribute != null) {
        String value = attribute.getValue().trim();
        if (value.indexOf(' ') != -1) {
          for (String token : value.split(" ")) {
            if (token.equals(className)) {
              return true;
            }
View Full Code Here

     * @return <code>true</code> if the node has the attribute
     * (and value if that is being checked too), <code>false</code> otherwise.
     */
    public boolean accept(Node node) {
    Tag tag;
    Attribute attribute;

    if (node instanceof Tag) {
      tag = (Tag)node;
      attribute = tag.getAttributeEx(attributeName);
      if (attribute != null) {
        return attribute.getValue().matches(regex);
      }
    }

    return false;
  }
View Full Code Here

     *         is out of range.
     * @see #getLength
     */
    public String getQName (int index)
    {
        Attribute attribute;
        String ret;
       
        attribute = (Attribute)(mTag.getAttributesEx ().elementAt (index + 1));
        if (attribute.isWhitespace ())
            ret = "#text";
        else
            ret = attribute.getName ();
       
        return (ret);
    }
View Full Code Here

     *         index is out of range.
     * @see #getLength
     */
    public String getValue (int index)
    {
        Attribute attribute;
        String ret;
       
        attribute = (Attribute)(mTag.getAttributesEx ().elementAt (index + 1));
        ret = attribute.getValue ();
        if (null == ret)
            ret = "";

        return (ret);
    }
View Full Code Here

     */
    public int getIndex (String uri, String localName)
    {
        Vector attributes;
        int size;
        Attribute attribute;
        String string;
        int ret;

        ret = -1;

        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
                {
                    mSupport.processName (string, mParts, true);
                    if uri.equals (mParts[0])
                        & localName.equalsIgnoreCase (mParts[1]))
View Full Code Here

     * (and value if that is being checked too), <code>false</code> otherwise.
     */
    public boolean accept (Node node)
    {
        Tag tag;
        Attribute attribute;
        boolean ret;

        ret = false;
        if (node instanceof Tag)
        {
            tag = (Tag)node;
            attribute = tag.getAttributeEx (mAttribute);
            ret = null != attribute;
            if (ret && (null != mValue))
                ret = mValue.equals (attribute.getValue ());
        }

        return (ret);
    }
View Full Code Here

        for (Enumeration e = newObjectParams.keys (); e.hasMoreElements (); )
        {
            attributes = new Vector (); // should the tag copy the attributes?
            paramName = (String)e.nextElement ();
            paramValue = (String)newObjectParams.get (paramName);
            attributes.addElement (new Attribute ("PARAM", null));
            attributes.addElement (new Attribute (" "));
            attributes.addElement (new Attribute ("VALUE", paramValue, '"'));
            attributes.addElement (new Attribute (" "));
            attributes.addElement (new Attribute ("NAME", paramName.toUpperCase (), '"'));
            tag = new TagNode (null, 0, 0, attributes);
            kids.add (tag);
        }
       
        //set kids as new children
View Full Code Here

TOP

Related Classes of org.htmlparser.Attribute

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.