134 helper.reportError("The string \"" + trArg + "\" is not a " +
135 "valid translate pattern");
136 return;
137 }
138
139 // Extract relevant parts
140 String suffix = m.group("suffix");
141 String classname = m.group("class");
142 String extra = m.group("extra");
143
144 // Valid suffix?
145 if (suffix.matches("\\.(class|java)")) {
146 helper.reportError("You cannot have a translator for " +
147 suffix + " files!");
148 return;
149 }
150
151 // Construct transformer
152 try {
153 Class<?> trCls = Class.forName(classname);
154 Transformer transformer = (Transformer) trCls.newInstance();
155 transformer.setExtra(extra);
156 helper.addTransformer(suffix, transformer);
157 } catch (Exception e) {
158 helper.reportError("Cannot use " + classname +
159 " as a translator: " + e.getMessage());
160 }
161 }
162 },
163 COPY("-copy", "Copy resources") {
164 @Override
165 protected void processMatching(ArgumentIterator iter, OptionHelper helper) {
166 if (!iter.hasNext()) {
167 helper.reportError(arg + " must be followed by a resource type");
168 return;
169 }
170
171 String copyArg = iter.next();
172
173 // Validate argument syntax. Examples: .gif, .html
|
134 helper.reportError("The string \"" + trArg + "\" is not a " +
135 "valid translate pattern");
136 return;
137 }
138
139 // Extract relevant parts
140 String suffix = m.group("suffix");
141 String classname = m.group("class");
142 String extra = m.group("extra");
143
144 // Valid suffix?
145 if (suffix.matches("\\.(class|java)")) {
146 helper.reportError("You cannot have a translator for " +
147 suffix + " files!");
148 return;
149 }
150
151 // Construct transformer
152 try {
153 Class<?> trCls = Class.forName(classname);
154 @SuppressWarnings("deprecation")
155 Transformer transformer = (Transformer) trCls.newInstance();
156 transformer.setExtra(extra);
157 helper.addTransformer(suffix, transformer);
158 } catch (Exception e) {
159 helper.reportError("Cannot use " + classname +
160 " as a translator: " + e.getMessage());
161 }
162 }
163 },
164 COPY("-copy", "Copy resources") {
165 @Override
166 protected void processMatching(ArgumentIterator iter, OptionHelper helper) {
167 if (!iter.hasNext()) {
168 helper.reportError(arg + " must be followed by a resource type");
169 return;
170 }
171
172 String copyArg = iter.next();
173
174 // Validate argument syntax. Examples: .gif, .html
|