Skip to content

Commit 323be55

Browse files
committed
remove UseShortJavaName code - should be in its own PR
1 parent bc4c826 commit 323be55

File tree

8 files changed

+5
-119
lines changed

8 files changed

+5
-119
lines changed

src/main/java/org/apache/xmlbeans/XmlOptions.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,21 +1069,6 @@ public boolean isCompileDownloadUrls() {
10691069
return hasOption(XmlOptionsKeys.COMPILE_DOWNLOAD_URLS);
10701070
}
10711071

1072-
/**
1073-
* If this option is set, then the schema compiler will use the java_short_name to generate file name
1074-
*
1075-
*/
1076-
public XmlOptions setCompileUseShortJavaName() {
1077-
return setCompileUseShortJavaName(true);
1078-
}
1079-
1080-
public XmlOptions setCompileUseShortJavaName(boolean b) {
1081-
return set(XmlOptionsKeys.USE_JAVA_SHORT_NAME, b);
1082-
}
1083-
1084-
public boolean isCompileUseShortJavaName() {
1085-
return hasOption(XmlOptionsKeys.USE_JAVA_SHORT_NAME);
1086-
}
10871072
/**
10881073
* If this option is set, then the schema compiler will permit and
10891074
* ignore multiple definitions of the same component (element, attribute,

src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypePool.java

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,7 @@ String handleForElement(SchemaGlobalElement element) {
8989
}
9090
String handle = _componentsToHandles.get(element);
9191
if (handle == null) {
92-
if(typeSystem.isUseShortJavaName()) {
93-
SchemaType type = element.getType();
94-
String javaName = type.getShortJavaName();
95-
if (javaName != null && !javaName.isEmpty()) {
96-
handle = addUniqueHandle(element, NameUtil.upperCamelCase(javaName) + "Element");
97-
} else {
98-
handle = addUniqueHandle(element, NameUtil.upperCamelCase(element.getName().getLocalPart()) + "Element");
99-
}
100-
} else {
101-
handle = addUniqueHandle(element, NameUtil.upperCamelCase(element.getName().getLocalPart()) + "Element");
102-
}
92+
handle = addUniqueHandle(element, NameUtil.upperCamelCase(element.getName().getLocalPart()) + "Element");
10393
}
10494
return handle;
10595
}
@@ -189,15 +179,7 @@ String handleForType(SchemaType type) {
189179
if (name == null) {
190180
baseName = "Anon" + uniq + "Type";
191181
} else {
192-
if(typeSystem.isUseShortJavaName()) {
193-
String javaName = type.getShortJavaName();
194-
if (javaName == null || javaName.isEmpty())
195-
javaName = name.getLocalPart();
196-
baseName = NameUtil.upperCamelCase(javaName) + uniq + suffix + "Type";
197-
}
198-
else {
199-
baseName = NameUtil.upperCamelCase(name.getLocalPart()) + uniq + suffix + "Type";
200-
}
182+
baseName = NameUtil.upperCamelCase(name.getLocalPart()) + uniq + suffix + "Type";
201183
}
202184

203185
handle = addUniqueHandle(type, baseName);

src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ public class SchemaTypeSystemImpl extends SchemaTypeLoaderBase implements Schema
166166

167167
// the additional config option
168168
private String _sourceCodeEncoding ;
169-
private boolean _useShortJavaName;
170169

171170
static String nameToPathString(String nameForSystem) {
172171
nameForSystem = nameForSystem.replace('.', '/');
@@ -319,25 +318,7 @@ void savePointers() {
319318

320319
void savePointersForComponents(SchemaComponent[] components, String dir) {
321320
for (SchemaComponent component : components) {
322-
if(_useShortJavaName) {
323-
String javaName = _localHandles.handleForComponent(component);
324-
if (javaName != null && !javaName.isEmpty())
325-
{
326-
QName nameTemp = component.getName();
327-
String resultName;
328-
if (nameTemp.getNamespaceURI() == null || nameTemp.getNamespaceURI().length() == 0) {
329-
resultName = "_nons/" + QNameHelper.hexsafe(javaName);
330-
} else {
331-
resultName = QNameHelper.hexsafe(nameTemp.getNamespaceURI()) + "/"
332-
+ QNameHelper.hexsafe(javaName);
333-
}
334-
savePointerFile(dir + resultName, _name);
335-
} else {
336-
savePointerFile(dir + QNameHelper.hexsafedir(component.getName()), _name);
337-
}
338-
} else {
339-
savePointerFile(dir + QNameHelper.hexsafedir(component.getName()), _name);
340-
}
321+
savePointerFile(dir + QNameHelper.hexsafedir(component.getName()), _name);
341322
}
342323
}
343324

@@ -440,10 +421,6 @@ String getSourceCodeEncoding() {
440421
return _sourceCodeEncoding ;
441422
}
442423

443-
boolean isUseShortJavaName(){
444-
return _useShortJavaName;
445-
}
446-
447424
@SuppressWarnings("unchecked")
448425
private <T extends SchemaComponent.Ref> void buildContainersHelper(Map<QName, SchemaComponent.Ref> elements, BiConsumer<SchemaContainer, T> adder) {
449426
elements.forEach((k, v) -> adder.accept(getContainerNonNull(k.getNamespaceURI()), (T) v));
@@ -648,7 +625,6 @@ public void loadFromStscState(StscState state) {
648625
_annotations = state.annotations();
649626
_namespaces = new HashSet<>(Arrays.asList(state.getNamespaces()));
650627
_containers = state.getContainerMap();
651-
_useShortJavaName = state.useShortName();
652628
_sourceCodeEncoding = state.sourceCodeEncoding();
653629
fixupContainers();
654630
// Checks that data in the containers matches the lookup maps

src/main/java/org/apache/xmlbeans/impl/schema/StscState.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ public class StscState {
103103
private boolean _noPvr;
104104
private boolean _noAnn;
105105
private boolean _mdefAll;
106-
private boolean _useShortJavaName;
107106
private String _sourceCodeEncoding ;
108107
private final Set<String> _mdefNamespaces = buildDefaultMdefNamespaces();
109108
private EntityResolver _entityResolver;
@@ -465,8 +464,6 @@ public void setOptions(XmlOptions options) {
465464
if (_sourceCodeEncoding == null || _sourceCodeEncoding.isEmpty()) {
466465
_sourceCodeEncoding = SystemProperties.getProperty("xmlbean.sourcecodeencoding");
467466
}
468-
_useShortJavaName = options.isCompileUseShortJavaName() ||
469-
"true".equals(SystemProperties.getProperty("xmlbean.useshortjavaname", "false"));
470467
_entityResolver = options.getEntityResolver();
471468

472469
if (_entityResolver == null) {
@@ -539,14 +536,6 @@ public String sourceCodeEncoding() {
539536
return _sourceCodeEncoding ;
540537
}
541538

542-
/**
543-
* True if use the java_short_name to generate file name
544-
*/
545-
// EXPERIMENTAL
546-
public boolean useShortName() {
547-
return _useShortJavaName;
548-
}
549-
550539
/**
551540
* Get count of recovered errors. Not for public.
552541
*/

src/main/java/org/apache/xmlbeans/impl/tool/MavenPlugin.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,6 @@ public class MavenPlugin extends AbstractMojo {
192192
@Parameter
193193
private String sourceCodeEncoding;
194194

195-
/**
196-
* Used for File Names.
197-
*
198-
* @since 5.2.2
199-
*/
200-
@Parameter( defaultValue = "false" )
201-
private boolean useShortJavaName;
202-
203195
@Parameter
204196
private List<Extension> extensions;
205197

@@ -320,7 +312,6 @@ public void execute() throws MojoExecutionException, MojoFailureException {
320312
if (sourceCodeEncoding != null && !sourceCodeEncoding.isEmpty()) {
321313
params.setSourceCodeEncoding(sourceCodeEncoding);
322314
}
323-
params.setUseShortJavaName(useShortJavaName);
324315

325316
boolean result = SchemaCompiler.compile(params);
326317

src/main/java/org/apache/xmlbeans/impl/tool/Parameters.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ public class Parameters {
5454
private boolean noExt;
5555
private boolean debug;
5656
private boolean copyAnn;
57-
private boolean useShortJavaName;
5857
private String sourceCodeEncoding;
5958
private boolean incrementalSrcGen;
6059
private String repackage;
@@ -205,10 +204,6 @@ public boolean isNoAnn() {
205204
return noAnn;
206205
}
207206

208-
public boolean isUseShortJavaName() {
209-
return useShortJavaName;
210-
}
211-
212207
public String getSourceCodeEncoding() {
213208
return sourceCodeEncoding;
214209
}
@@ -249,10 +244,6 @@ public void setDebug(boolean debug) {
249244
this.debug = debug;
250245
}
251246

252-
public void setUseShortJavaName(boolean useShortJavaName) {
253-
this.useShortJavaName = useShortJavaName;
254-
}
255-
256247
public void setSourceCodeEncoding(String sourceCodeEncoding) {
257248
this.sourceCodeEncoding = sourceCodeEncoding;
258249
}

src/main/java/org/apache/xmlbeans/impl/tool/SchemaCompiler.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ public static void printUsage() {
6868
System.out.println(" -repackage - repackage specification, e.g. \"org.apache.xmlbeans.metadata:mypackage.metadata\" to change the metadata directory");
6969
System.out.println(" -copyann - copy schema annotations to javadoc (default false) - don't activate on untrusted schema sources!");
7070
System.out.println(" -sourcecodeencoding [encodingName] - Generate Java source code with the specified encoding (ISO-8859-1 is the legacy default)");
71-
System.out.println(" -useshortjavaname - Generate file name using Short Java Name");
7271
/* Undocumented feature - pass in one schema compiler extension and related parameters
7372
System.out.println(" -extension - registers a schema compiler extension");
7473
System.out.println(" -extensionParms - specify parameters for the compiler extension");
@@ -100,7 +99,6 @@ public static void main(String[] args) {
10099
flags.add("noext");
101100
flags.add("srconly");
102101
flags.add("debug");
103-
flags.add("useshortjavaname");
104102

105103
Set<String> opts = new HashSet<>();
106104
opts.add("out");
@@ -191,7 +189,6 @@ public static void main(String[] args) {
191189
boolean debug = (cl.getOpt("debug") != null);
192190
boolean copyAnn = (cl.getOpt("copyann") != null);
193191
String sourceCodeEncoding = cl.getOpt("sourcecodeencoding");
194-
boolean useShortJavaName = (cl.getOpt("useshortjavaname") != null);
195192

196193
String allowmdef = cl.getOpt("allowmdef");
197194
Set<String> mdefNamespaces = (allowmdef == null ? Collections.emptySet() :
@@ -340,7 +337,6 @@ public static void main(String[] args) {
340337
params.setNoExt(noExt);
341338
params.setDebug(debug);
342339
params.setSourceCodeEncoding(sourceCodeEncoding);
343-
params.setUseShortJavaName(useShortJavaName);
344340
params.setErrorListener(err);
345341
params.setRepackage(repackage);
346342
params.setExtensions(extensions);
@@ -364,7 +360,7 @@ public static void main(String[] args) {
364360

365361
private static SchemaTypeSystem loadTypeSystem(String name, File[] xsdFiles, File[] wsdlFiles, URL[] urlFiles, File[] configFiles,
366362
File[] javaFiles, ResourceLoader cpResourceLoader,
367-
boolean download, boolean noUpa, boolean noPvr, boolean noAnn, boolean noVDoc, boolean noExt, String sourceCodeEncoding, boolean useShortName,
363+
boolean download, boolean noUpa, boolean noPvr, boolean noAnn, boolean noVDoc, boolean noExt, String sourceCodeEncoding,
368364
Set<String> mdefNamespaces, File baseDir, Map<String, String> sourcesToCopyMap,
369365
Collection<XmlError> outerErrorListener, File schemasDir, EntityResolver entResolver, File[] classpath) {
370366
XmlErrorWatcher errorListener = new XmlErrorWatcher(outerErrorListener);
@@ -532,9 +528,6 @@ private static SchemaTypeSystem loadTypeSystem(String name, File[] xsdFiles, Fil
532528
if (sourceCodeEncoding != null ) {
533529
opts.setCharacterEncoding(sourceCodeEncoding);
534530
}
535-
if (useShortName) {
536-
opts.setCompileUseShortJavaName();
537-
}
538531
if (mdefNamespaces != null) {
539532
opts.setCompileMdefNamespaces(mdefNamespaces);
540533
}
@@ -629,7 +622,6 @@ public static boolean compile(Parameters params) {
629622
boolean incrSrcGen = params.isIncrementalSrcGen();
630623
boolean copyAnn = params.isCopyAnn();
631624
String sourceCodeEncoding = params.getSourceCodeEncoding();
632-
boolean useShortName = params.isUseShortJavaName();
633625
Collection<XmlError> outerErrorListener = params.getErrorListener();
634626
Set<BeanMethod> partialMethods = params.getPartialMethods();
635627

@@ -682,7 +674,7 @@ public static boolean compile(Parameters params) {
682674
// build the in-memory type system
683675
XmlErrorWatcher errorListener = new XmlErrorWatcher(outerErrorListener);
684676
SchemaTypeSystem system = loadTypeSystem(name, xsdFiles, wsdlFiles, urlFiles, configFiles,
685-
javaFiles, cpResourceLoader, download, noUpa, noPvr, noAnn, noVDoc, noExt, sourceCodeEncoding, useShortName, mdefNamespaces,
677+
javaFiles, cpResourceLoader, download, noUpa, noPvr, noAnn, noVDoc, noExt, sourceCodeEncoding, mdefNamespaces,
686678
baseDir, sourcesToCopyMap, errorListener, schemasDir, cmdLineEntRes, classpath);
687679
if (errorListener.hasError()) {
688680
result = false;
@@ -710,7 +702,6 @@ public static boolean compile(Parameters params) {
710702
options.setCompileNoAnnotations(noAnn);
711703
options.setCompileAnnotationAsJavadoc(copyAnn);
712704
options.setCharacterEncoding(sourceCodeEncoding);
713-
options.setCompileUseShortJavaName(useShortName);
714705

715706
// save .xsb files
716707
system.save(filer);

src/test/java/compile/scomp/checkin/XmlBeansCompCheckinTests.java

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -99,25 +99,6 @@ void test_Filer_compilation() throws Exception {
9999
MatcherAssert.assertThat(f.getSrcFileVec(), is(expSrcType));
100100
}
101101

102-
@Test
103-
void test_Filer_shortname_compilation() throws Exception {
104-
XmlObject obj1 = XmlObject.Factory.parse(FOR_XSD);
105-
XmlObject[] schemas = new XmlObject[]{obj1};
106-
107-
TestFiler f = new TestFiler();
108-
xm_opts.setCompileUseShortJavaName();
109-
XmlBeans.compileXmlBeans("apiCompile", null, schemas, null, XmlBeans.getBuiltinTypeSystem(), f, xm_opts);
110-
111-
assertTrue(f.isCreateBinaryFile(), "Binary File method not invoked");
112-
assertTrue(f.isCreateSourceFile(), "Source File method not invoked");
113-
114-
assertNotNull(f.getBinFileVec());
115-
MatcherAssert.assertThat(f.getBinFileVec(), is(expBinShortnameType));
116-
117-
assertNotNull(f.getSrcFileVec());
118-
MatcherAssert.assertThat(f.getSrcFileVec(), is(expSrcType));
119-
}
120-
121102
/**
122103
* Verify Partial SOM cannot be saved to file system
123104
*/

0 commit comments

Comments
 (0)