75
76 /**
77 * recovers current pattern
78 */
79 public String getPattern() {
80 return getPattern(true);
81 }
82
83 /**
84 * recovers current pattern.
85 * @param withWhiteSpace puts spacing around the entries, and \n
86 * before & and <
87 */
88 public String getPattern(boolean withWhiteSpace) {
89 StringBuffer result = new StringBuffer();
90 PatternEntry tmp = null;
91 ArrayList<PatternEntry> extList = null;
92 int i;
93 for (i = 0; i < patterns.size(); ++i) {
94 PatternEntry entry = patterns.get(i);
95 if (entry.extension.length() != 0) {
96 if (extList == null)
97 extList = new ArrayList<>();
98 extList.add(entry);
99 } else {
100 if (extList != null) {
101 PatternEntry last = findLastWithNoExtension(i-1);
102 for (int j = extList.size() - 1; j >= 0 ; j--) {
103 tmp = extList.get(j);
104 tmp.addToBuffer(result, false, withWhiteSpace, last);
105 }
106 extList = null;
107 }
108 entry.addToBuffer(result, false, withWhiteSpace, null);
109 }
110 }
111 if (extList != null) {
112 PatternEntry last = findLastWithNoExtension(i-1);
113 for (int j = extList.size() - 1; j >= 0 ; j--) {
114 tmp = extList.get(j);
115 tmp.addToBuffer(result, false, withWhiteSpace, last);
116 }
117 extList = null;
118 }
119 return result.toString();
120 }
121
122 private final PatternEntry findLastWithNoExtension(int i) {
123 for (--i;i >= 0; --i) {
124 PatternEntry entry = patterns.get(i);
125 if (entry.extension.length() == 0) {
126 return entry;
127 }
128 }
129 return null;
130 }
131
132 /**
133 * emits the pattern for collation builder.
134 * @return emits the string in the format understable to the collation
135 * builder.
136 */
137 public String emitPattern() {
138 return emitPattern(true);
139 }
140
141 /**
142 * emits the pattern for collation builder.
143 * @param withWhiteSpace puts spacing around the entries, and \n
144 * before & and <
145 * @return emits the string in the format understable to the collation
|
75
76 /**
77 * recovers current pattern
78 */
79 public String getPattern() {
80 return getPattern(true);
81 }
82
83 /**
84 * recovers current pattern.
85 * @param withWhiteSpace puts spacing around the entries, and \n
86 * before & and <
87 */
88 public String getPattern(boolean withWhiteSpace) {
89 StringBuffer result = new StringBuffer();
90 PatternEntry tmp = null;
91 ArrayList<PatternEntry> extList = null;
92 int i;
93 for (i = 0; i < patterns.size(); ++i) {
94 PatternEntry entry = patterns.get(i);
95 if (!entry.extension.isEmpty()) {
96 if (extList == null)
97 extList = new ArrayList<>();
98 extList.add(entry);
99 } else {
100 if (extList != null) {
101 PatternEntry last = findLastWithNoExtension(i-1);
102 for (int j = extList.size() - 1; j >= 0 ; j--) {
103 tmp = extList.get(j);
104 tmp.addToBuffer(result, false, withWhiteSpace, last);
105 }
106 extList = null;
107 }
108 entry.addToBuffer(result, false, withWhiteSpace, null);
109 }
110 }
111 if (extList != null) {
112 PatternEntry last = findLastWithNoExtension(i-1);
113 for (int j = extList.size() - 1; j >= 0 ; j--) {
114 tmp = extList.get(j);
115 tmp.addToBuffer(result, false, withWhiteSpace, last);
116 }
117 extList = null;
118 }
119 return result.toString();
120 }
121
122 private final PatternEntry findLastWithNoExtension(int i) {
123 for (--i;i >= 0; --i) {
124 PatternEntry entry = patterns.get(i);
125 if (entry.extension.isEmpty()) {
126 return entry;
127 }
128 }
129 return null;
130 }
131
132 /**
133 * emits the pattern for collation builder.
134 * @return emits the string in the format understable to the collation
135 * builder.
136 */
137 public String emitPattern() {
138 return emitPattern(true);
139 }
140
141 /**
142 * emits the pattern for collation builder.
143 * @param withWhiteSpace puts spacing around the entries, and \n
144 * before & and <
145 * @return emits the string in the format understable to the collation
|