source: fedd/abac-src/rtml/src/edu/stanford/rt/datatype/TreeValue.java @ 8780cbec

axis_examplecompt_changesinfo-opsversion-1.30version-2.00version-3.01version-3.02
Last change on this file since 8780cbec was 8780cbec, checked in by Jay Jacobs <Jay.Jacobs@…>, 15 years ago

ABAC sources from Cobham

  • Property mode set to 100644
File size: 1.8 KB
Line 
1package edu.stanford.rt.datatype;
2
3import java.util.*;
4
5
6/**
7 * @author Ninghui Li, Sandra Qiu <br>
8 *
9 * Implementation of <code>TreeValue</code> element.
10 *
11 */
12public class TreeValue implements DataValue
13{
14    private ArrayList value;
15    private TreeType type;
16
17    /**
18     * Constructor for TreeValue
19     */
20    public TreeValue(TreeType type, List v)
21        throws IllegalArgumentException
22    {
23        this.type = type;
24       
25        if(v == null || v.size() ==0)
26            throw new IllegalArgumentException("Empty tree value");
27
28        value = new ArrayList();
29        Iterator it = v.iterator();
30        while(it.hasNext())
31        {
32            String val = (String)it.next();
33            value.add(val);
34        }
35    }
36
37        /**
38         * Method getValue.
39     *      returns an unmodifiable view of value part list.
40         * @return List
41         */
42    public List getValue()
43    {
44        return Collections.unmodifiableList(value);
45    }
46   
47        /* (non-Javadoc)
48         * @see java.lang.Object#toString()
49         */
50    public String toString()
51    {
52        StringBuffer sb = new StringBuffer();
53        String separator = type.getSeparator();
54        boolean rootFirst = type.isRootFirst();
55        int size = value.size();
56        if(rootFirst)
57        {
58            for(int i=0; i<size; i++)
59            {
60                String val = (String)value.get(i);
61                sb.append(val);
62                if(i != (size-1))  sb.append(separator);
63            }
64        }
65        else
66        {
67            for(int i=size-1; i>=0; i--)
68            {
69                String val = (String)value.get(i);
70                sb.append(val);
71                if(i != 0)  sb.append(separator);
72            }
73        }
74        return sb.toString();
75    }
76   
77}
Note: See TracBrowser for help on using the repository browser.