コード例 #1
0
  /**
   * Creates a new child segement and inserts it after the last segement with the same name
   *
   * @param newChildSeg
   */
  public void attachDuplicateChildSegment(CSVSegment newChildSeg) {
    newChildSeg.setParentSegment(this);
    int childSegSite = 0;
    ArrayList<CSVSegment> childSegList = this.getChildSegments();

    for (int i = 0; i < childSegList.size(); i++) {
      CSVSegment childSeg = (CSVSegment) childSegList.get(i);
      if (newChildSeg.getName().equals(childSeg.getName())) childSegSite = i;
    }
    this.getChildSegments().add(childSegSite + 1, newChildSeg);
  }
コード例 #2
0
 private void processCsvSegment(CSVSegment seg, String indent) {
   // process CSV fields
   xmlBuffer.append(indent + "<" + seg.getName());
   for (CSVField field : seg.getFields()) {
     xmlBuffer.append(" " + field.getName() + "=\"" + field.getValue() + "\"");
   }
   xmlBuffer.append(">\n");
   // process child CSV segments
   for (CSVSegment childSeg : seg.getChildSegments()) {
     processCsvSegment(childSeg, indent + "\t");
   }
   xmlBuffer.append(indent + "</" + seg.getName() + ">\n");
 }
コード例 #3
0
 /**
  * Find all child segment with the given name
  *
  * @param childName
  * @return
  */
 public List<CSVSegment> getChildSegmentsByName(String childName) {
   ArrayList<CSVSegment> rtnList = new ArrayList<CSVSegment>();
   for (CSVSegment childSeg : getChildSegments())
     if (childSeg.getName().equals(childName)) rtnList.add(childSeg);
   return rtnList;
 }