KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > lib > lexer > test > RandomModifyDescriptor


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.lib.lexer.test;
21
22 public class RandomModifyDescriptor {
23
24     private final int opCount;
25
26     private final RandomTextProvider randomTextProvider;
27
28     private final double insertCharRatio;
29
30     private final double insertTextRatio;
31
32     private int insertTextMaxLength = 10;
33
34     private final double insertFixedTextRatio;
35
36     private final double removeCharRatio;
37
38     private final double removeTextRatio;
39
40     private int removeTextMaxLength = 10;
41
42     private final double createSnapshotRatio;
43     
44     private final double destroySnapshotRatio;
45
46     private double ratioSum;
47     
48     private boolean ratioSumInited;
49
50     public RandomModifyDescriptor(int opCount, RandomTextProvider randomTextProvider,
51     double insertCharRatio, double insertTextRatio, double insertFixedTextRatio,
52     double removeCharRatio, double removeTextRatio,
53     double createSnapshotRatio, double destroySnapshotRatio) {
54         this.opCount = opCount;
55         this.randomTextProvider = randomTextProvider;
56         this.insertCharRatio = insertCharRatio;
57         this.insertTextRatio = insertTextRatio;
58         this.insertFixedTextRatio = insertFixedTextRatio;
59         this.removeCharRatio = removeCharRatio;
60         this.removeTextRatio = removeTextRatio;
61         this.createSnapshotRatio = createSnapshotRatio;
62         this.destroySnapshotRatio = destroySnapshotRatio;
63     }
64     
65     protected double computeRatioSum() {
66         return insertCharRatio + insertTextRatio + insertFixedTextRatio
67                 + removeCharRatio + removeTextRatio
68                 + createSnapshotRatio + destroySnapshotRatio;
69     }
70     
71     public int opCount() {
72         return opCount;
73     }
74     
75     public RandomTextProvider randomTextProvider() {
76         return randomTextProvider;
77     }
78
79     public double insertCharRatio() {
80         return insertCharRatio;
81     }
82     
83     public double insertTextRatio() {
84         return insertTextRatio;
85     }
86     
87     public int insertTextMaxLength() {
88         return insertTextMaxLength;
89     }
90     
91     public double insertFixedTextRatio() {
92         return insertFixedTextRatio;
93     }
94
95     public void setInsertTextMaxLength(int insertTextMaxLength) {
96         this.insertTextMaxLength = insertTextMaxLength;
97     }
98     
99     public double removeCharRatio() {
100         return removeCharRatio;
101     }
102     
103     public double removeTextRatio() {
104         return removeTextRatio;
105     }
106     
107     public int removeTextMaxLength() {
108         return removeTextMaxLength;
109     }
110
111     public void setRemoveTextMaxLength(int removeTextMaxLength) {
112         this.removeTextMaxLength = removeTextMaxLength;
113     }
114     
115     public double ratioSum() {
116         if (!ratioSumInited) {
117             ratioSumInited = true;
118             ratioSum = computeRatioSum();
119         }
120         return ratioSum;
121     }
122
123     public double createSnapshotRatio() {
124         return createSnapshotRatio;
125     }
126     
127     public double destroySnapshotRatio() {
128         return destroySnapshotRatio;
129     }
130     
131 }
Popular Tags