View | Details | Raw Unified | Return to bug 36355
Collapse All | Expand All

(-)file_not_specified_in_diff (-31 / +78 lines)
Line 2 Link Here
2
 * $Header: /home/cvspublic/jakarta-slide/src/share/org/apache/slide/content/NodeRevisionNumber.java,v 1.9 2004/07/28 09:37:54 ib Exp $
2
 * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/content/NodeRevisionNumber.java,v 1.9 2004/07/28 09:37:54 ib Exp $
3
--
Line 28 Link Here
28
import java.util.Enumeration;
29
Lines 57-59 Link Here
57
        number = new int[2];
59
        initBaseRevision();
58
        number[MAJOR] = 1;
59
        number[MINOR] = 0;
60
--
Line 73 Link Here
73
        branch_level = 0;
Line 92 Link Here
92
        this(revisionNumber, false);
93
        if (revisionNumber != null) {
93
--
94
            parseString(revisionNumber.toString());
95
            next();
96
        } else {
97
            initBaseRevision();
98
        }
Line 100 Link Here
100
     * @param createBranch True if a new branch is to be created
106
     * @param successors An enumeration of NodeRevisionNumber objects, each of which is
101
--
107
     * a successor to revisionNumber.
Lines 102-109 Link Here
102
    public NodeRevisionNumber(NodeRevisionNumber revisionNumber, 
109
    public NodeRevisionNumber(NodeRevisionNumber revisionNumber, Enumeration successors) {
103
                              boolean createBranch) {
110
        if (revisionNumber == null) {
104
        if (revisionNumber != null) {
111
            initBaseRevision();
105
            if (createBranch) {
112
            return;
106
                parseString(revisionNumber.toString() + ".1");
113
        }
107
            } else {
114
108
                parseString(revisionNumber.toString());
115
        // Cycle through each of the successors, and find the maximum branch number
109
                next();
116
        // whose branch level is one greater than the current branch level.
110
--
117
        // e.g.  if we are currently at 1.0, and we have successors 1.0.1.0, 1.0.2.0, and 1.1,
118
        // we would like to create revision 1.0.3.0.
119
        int maxBranchNumber = 0;
120
        while (successors.hasMoreElements() == true) {
121
            NodeRevisionNumber successor = (NodeRevisionNumber)successors.nextElement();
122
            if ((successor.getBranchLevel() == revisionNumber.getBranchLevel() + 1) &&
123
                    successor.getBranchNumber() > maxBranchNumber)  {
124
                // This is the right level, and we have a new max branch number.
125
                maxBranchNumber = successor.getBranchNumber();
Lines 111-114 Link Here
111
        } else {
112
            number = new int[2];
113
            number[MAJOR] = 1;
114
            number[MINOR] = 0;
Line 116 Link Here
128
129
        // Now make the new version number.
130
        parseString(revisionNumber.toString() + "." + new Integer(maxBranchNumber + 1).toString() + ".0");
Line 128 Link Here
128
    
143
129
--
144
    /**
145
     * Branch level storage.  Indicates the current level of branching.
146
     * e.g. 1.0 = branch_level => 0
147
     *      1.0.1.0 = branch_level => 1
148
     *      1.0.1.0.1.0 = branch_level => 2
149
     */
150
    private int branch_level;
151
Lines 175-176 Link Here
175
    
198
176
    
199
177
--
200
    /**
201
     * Initialises the base revision (i.e. 1.0)
202
     *
203
     */
204
    private void initBaseRevision() {
205
        number = new int[2];
206
        number[MAJOR] = 1;
207
        number[MINOR] = 0;
208
        branch_level = 0;
209
    }
Line 199 Link Here
232
233
        // Work out the branch level.  e.g. 4 lots of numbers (e.g. 1.0.1.0) corresponds to a branch_level of 1.
234
        branch_level = nbDigits/2 - 1;
Line 212 Link Here
212
    
Line 311 Link Here
311
    
346
    /**
312
--
347
     * Returns the branch level of the current revision number.
348
     * e.g. revision 1.0.1.0 has a branch level of 1.
349
     *
350
     * @return int the level of branching of the current node.
351
     */
352
    public int getBranchLevel() {
353
        return branch_level;
354
    }
355
356
    /**
357
     * Returns the branch number of the current node.
358
     * e.g. revision 1.0.1.0 has a branch number of 1.
359
     *      revision 1.0.2.0 has a branch number of 2.
360
     *
361
     * @return int the branch number of the current node.
362
     */
363
    public int getBranchNumber() {
364
        // The branch number is the second last number.
365
        return number[number.length - 2];
366
    }

Return to bug 36355