Project

General

Profile

« Previous | Next » 

Revision 1584

Added by Jing Tao over 21 years ago

Revise code to handle text node be splitted into two nodes.

View differences:

src/edu/ucsb/nceas/metacat/ReplMessageHandler.java
56 56
  private boolean update = false;
57 57
  private boolean delete = false;
58 58
  String currentTag = new String();
59
  StringBuffer textBuffer = null;
59 60
  
60 61
  public ReplMessageHandler()
61 62
  {
......
67 68
  public void startElement(String uri, String localName, String qName, 
68 69
                           Attributes attributes) throws SAXException
69 70
  {
71
    textBuffer = new StringBuffer();
70 72
    currentTag = localName;
71 73
    if(localName.equals("updatedDocument"))
72 74
    {
......
86 88
  public void endElement(String uri, String localName, String qName) 
87 89
              throws SAXException
88 90
  {
89
    if(localName.equals("updatedDocument"))
91
     if(currentTag.equals("docid") && update)
90 92
    {
91
      updates.add(new Vector(indivUpdate));
92
      update = false;
93
      indivUpdate.add(textBuffer.toString());
93 94
    }
94
    else if(localName.equals("deletedDocument"))
95
    {
96
      deletes.add(new Vector(indivDelete));
97
      delete = false;
98
    }
99
  }
100
  
101
  /**
102
   * Take the data out of the docid and date_updated fields
103
   */
104
  public void characters(char[] ch, int start, int length) throws SAXException
105
  {
106
    if(currentTag.equals("docid") && update)
107
    {
108
      indivUpdate.add(new String(ch, start, length));
109
    }
110 95
    else if(currentTag.equals("docid") && delete)
111 96
    {
112
      indivDelete.add(new String(ch, start, length));
97
      indivDelete.add(textBuffer.toString());
113 98
    }
114 99
    
115 100
    if(currentTag.equals("rev") && update)
116 101
    {
117
      indivUpdate.add(new String(ch, start, length));
102
      indivUpdate.add(textBuffer.toString());
118 103
      indivUpdate.add(server);
119 104
    }
120 105
    else if(currentTag.equals("rev") && delete)
121 106
    {
122
      indivDelete.add(new String(ch, start, length));
107
      indivDelete.add(textBuffer.toString());
123 108
      indivDelete.add(server);
124 109
    }
125 110
    
126 111
    if(currentTag.equals("date_updated") && update)
127 112
    {
128
      indivUpdate.add(new String(ch, start, length));
113
      indivUpdate.add(textBuffer.toString());
129 114
      indivUpdate.add(server);
130 115
    }
131 116
    else if(currentTag.equals("date_updated") && delete)
132 117
    {
133
      indivDelete.add(new String(ch, start, length));
118
      indivDelete.add(textBuffer.toString());
134 119
      indivDelete.add(server);
135 120
    }
136 121
    
137 122
    if(currentTag.equals("server"))
138 123
    {
139
      server = new String(ch, start, length);
124
      server = textBuffer.toString();
140 125
    }
141 126
    
142 127
    //Adding data file attribute into indivUpdate vector
143 128
    if (currentTag.equals("datafile"))
144 129
    {
145
      dataFile = new String(ch, start, length);
130
      dataFile = textBuffer.toString();
146 131
      indivUpdate.add(dataFile);
147 132
    }
133
    
134
    if(localName.equals("updatedDocument"))
135
    {
136
      updates.add(new Vector(indivUpdate));
137
      update = false;
138
    }
139
    else if(localName.equals("deletedDocument"))
140
    {
141
      deletes.add(new Vector(indivDelete));
142
      delete = false;
143
    }
148 144
  }
149 145
  
146
  /**
147
   * Take the data out of the docid and date_updated fields
148
   */
149
  public void characters(char[] ch, int start, int length) throws SAXException
150
  {
151
    textBuffer.append(new String(ch, start,length));
152
  }
153
  
150 154
  public Vector getUpdatesVect()
151 155
  {
152 156
    return updates;

Also available in: Unified diff