Package vmcreative.htmlparser

Examples of vmcreative.htmlparser.Tag


  }
 
  private void parse(HTMLParser htmlparser) throws ParseException {
      List tagList;
      int size;
      Tag lastTag;
   
    tagList = htmlparser.getTagList();
    size = tagList.size();
   
    if(size == 0) {
      this.trailingData = htmlparser.getText(0, htmlparser.getHTMLLength()-1);
      return;
    }
    // Add all the fields to the html tree as tags
    for(int i = 0; i < size; i++) { 
      parseTag(htmlparser, (Tag)tagList.get(i));
    }
   
    // Convert the html tags into injection targets
    size = tagList.size();
    Tag tag;
    for(int i = 0; i < size; i++) { 
      tag = (Tag)tagList.get(i);
        if(tag.getName().equalsIgnoreCase("irow")) {
          this.positionsList.add(new HTMLTargetRow(htmlparser, null, tag));
      } else if(tag.getName().equalsIgnoreCase("iwindow")) {
        this.positionsList.add(new HTMLTargetWindow(htmlparser, null, tag));
      } else {
        this.positionsList.add(new HTMLTargetGroup(htmlparser, null, tag));
      }
    }
View Full Code Here


    int start = tag.getEndPosition()+1;
    int pos = start;
      int endTagPos = getEndOfTag(tag);
    int endPos = endTagPos;
      int nextChild = 1;
    Tag childTag;
    List fieldTags;
   
    while(pos < endTagPos) {
      if(tag.getChildCount() >= nextChild) {
          childTag = tag.getChildTag(nextChild - 1);
        endPos = childTag.getStartPosition() - 1 ;
      } else {
        endPos = getEndOfTag(tag);
        childTag = null;
      }
     
      fieldTags = parseFieldTags(htmlparser, pos, endPos);
           
      // Insert child tags
      if(!fieldTags.isEmpty()) {
        tag.insertTags(fieldTags, nextChild-1);
        nextChild += fieldTags.size();
      }
                 
      // If the child tag has its own children parse those
      if(childTag != null) parseTag(htmlparser, childTag);
     
      // Increment
      try {
        pos = childTag == null ? endPos : childTag.getEndTag().getEndPosition() + 1;
      } catch(NullPointerException q) {
        throw new ParseException("ParseException: Tag: <" + childTag.getName() + "> has no maching end tag.");
      }
      nextChild++;
    }
  }
View Full Code Here

              }
       
        int endOfTag = chars[i] == '#' ? i : i - 1; // Set end of tag correctly
               
       
              Tag t = new Tag(htmlparser.getText(tagStart+1, i-1), false, null, tagStart, endOfTag);
              fieldList.add(t);
               
          }          
          i++;
      }
View Full Code Here

      if(getPositionCount() == 0) {
        this.trailingData = htmlparser.getText(tag.getEndPosition() + 1, tag.getEndTag().getStartPosition()-1);
      } else {
        List childtags = tag.getChildTags();
       
        Tag lastChildTag = (Tag)childtags.get(childtags.size()-1);
   
          int start = lastChildTag.getEndTag() == null ? lastChildTag.getEndPosition() + 1 : lastChildTag.getEndTag().getEndPosition() + 1;
          this.trailingData = htmlparser.getText(start, tag.getEndTag().getStartPosition()-1);      }
    }
View Full Code Here

    private String name;
    private List subPositions = new ArrayList();
   
    public HTMLTargetGroup(HTMLParser htmlparser, HTMLTargetGroup parentGroup, Tag tag) {
      int startPos;
        Tag previousTag = tag.getPreviousTag();
     
      // Get leading data
      if(previousTag == null) {
        Tag parentTag;
       
        parentTag = tag.getParent(); // See if there is a parent
       
        if(parentTag != null ) {
          startPos = parentTag.getEndPosition() + 1;
            this.leadingData = htmlparser.getText(startPos, tag.getStartPosition()-1);
        } else {
          // This is the first node so the leading data is everything from the beginining of the doc
          this.leadingData = htmlparser.getText(0, tag.getStartPosition()-1);
         
        }
      } else {
       
        if(previousTag.getEndTag() == null) {
          startPos = previousTag.getEndPosition() + 1;
        } else {
          startPos = previousTag.getEndTag().getEndPosition() > tag.getStartPosition() ?
            previousTag.getEndPosition()
            : previousTag.getEndTag().getEndPosition();
         
          startPos ++;
        }

        this.leadingData = htmlparser.getText(startPos, tag.getStartPosition()-1);         
      }
     
            
      //this.leadingData = stripTag(this.leadingData, "igroup"); 
      this.name = tag.getAttribute("name");
     
      // Process child tags
      Tag childTag;
      int childCount = tag.getChildCount();
     
      for(int i = 0; i < childCount; i++) {
        addTarget(htmlparser, this, tag.getChildTag(i));
      }
     
      // Set trailing data 19/01/08
       if(getPositionCount() == 0) {
           this.trailingData = htmlparser.getText(tag.getEndPosition() + 1, tag.getEndTag().getStartPosition()-1);
       } else {
           List childtags = tag.getChildTags();
          
           Tag lastChildTag = (Tag)childtags.get(childtags.size()-1);
        
         //if(getType() == InjectionStreamer.FIELD) {
        
           int start = lastChildTag.getEndTag() == null ? lastChildTag.getEndPosition() + 1 : lastChildTag.getEndTag().getEndPosition() + 1;
           this.trailingData = htmlparser.getText(start, tag.getEndTag().getStartPosition()-1);
         //}
       }
    }
View Full Code Here

    private int start;
    private int end;
   
      public HTMLTargetField(HTMLParser htmlparser, HTMLTargetGroup parentTarget, Tag tag) {
      // Set tag name
      Tag parentTag = tag.getParent();
      Tag previousTag = tag.getPreviousTag();
      Tag nextTag = tag.getNextTag();
      this.name = tag.getName();
     
      // Set tag parent
     
   
View Full Code Here

TOP

Related Classes of vmcreative.htmlparser.Tag

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.