Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: diffxml/pulldiff/Node.java


1   /*
2   Class to hold data associated with nodes for pulldiff
3    
4   Copyright (C) 2002  Adrian Mouat
5    
6   This program is free software; you can redistribute it and/or
7   modify it under the terms of the GNU General Public License
8   as published by the Free Software Foundation; either version 2
9   of the License, or (at your option) any later version.
10   
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  GNU General Public License for more details.
15  
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19   
20  Author: Adrian Mouat
21  email: amouat@postmaster.co.uk
22  */
23  
24  package diffxml.pulldiff;
25  
26  
27  //Holds data associated with tag
28  import java.util.Vector;
29  
30  public class Node
31  {
32  public static final int TEXT = 0;
33  public static final int TAG = 1;
34  
35  public int type;
36  public String value;
37  public int depth;
38  public int attr_count;
39  private Vector attributes;
40  
41  Node()
42  {
43  attributes=new Vector();
44  depth=0;
45  value="";
46  type=TAG;
47  attr_count=0;
48  }
49  Node(int t, String n, int d)
50  {
51  attributes=new Vector();
52  depth = d;
53  value = n;
54  type = t;
55  attr_count=0;
56  }
57  
58  public void set(int t, String v, int d)
59  {
60  depth = d;
61  value = v;
62  type = t;
63  }
64  
65  public void removeAttrs()
66  {
67  attributes.removeAllElements();
68  attr_count=0;
69  }
70  
71  public void addAttr(String n, String v)
72  {
73  //System.out.println("Entered addAttr name: " + n + " Value: " +v);
74  attributes.add(n);
75  attributes.add(v);
76  attr_count++;
77  }
78  
79  public String getAttrName(int i)
80  {
81  if (i>attr_count)
82    return null;
83  
84  return ((String) attributes.get((2*i)));
85  
86  }
87  
88  public String getAttrValue(int i)
89  {
90  if (i>attr_count)
91          return null;
92   
93  return ((String) attributes.get((2*i)+1));
94  }
95  }