Skip to content

Commit

Permalink
Show version when constructing collator instance
Browse files Browse the repository at this point in the history
  • Loading branch information
contrext committed Oct 14, 2016
1 parent 8081a42 commit f7715f5
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
6 changes: 5 additions & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@
<type type="file"/>
</fileset>
</copy>
<copy todir="${org.dita-community.i18n.output.dir}/org/ditacommunity/i18n/saxon">
<fileset dir="${basedir}">
<include name="version.properties"/>
</fileset>
</copy>
</target>

<target name="compile.module.org.dita-community.i18n.tests" depends="compile.module.org.dita-community.i18n.production" description="compile module org.dita-community.i18n; test classes" unless="skip.tests"/>
Expand Down Expand Up @@ -218,7 +223,6 @@
<fileset dir="${basedir}/src/main/java">
<include name="**/resources/**.*" />
</fileset>

</jar>
</target>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
import net.sf.saxon.sort.StringCollator;
import org.ditacommunity.i18n.collation.ZhCnAwareCollator;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
* Resolves references to the DITA Community zh-CN URI resolver, setting the
* properties specified on the URI.
Expand All @@ -15,12 +19,27 @@ public class DCI18nCollationUriResolver91 extends DCI18nCollationUriResolverBase

private final StandardCollationURIResolver defaultResolver;

private static final Properties versionProps = new Properties();

static {
try {
InputStream inStream = DCI18nCollationUriResolver91.class.getResourceAsStream("version.properties");
if (null != inStream) {
versionProps.load(inStream);
}
} catch (Exception e) {
System.err.println("Failed to load version.properties resource from jar file. This should not happen.");
}

}

public DCI18nCollationUriResolver91() {
super();
defaultResolver = StandardCollationURIResolver.getInstance();
}

public StringCollator resolve(String uri, String base, Configuration configuration) {
System.out.println("DCI18nCollationUriResolver91 version " + DCI18nCollationUriResolver91.getVersion());
System.out.println("+ [DEBUG] DCI18nCollationUriResolver91.resolve(): Collation URI=\"" + uri + "\"");
ZhCnAwareCollator collator = resolveToZhCnAwareCollator(uri);
if (null == collator) {
Expand All @@ -31,4 +50,8 @@ public StringCollator resolve(String uri, String base, Configuration configurati
return (StringCollator)collator;
}

private static String getVersion() {
return versionProps.getProperty("version", "Version not set");
}

}
2 changes: 1 addition & 1 deletion version.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=0.1.1
version=0.1.2

0 comments on commit f7715f5

Please sign in to comment.