1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
|
From: Giovanni Mascellani <mascellani@poisson.phc.unipi.it>
Subject: [PATCH] patch/XMLCharacterProperties.java
Substitute for XMLCharacterProperties.java, which is not compatible with LGPL.
Signed-off-by: Giovanni Mascellani <mascellani@poisson.phc.unipi.it>
---
.../java/jas/util/xml/XMLCharacterProperties.java | 80 ++++++++++++++++++++
1 files changed, 80 insertions(+), 0 deletions(-)
diff --git a/src/main/java/jas/util/xml/XMLCharacterProperties.java b/src/main/java/jas/util/xml/XMLCharacterProperties.java
new file mode 100644
index 0000000..394acd7
--- /dev/null
+++ b/src/main/java/jas/util/xml/XMLCharacterProperties.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2010 by Giovanni Mascellani <mascellani@poisson.phc.unipi.it>
+ *
+ * This class is meant as a substitute for the original XMLCharacterProperties
+ * in JAS Plotter, which is picked out from Xerces, but it licensed
+ * under Apache 1.1 license (GPL-incompatible). IT IS NOT A COMPLETE
+ * REPLACEMENT: it just implements the three methods needed by JAS Plotter.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+package jas.util.xml;
+
+public class XMLCharacterProperties {
+
+ public static boolean isLetter(char c) {
+ return ((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z'));
+ }
+
+ public static boolean isDigit(char c) {
+ return (c >= '0') && (c <= '9');
+ }
+
+ /*
+ * [26] VersionNum ::= ([a-zA-Z0-9_.:] | '-')+
+ */
+ public static boolean validVersionNum(String name) {
+ int len = name.length();
+ if (len == 0) return false;
+ for (int i = 0; i < len; i++) {
+ char c = name.charAt(i);
+ if (!(isLetter(c) || isDigit(c) || c == '_' || c == '.' || c == ':' || c == '-')) return false;
+ }
+ return true;
+ }
+
+ /*
+ * [81] EncName ::= [A-Za-z] ([A-Za-z0-9._] | '-')*
+ */
+ public static boolean validEncName(String name) {
+ int len = name.length();
+ if (len == 0) return false;
+ if (!isLetter(name.charAt(0))) return false;
+ for (int i = 1; i < len; i++) {
+ char c = name.charAt(i);
+ if (!(isLetter(c) || isDigit(c) || c == '.' || c == '_' || c == '-')) return false;
+ }
+ return true;
+ }
+
+ /*
+ * [5] Name ::= (Letter | '_' | ':') (NameChar)*
+ */
+ public static boolean validName(String name) {
+ int len = name.length();
+ if (len == 0) return false;
+ char c = name.charAt(0);
+ if (!(isLetter(c) || c == '_' || c == ':')) return false;
+ for (int i = 1; i < len; i++) {
+ c = name.charAt(i);
+ if (!(isLetter(c) || isDigit(c) || c == '_' || c == '.' || c == ':' || c == '-')) return false;
+ }
+ return true;
+ }
+
+}
+
--
tg: (2e38280..) patch/XMLCharacterProperties.java (depends on: master)
|