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

Quick Search    Search Deep

Source code: com/flexstor/common/data/ejb/disguiserecord/GenericBucketRecordData.java


1   /*
2    * GenericBucketRecordData.java
3    *
4    * Copyright $Date: 2003/08/11 02:22:28 $ FLEXSTOR.net Inc.
5    *
6    * This work is licensed for use and distribution under license terms found at
7    * http://www.flexstor.org/license.html
8    *
9    */
10  
11  package com.flexstor.common.data.ejb.disguiserecord;
12  
13  import java.util.Vector;
14  
15  import com.flexstor.common.data.TraversalInfo;
16  import com.flexstor.common.data.ejb.Data;
17  
18  /**
19  * Superclass of DisguiseBucketRecordData, DisguiseElementRecordData and DisguiseAssetRecordData
20  */
21  public class GenericBucketRecordData
22     extends Data
23  {
24      static final long serialVersionUID = -7965738316670146475L;
25  
26     /** This is inserted into the bucket table as the row id and also into the container table. */
27     long nRecordId = 0;
28     
29     /** The ID to specify which bucket in the structure this bucket relates to. */
30     int nBucketStructId = 0;
31     
32     /** Field Data for this bucket */
33     Vector vFields = null;
34     
35     /** The traversal path for this bucket */
36     TraversalInfo traversalInfo = null;
37  
38     /**
39      * Another representation of the traversal path. This Vector contains a copy
40      * of each bucket in the path. The first item in the Vector is the top bucket,
41      * followed by sub-buckets in order. In case of the assets, the last item
42      * represents the element bucket.
43      */
44     Vector vTraversalPath = null;
45     
46     /** A description to be added during transaction logging */
47     String sDescription = null;
48     
49     public long getRecordId()
50     {
51        return nRecordId;
52     }
53     
54     public void setRecordId( long nRecordId )
55     {
56        this.nRecordId = nRecordId;
57     }
58     
59     public int getBucketStructId()
60     {
61        return nBucketStructId;
62     }
63     
64     public void setBucketStructId( int nBucketStructId )
65     {
66        this.nBucketStructId = nBucketStructId;
67     }
68     
69     public DisguiseFieldRecordData[] getValues()
70     {
71        if ( vFields != null && vFields.size() > 0 )
72        {
73           DisguiseFieldRecordData[] fields = new DisguiseFieldRecordData[ vFields.size() ];
74           vFields.copyInto( fields );
75           return fields;
76        }
77        return null;
78     }
79     
80     public boolean setValues( DisguiseFieldRecordData[] values )
81     {
82        if ( values != null && values.length > 0 )
83        {
84           vFields = new Vector();
85           for( int i = 0; i < values.length; i++ )
86              vFields.addElement( values[i] );
87  
88           return true;
89        }
90        return false;
91     }
92     
93     public void addValue( String sValue )
94     {
95        if ( vFields == null )
96           vFields = new Vector();
97      
98        DisguiseFieldRecordData aField = new DisguiseFieldRecordData();
99        aField.addValue( sValue );
100       vFields.addElement( aField );
101    }
102    
103    public void setTraversalInfo( int nDisguiseId, Vector vTraversalItems )
104    {
105       traversalInfo = new TraversalInfo( nDisguiseId, vTraversalItems);
106    }
107 
108    public void setTraversalInfo( TraversalInfo traversalInfo )
109    {
110       this.traversalInfo = traversalInfo;
111    }
112    
113    public TraversalInfo getTraversalInfo()
114    {
115       return traversalInfo;  
116    }
117 
118    public void setTraversalPath( Vector vTraversalPath )
119    {
120       this.vTraversalPath = vTraversalPath;
121    }
122 
123    public Vector getTraversalPath()
124    {
125       return vTraversalPath;
126    }
127    
128    public void setDescription( String sDescription )
129    {
130       this.sDescription = sDescription;
131    }
132    
133    public String getDescription()
134    {
135       return sDescription;
136    }
137    
138    protected void cloneRecord( GenericBucketRecordData clonedObject )
139    {
140       clonedObject.setRecordId( this.nRecordId );
141       clonedObject.setBucketStructId( this.nBucketStructId );
142       clonedObject.setTraversalInfo( this.traversalInfo );
143       clonedObject.setTraversalPath( this.vTraversalPath );
144       clonedObject.setDescription( this.sDescription );
145       // It should be ok to use the same reference to the values; they won't change
146       clonedObject.setValues( this.getValues() );
147    }
148 }