Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoroliviert2016-12-02 16:00:06 -0500
committeroliviert2016-12-02 16:00:06 -0500
commitc2d548d22c377935fba9d50120a0a03c7fd537af (patch)
tree3ec2a79015e7cfcb9d5c04e29f8491d9cda4e819 /org.eclipse.jdt.core.internal.tools
parent455144365ccdb4919a7fca29bcf761d08c72b47a (diff)
downloadeclipse.jdt.core-c2d548d22c377935fba9d50120a0a03c7fd537af.tar.gz
eclipse.jdt.core-c2d548d22c377935fba9d50120a0a03c7fd537af.tar.xz
eclipse.jdt.core-c2d548d22c377935fba9d50120a0a03c7fd537af.zip
Bug 508624 - Tool to generate scanner helper resources for new version
of unicode
Diffstat (limited to 'org.eclipse.jdt.core.internal.tools')
-rw-r--r--org.eclipse.jdt.core.internal.tools/src/org/eclipse/jdt/core/internal/tools/unicode/CodePointsBuilder.java109
-rw-r--r--org.eclipse.jdt.core.internal.tools/src/org/eclipse/jdt/core/internal/tools/unicode/Environment.java16
-rw-r--r--org.eclipse.jdt.core.internal.tools/src/org/eclipse/jdt/core/internal/tools/unicode/FileEncoder.java165
-rw-r--r--org.eclipse.jdt.core.internal.tools/src/org/eclipse/jdt/core/internal/tools/unicode/GenerateIdentifierPartResources.java11
-rw-r--r--org.eclipse.jdt.core.internal.tools/src/org/eclipse/jdt/core/internal/tools/unicode/GenerateIdentifierStartResources.java11
-rw-r--r--org.eclipse.jdt.core.internal.tools/src/org/eclipse/jdt/core/internal/tools/unicode/PartEnvironment.java30
-rw-r--r--org.eclipse.jdt.core.internal.tools/src/org/eclipse/jdt/core/internal/tools/unicode/StartEnvironment.java30
-rw-r--r--org.eclipse.jdt.core.internal.tools/src/org/eclipse/jdt/core/internal/tools/unicode/TableBuilder.java77
-rw-r--r--org.eclipse.jdt.core.internal.tools/src/org/eclipse/jdt/core/internal/tools/unicode/UnicodeResourceGenerator.java43
9 files changed, 492 insertions, 0 deletions
diff --git a/org.eclipse.jdt.core.internal.tools/src/org/eclipse/jdt/core/internal/tools/unicode/CodePointsBuilder.java b/org.eclipse.jdt.core.internal.tools/src/org/eclipse/jdt/core/internal/tools/unicode/CodePointsBuilder.java
new file mode 100644
index 0000000000..b86075dede
--- /dev/null
+++ b/org.eclipse.jdt.core.internal.tools/src/org/eclipse/jdt/core/internal/tools/unicode/CodePointsBuilder.java
@@ -0,0 +1,109 @@
+package org.eclipse.jdt.core.internal.tools.unicode;
+
+import java.text.DecimalFormat;
+import java.util.ArrayList;
+import java.util.Collections;
+
+public class CodePointsBuilder {
+
+ public static Integer[] build(String[] codePointTable, Environment environment) {
+ ArrayList<Integer> values = new ArrayList<>();
+ for (String codePointTableEntry : codePointTable) {
+ if (codePointTableEntry.length() != 0) {
+ int indexOfDots = codePointTableEntry.indexOf(".."); //$NON-NLS-1$
+ if (indexOfDots == -1) {
+ // single value on the line
+ try {
+ values.add(Integer.parseInt(codePointTableEntry, 16));
+ } catch (NumberFormatException e) {
+ System.err.println("NumberFormatException processing : " + codePointTableEntry); //$NON-NLS-1$
+ return null;
+ }
+ } else {
+ // range of values
+ try {
+ int firstValue = Integer.parseInt(codePointTableEntry.substring(0, indexOfDots), 16);
+ int secondValue = Integer.parseInt(codePointTableEntry.substring(indexOfDots + 2), 16);
+ for (int i = firstValue; i <= secondValue; i++) {
+ values.add(i);
+ }
+ } catch (NumberFormatException e) {
+ System.err.println("NumberFormatException processing : " + codePointTableEntry); //$NON-NLS-1$
+ return null;
+ }
+ }
+ }
+ }
+ Collections.sort(values);
+ printDistribution(values, 0x10000);
+ return values.toArray(new Integer[values.size()]);
+ }
+
+ private static void printDistribution(ArrayList<Integer> array, int increment) {
+ int bound = increment;
+ int counter = 0;
+ int totalCounter = 0;
+ int length = array.size();
+ int max = array.get(length - 1).intValue();
+ int numberOfFiguresForRange = (int) (Math.log(max) / Math.log(10));
+ if ((max % increment) == 0) {
+ numberOfFiguresForRange = (int) (Math.log(max + 1) / Math.log(10));
+ }
+ int numberOfFiguresForCounter = (int) (Math.log(length) / Math.log(10));
+ if ((length % increment) == 0) {
+ numberOfFiguresForCounter = (int) (Math.log(length + 1) / Math.log(10));
+ }
+ for (int i = 0; i < length; i++) {
+ if (array.get(i).intValue() < bound) {
+ counter++;
+ } else {
+ i--;
+ totalCounter += counter;
+ printRange(counter, bound, increment, totalCounter, length, numberOfFiguresForRange,
+ numberOfFiguresForCounter);
+ counter = 0;
+ bound += increment;
+ }
+ }
+ totalCounter += counter;
+ printRange(counter, bound, increment, totalCounter, length, numberOfFiguresForRange, numberOfFiguresForCounter);
+ }
+
+ private static void printRange(int counter, int bound, int increment, int totalCounter, int length,
+ int numberOfFiguresForRange, int numberOfFiguresForCounters) {
+ if (counter != 0) {
+ StringBuffer buffer = new StringBuffer();
+ int low = bound - increment;
+ if (low != 0) {
+ low++;
+ }
+ DecimalFormat format = new DecimalFormat("###.##"); //$NON-NLS-1$
+ buffer.append(display(low, numberOfFiguresForRange, 16)).append(" - ") //$NON-NLS-1$
+ .append(display(bound, numberOfFiguresForRange, 16)).append(" : ") //$NON-NLS-1$
+ .append(display(counter, numberOfFiguresForCounters, 10)).append("\t") //$NON-NLS-1$
+ .append((low & 0x1F0000) >> 16).append("\t\t") //$NON-NLS-1$
+ .append(format.format(100.0 * ((double) totalCounter / length)));
+ System.out.println(String.valueOf(buffer));
+ }
+ }
+
+ private static String display(int value, int numberOfFiguresForRange, int radix) {
+ int numberOfFigures = value == 0 ? 1 : (int) (Math.log(value) / Math.log(10));
+ if ((value % 10) == 0) {
+ numberOfFigures = (int) (Math.log(value + 1) / Math.log(10));
+ }
+ StringBuffer buffer = new StringBuffer();
+ switch (radix) {
+ case 10:
+ while (numberOfFigures < numberOfFiguresForRange) {
+ buffer.append(" "); //$NON-NLS-1$
+ numberOfFigures++;
+ }
+ buffer.append(value);
+ break;
+ case 16:
+ buffer.append("0x" + Integer.toHexString(value)); //$NON-NLS-1$
+ }
+ return String.valueOf(buffer);
+ }
+}
diff --git a/org.eclipse.jdt.core.internal.tools/src/org/eclipse/jdt/core/internal/tools/unicode/Environment.java b/org.eclipse.jdt.core.internal.tools/src/org/eclipse/jdt/core/internal/tools/unicode/Environment.java
new file mode 100644
index 0000000000..e2fa003283
--- /dev/null
+++ b/org.eclipse.jdt.core.internal.tools/src/org/eclipse/jdt/core/internal/tools/unicode/Environment.java
@@ -0,0 +1,16 @@
+package org.eclipse.jdt.core.internal.tools.unicode;
+
+public abstract class Environment {
+ /**
+ * Returns <code>true</code> if the given category is a valid one for the current environment, <code>false</code> otherwise.
+ * @param value the given category value
+ * @return <code>true</code> if the given category is a valid one for the current environment, <code>false</code> otherwise.
+ */
+ public abstract boolean hasCategory(String value);
+
+ /**
+ * Returns the resource file name for the given environment.
+ * @return the resource file name for the given environment.
+ */
+ public abstract String getResourceFileName();
+}
diff --git a/org.eclipse.jdt.core.internal.tools/src/org/eclipse/jdt/core/internal/tools/unicode/FileEncoder.java b/org.eclipse.jdt.core.internal.tools/src/org/eclipse/jdt/core/internal/tools/unicode/FileEncoder.java
new file mode 100644
index 0000000000..ad189dde3d
--- /dev/null
+++ b/org.eclipse.jdt.core.internal.tools/src/org/eclipse/jdt/core/internal/tools/unicode/FileEncoder.java
@@ -0,0 +1,165 @@
+package org.eclipse.jdt.core.internal.tools.unicode;
+
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+
+public class FileEncoder {
+ private static final String RESOURCE_FILE_EXTENSION = ".rsc"; //$NON-NLS-1$
+ private final static int Bit1 = 0x1;
+ private final static int Bit2 = 0x2;
+ private final static int Bit3 = 0x4;
+ private final static int Bit4 = 0x8;
+ private final static int Bit5 = 0x10;
+ private final static int Bit6 = 0x20;
+ private final static int Bit7 = 0x40;
+ private final static int Bit8 = 0x80;
+ private final static int Bit9 = 0x100;
+ private final static int Bit10 = 0x200;
+ private final static int Bit11 = 0x400;
+ private final static int Bit12 = 0x800;
+ private final static int Bit13 = 0x1000;
+ private final static int Bit14 = 0x2000;
+ private final static int Bit15 = 0x4000;
+ private final static int Bit16 = 0x8000;
+ private final static int Bit17 = 0x10000;
+ private final static int Bit18 = 0x20000;
+ private final static int Bit19 = 0x40000;
+ private final static int Bit20 = 0x80000;
+ private final static int Bit21 = 0x100000;
+ private final static int Bit22 = 0x200000;
+ private final static int Bit23 = 0x400000;
+ private final static int Bit24 = 0x800000;
+ private final static int Bit25 = 0x1000000;
+ private final static int Bit26 = 0x2000000;
+ private final static int Bit27 = 0x4000000;
+ private final static int Bit28 = 0x8000000;
+ private final static int Bit29 = 0x10000000;
+ private final static int Bit30 = 0x20000000;
+ private final static int Bit31 = 0x40000000;
+ private final static long Bit32 = 0x80000000L;
+ private final static long Bit33 = 0x100000000L;
+ private final static long Bit34 = 0x200000000L;
+ private final static long Bit35 = 0x400000000L;
+ private final static long Bit36 = 0x800000000L;
+ private final static long Bit37 = 0x1000000000L;
+ private final static long Bit38 = 0x2000000000L;
+ private final static long Bit39 = 0x4000000000L;
+ private final static long Bit40 = 0x8000000000L;
+ private final static long Bit41 = 0x10000000000L;
+ private final static long Bit42 = 0x20000000000L;
+ private final static long Bit43 = 0x40000000000L;
+ private final static long Bit44 = 0x80000000000L;
+ private final static long Bit45 = 0x100000000000L;
+ private final static long Bit46 = 0x200000000000L;
+ private final static long Bit47 = 0x400000000000L;
+ private final static long Bit48 = 0x800000000000L;
+ private final static long Bit49 = 0x1000000000000L;
+ private final static long Bit50 = 0x2000000000000L;
+ private final static long Bit51 = 0x4000000000000L;
+ private final static long Bit52 = 0x8000000000000L;
+ private final static long Bit53 = 0x10000000000000L;
+ private final static long Bit54 = 0x20000000000000L;
+ private final static long Bit55 = 0x40000000000000L;
+ private final static long Bit56 = 0x80000000000000L;
+ private final static long Bit57 = 0x100000000000000L;
+ private final static long Bit58 = 0x200000000000000L;
+ private final static long Bit59 = 0x400000000000000L;
+ private final static long Bit60 = 0x800000000000000L;
+ private final static long Bit61 = 0x1000000000000000L;
+ private final static long Bit62 = 0x2000000000000000L;
+ private final static long Bit63 = 0x4000000000000000L;
+ private final static long Bit64 = 0x8000000000000000L;
+ private final static long[] Bits = { Bit1, Bit2, Bit3, Bit4, Bit5, Bit6, Bit7, Bit8, Bit9, Bit10, Bit11, Bit12,
+ Bit13, Bit14, Bit15, Bit16, Bit17, Bit18, Bit19, Bit20, Bit21, Bit22, Bit23, Bit24, Bit25, Bit26, Bit27,
+ Bit28, Bit29, Bit30, Bit31, Bit32, Bit33, Bit34, Bit35, Bit36, Bit37, Bit38, Bit39, Bit40, Bit41, Bit42,
+ Bit43, Bit44, Bit45, Bit46, Bit47, Bit48, Bit49, Bit50, Bit51, Bit52, Bit53, Bit54, Bit55, Bit56, Bit57,
+ Bit58, Bit59, Bit60, Bit61, Bit62, Bit63, Bit64, };
+
+ private static final int BOUND = 64;
+
+ private static final int BLOCK_SIZE = 65536;
+
+ private static final int BLOCK_LENGTH = 1024;
+
+ private static int getBitIndex(int i) {
+ return i % 64;
+ }
+
+ public static void encodeResourceFiles(Integer[] codePoints, Environment environment, String exportDirectory) {
+ File parentFile = new File(exportDirectory);
+ if (!parentFile.exists()) {
+ if (!parentFile.mkdirs()) {
+ System.err.println("Could not create the export directory: " + exportDirectory); //$NON-NLS-1$
+ return;
+ }
+ }
+ long encoding = 0;
+ int length = codePoints.length;
+ int counter = 0;
+ long[] computedValues = new long[BLOCK_LENGTH];
+ int limit = BOUND;
+ int blockLimit = BLOCK_SIZE;
+ int blockNumber = 0;
+ boolean hasMeaningfulValue = false;
+ for (int i = 0; i < length; i++) {
+ if (codePoints[i] < blockLimit) {
+ int valueToEncode = codePoints[i] & 0xFFFF;
+ if (valueToEncode < limit) {
+ encoding |= Bits[getBitIndex(valueToEncode)];
+ } else {
+ i--;
+ computedValues[counter++] = encoding;
+ hasMeaningfulValue |= encoding != 0 ? true : false;
+ encoding = 0;
+ limit += BOUND;
+ }
+ } else {
+ computedValues[counter++] = encoding;
+ try {
+ File f = new File(exportDirectory,
+ environment.getResourceFileName() + blockNumber + RESOURCE_FILE_EXTENSION);
+ if (hasMeaningfulValue) {
+ try (DataOutputStream outputStream = new DataOutputStream(new FileOutputStream(f))) {
+ for (int j = 0, max = computedValues.length; j < max; j++) {
+ long value = computedValues[j];
+ outputStream.writeLong(value);
+ }
+ outputStream.flush();
+ }
+ }
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ counter = 0;
+ hasMeaningfulValue = false;
+ Arrays.fill(computedValues, 0);
+ i--;
+ limit = BOUND;
+ blockLimit += BLOCK_SIZE;
+ blockNumber++;
+ }
+ }
+ computedValues[counter++] = encoding;
+ try {
+ File f = new File(exportDirectory,
+ environment.getResourceFileName() + blockNumber + RESOURCE_FILE_EXTENSION);
+ try (DataOutputStream outputStream = new DataOutputStream(new FileOutputStream(f))) {
+ for (int j = 0, max = computedValues.length; j < max; j++) {
+ long value = computedValues[j];
+ outputStream.writeLong(value);
+ }
+ outputStream.flush();
+ }
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/org.eclipse.jdt.core.internal.tools/src/org/eclipse/jdt/core/internal/tools/unicode/GenerateIdentifierPartResources.java b/org.eclipse.jdt.core.internal.tools/src/org/eclipse/jdt/core/internal/tools/unicode/GenerateIdentifierPartResources.java
new file mode 100644
index 0000000000..2885ed913b
--- /dev/null
+++ b/org.eclipse.jdt.core.internal.tools/src/org/eclipse/jdt/core/internal/tools/unicode/GenerateIdentifierPartResources.java
@@ -0,0 +1,11 @@
+package org.eclipse.jdt.core.internal.tools.unicode;
+
+import java.io.IOException;
+
+public class GenerateIdentifierPartResources {
+
+ public static void main(String[] args) throws IOException {
+ UnicodeResourceGenerator generator = new UnicodeResourceGenerator(args);
+ generator.generate(new PartEnvironment());
+ }
+}
diff --git a/org.eclipse.jdt.core.internal.tools/src/org/eclipse/jdt/core/internal/tools/unicode/GenerateIdentifierStartResources.java b/org.eclipse.jdt.core.internal.tools/src/org/eclipse/jdt/core/internal/tools/unicode/GenerateIdentifierStartResources.java
new file mode 100644
index 0000000000..96a0b93082
--- /dev/null
+++ b/org.eclipse.jdt.core.internal.tools/src/org/eclipse/jdt/core/internal/tools/unicode/GenerateIdentifierStartResources.java
@@ -0,0 +1,11 @@
+package org.eclipse.jdt.core.internal.tools.unicode;
+
+import java.io.IOException;
+
+public class GenerateIdentifierStartResources {
+
+ public static void main(String[] args) throws IOException {
+ UnicodeResourceGenerator generator = new UnicodeResourceGenerator(args);
+ generator.generate(new StartEnvironment());
+ }
+}
diff --git a/org.eclipse.jdt.core.internal.tools/src/org/eclipse/jdt/core/internal/tools/unicode/PartEnvironment.java b/org.eclipse.jdt.core.internal.tools/src/org/eclipse/jdt/core/internal/tools/unicode/PartEnvironment.java
new file mode 100644
index 0000000000..1abf8350f1
--- /dev/null
+++ b/org.eclipse.jdt.core.internal.tools/src/org/eclipse/jdt/core/internal/tools/unicode/PartEnvironment.java
@@ -0,0 +1,30 @@
+package org.eclipse.jdt.core.internal.tools.unicode;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public class PartEnvironment extends Environment {
+ private static final String RESOURCE_FILE_NAME = "part"; //$NON-NLS-1$
+
+ private static enum Category {
+ Lu, Ll, Lt, Lm, Lo, Nl, Sc, Pc, Nd, Mc, Mn, Cf;
+ }
+
+ private static final Set<String> categories = new HashSet<>();
+ static {
+ for (Category c : Category.values()) {
+ categories.add(c.name());
+ }
+ }
+
+ @Override
+ public boolean hasCategory(String value) {
+ return categories.contains(value);
+ }
+
+ @Override
+ public String getResourceFileName() {
+ return RESOURCE_FILE_NAME;
+ }
+
+}
diff --git a/org.eclipse.jdt.core.internal.tools/src/org/eclipse/jdt/core/internal/tools/unicode/StartEnvironment.java b/org.eclipse.jdt.core.internal.tools/src/org/eclipse/jdt/core/internal/tools/unicode/StartEnvironment.java
new file mode 100644
index 0000000000..ec6b50ad87
--- /dev/null
+++ b/org.eclipse.jdt.core.internal.tools/src/org/eclipse/jdt/core/internal/tools/unicode/StartEnvironment.java
@@ -0,0 +1,30 @@
+package org.eclipse.jdt.core.internal.tools.unicode;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public class StartEnvironment extends Environment {
+ private static final String RESOURCE_FILE_NAME = "start"; //$NON-NLS-1$
+
+ private static enum Category {
+ Lu, Ll, Lt, Lm, Lo, Nl, Sc, Pc
+ }
+
+ private static final Set<String> categories = new HashSet<>();
+ static {
+ for (Category c : Category.values()) {
+ categories.add(c.name());
+ }
+ }
+
+ @Override
+ public boolean hasCategory(String value) {
+ return categories.contains(value);
+ }
+
+ @Override
+ public String getResourceFileName() {
+ return RESOURCE_FILE_NAME;
+ }
+
+}
diff --git a/org.eclipse.jdt.core.internal.tools/src/org/eclipse/jdt/core/internal/tools/unicode/TableBuilder.java b/org.eclipse.jdt.core.internal.tools/src/org/eclipse/jdt/core/internal/tools/unicode/TableBuilder.java
new file mode 100644
index 0000000000..870d3eb1b3
--- /dev/null
+++ b/org.eclipse.jdt.core.internal.tools/src/org/eclipse/jdt/core/internal/tools/unicode/TableBuilder.java
@@ -0,0 +1,77 @@
+package org.eclipse.jdt.core.internal.tools.unicode;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+public class TableBuilder {
+
+ private static final String CHAR_ELEMENT = "char"; //$NON-NLS-1$
+ private static final String SINCE_UNICODE_VERSION = "age"; //$NON-NLS-1$
+ private static final String CODE_POINT = "cp"; //$NON-NLS-1$
+ private static final String GROUP_CODE = "gc"; //$NON-NLS-1$
+
+ public static String[] buildTables(
+ final double unicodeValue,
+ boolean usePredefinedRange,
+ Environment env,
+ String unicodeDataFileName) throws IOException {
+
+ List<String> result = new ArrayList<>();
+ SAXParser saxParser = null;
+ try {
+ saxParser = SAXParserFactory.newInstance().newSAXParser();
+ } catch (ParserConfigurationException e) {
+ e.printStackTrace();
+ return null;
+ } catch (SAXException e) {
+ e.printStackTrace();
+ return null;
+ }
+ DefaultHandler defaultHandler = new DefaultHandler() {
+ @Override
+ public void startElement(String uri, String localName, String qName, Attributes attributes)
+ throws SAXException {
+ if (CHAR_ELEMENT.equals(qName)) {
+ final String group = attributes.getValue(GROUP_CODE);
+ if (env.hasCategory(group)) {
+ final String codePoint = attributes.getValue(CODE_POINT);
+ final String age = attributes.getValue(SINCE_UNICODE_VERSION);
+ double ageValue = 0.0;
+ try {
+ ageValue = Double.parseDouble(age);
+ } catch (NumberFormatException e) {
+ e.printStackTrace();
+ }
+ if (ageValue <= unicodeValue) {
+ result.add(codePoint);
+ }
+ }
+ }
+ }
+ };
+ try {
+ saxParser.parse(new File(unicodeDataFileName), defaultHandler);
+ } catch (SAXException e) {
+ e.printStackTrace();
+ return null;
+ }
+ if (usePredefinedRange) {
+ // predefined ranges - ISO control character (see
+ // isIdentifierIgnorable(int))
+ result.add("0000..0008"); //$NON-NLS-1$
+ result.add("000E..001B"); //$NON-NLS-1$
+ result.add("007F..009F"); //$NON-NLS-1$
+ }
+ return result.toArray(new String[result.size()]);
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.core.internal.tools/src/org/eclipse/jdt/core/internal/tools/unicode/UnicodeResourceGenerator.java b/org.eclipse.jdt.core.internal.tools/src/org/eclipse/jdt/core/internal/tools/unicode/UnicodeResourceGenerator.java
new file mode 100644
index 0000000000..46ee184230
--- /dev/null
+++ b/org.eclipse.jdt.core.internal.tools/src/org/eclipse/jdt/core/internal/tools/unicode/UnicodeResourceGenerator.java
@@ -0,0 +1,43 @@
+package org.eclipse.jdt.core.internal.tools.unicode;
+
+import java.io.IOException;
+
+public class UnicodeResourceGenerator {
+
+ double unicodeValue = -1.0;
+ String[] args = null;
+
+ UnicodeResourceGenerator(String[] args) {
+ if (args.length != 3) {
+ System.err.println("Usage: " + GenerateIdentifierStartResources.class + " <unicode version> <path to ucd.all.flat.xml> <export directory>"); //$NON-NLS-1$ //$NON-NLS-2$
+ return;
+ }
+
+ this.unicodeValue = 0.0;
+ try {
+ this.unicodeValue = Double.parseDouble(args[0]);
+ } catch (NumberFormatException e) {
+ System.err.println("<unicode version> has the wrong format. Expecting a double value. e.g. 8.0"); //$NON-NLS-1$
+ return;
+ }
+ this.args = args;
+ }
+
+ public void generate(Environment environment) throws IOException {
+ if (this.args == null) {
+ // wrong settings
+ return;
+ }
+ String[] codePointTable = TableBuilder.buildTables(this.unicodeValue, true, environment, this.args[1]);
+ if (codePointTable == null) {
+ System.err.println("Generation failed"); //$NON-NLS-1$
+ return;
+ }
+ Integer[] codePoints = CodePointsBuilder.build(codePointTable, environment);
+ if (codePoints == null) {
+ System.err.println("Generation failed"); //$NON-NLS-1$
+ return;
+ }
+ FileEncoder.encodeResourceFiles(codePoints, environment, this.args[2]);
+ }
+}

Back to the top