Permalink
Browse files

Issue #75 - Android support.

The class-build order appears to be subtly different for Android, which, in this enum, causes the items to become available at a different time (compated to regular Java). By restructring the 'DEFAULT' enum build process we end up with a better solution for both regular Java and Android.
  • Loading branch information...
1 parent df606e1 commit 081640873760d333090d19b7d98173231a16e930 @rolfl rolfl committed Apr 19, 2012
Showing with 13 additions and 11 deletions.
  1. +13 −11 core/src/java/org/jdom2/output/LineSeparator.java
@@ -158,20 +158,22 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
private static String getDefaultLineSeparator() {
- String def = LineSeparator.DOS.value();
- String prop = System.getProperty(JDOMConstants.JDOM2_PROPERTY_LINE_SEPARATOR, def);
+ // Android has some unique ordering requirements in this bootstrap process.
+ // also, Android will not have the system property set, so we can exit with the null.
+ final String prop = System.getProperty(JDOMConstants.JDOM2_PROPERTY_LINE_SEPARATOR, "DEFAULT");
if ("DEFAULT".equals(prop)) {
- // need to do this to catch an unlikelye instance when someone sets
+ // need to do this to catch the normal process where the property is not set
+ // which will cause the value 'DEFAULT' to be returned by the getProperty(),
+ // or in an unlikely instance when someone sets
// -Dorg.jdom2.output.LineSeparator=DEFAULT
// which would create some sort of loop to happen....
- prop = "\r\n";
- } else {
- try {
- LineSeparator sep = Enum.valueOf(LineSeparator.class, prop);
- prop = sep.value();
- } catch (Exception e) {
- // ignore it, just use the prop.
- }
+ return DOS.value();
+ }
+ try {
+ final LineSeparator sep = Enum.valueOf(LineSeparator.class, prop);
+ return sep.value();
+ } catch (Exception e) {
+ // ignore it, just use the prop.
}
return prop;
}

0 comments on commit 0816408

Please sign in to comment.