summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Waibel2010-08-05 14:42:46 (EDT)
committer Steve Powell2010-08-05 14:42:46 (EDT)
commit5b73e31ba60ec7d4fb896b032a83f0eda78f6c42 (patch)
treee2e464c228f8981618186e472222773a6e47236c
parent3f082d736ce985cec4956471cbe8aa46f916425c (diff)
downloadorg.eclipse.virgo.util-5b73e31ba60ec7d4fb896b032a83f0eda78f6c42.zip
org.eclipse.virgo.util-5b73e31ba60ec7d4fb896b032a83f0eda78f6c42.tar.gz
org.eclipse.virgo.util-5b73e31ba60ec7d4fb896b032a83f0eda78f6c42.tar.bz2
Add tests and lexer for package attribute names.
-rw-r--r--org.eclipse.virgo.util.osgi/src/main/java/org/eclipse/virgo/util/osgi/manifest/parse/standard/StandardHeaderLexer.java59
-rw-r--r--org.eclipse.virgo.util.osgi/src/test/java/org/eclipse/virgo/util/osgi/manifest/parse/standard/StandardHeaderParserTests.java26
2 files changed, 81 insertions, 4 deletions
diff --git a/org.eclipse.virgo.util.osgi/src/main/java/org/eclipse/virgo/util/osgi/manifest/parse/standard/StandardHeaderLexer.java b/org.eclipse.virgo.util.osgi/src/main/java/org/eclipse/virgo/util/osgi/manifest/parse/standard/StandardHeaderLexer.java
index 5e3547d..f4e8621 100644
--- a/org.eclipse.virgo.util.osgi/src/main/java/org/eclipse/virgo/util/osgi/manifest/parse/standard/StandardHeaderLexer.java
+++ b/org.eclipse.virgo.util.osgi/src/main/java/org/eclipse/virgo/util/osgi/manifest/parse/standard/StandardHeaderLexer.java
@@ -31,7 +31,7 @@ package org.eclipse.virgo.util.osgi.manifest.parse.standard;
* <li>alphanum ::= alpha | digit
- * <li>token ::= ( alphanum | _ | - )+
+ * <li>token ::= ( alphanum | _ | - | .)+
* <li>number ::= digit+
@@ -307,9 +307,50 @@ public class StandardHeaderLexer {
}
+ private void processDot() {
+ if (lastEmittedToken != null && lastEmittedToken.getKind() == HeaderTokenKind.SEMICOLON) {
- private void processDot() {
+ if (state == UNKNOWN) {
+
+ processDotOrigin();
+
+ } else if (state == DIGITS || state == ALPHABETIC || state == ALPHANUMERIC || state == TOKEN) {
+
+ state = TOKEN;
+
+ do {
+
+ // is ".*" ?
+
+ if (data[datapos + 1] == '*' && data[datapos] == '.') {
+
+ datapos++;
+
+ }
+
+ datapos++;
+
+ } while (isToken(data[datapos]));
+
+ } else {
+
+ assert state == QUOTEDSTRING;
+
+ emitToken(datapos);
+
+ state = UNKNOWN;
+
+ }
+ } else {
+
+ processDotOrigin();
+
+ }
+
+ }
+
+ private void processDotOrigin() {
emitToken(datapos); // emit what we have so far
@@ -817,6 +858,20 @@ public class StandardHeaderLexer {
}
+ if (state == TOKEN) {
+
+ if ((ch == '.' || ch == '*') && lastEmittedToken != null && lastEmittedToken.getKind() == HeaderTokenKind.SEMICOLON) {
+
+ if (extensionStart != null) {
+
+ return true;
+
+ }
+
+ }
+
+ }
+
return (lookup[ch] & IS_TOKEN) != 0;
}
diff --git a/org.eclipse.virgo.util.osgi/src/test/java/org/eclipse/virgo/util/osgi/manifest/parse/standard/StandardHeaderParserTests.java b/org.eclipse.virgo.util.osgi/src/test/java/org/eclipse/virgo/util/osgi/manifest/parse/standard/StandardHeaderParserTests.java
index 26a6072..a77b218 100644
--- a/org.eclipse.virgo.util.osgi/src/test/java/org/eclipse/virgo/util/osgi/manifest/parse/standard/StandardHeaderParserTests.java
+++ b/org.eclipse.virgo.util.osgi/src/test/java/org/eclipse/virgo/util/osgi/manifest/parse/standard/StandardHeaderParserTests.java
@@ -49,7 +49,29 @@ public class StandardHeaderParserTests extends TestCase {
private static final char aeDipthong = '\u00c6';
- public void testValidPackageAttributeName() throws Exception {
+ public void testPackageAttributeNameNastySplit() throws Exception {
+ String test = "a.split.pkg;nasty.split=\"split\"";
+ List<HeaderDeclaration> packageDeclarations = parseTestHeader(test);
+ assertNotNull(packageDeclarations);
+ assertEquals(1, packageDeclarations.size());
+
+ HeaderDeclaration decl = packageDeclarations.get(0);
+ assertEquals("a.split.pkg", decl.getNames().get(0));
+ assertEquals("split", decl.getAttributes().get("nasty.split"));
+ }
+
+ public void testPackageAttributeNameWithDotsAndUnderscores() throws Exception {
+ String test = "a.long.package.name;test.split_mixed_with.underscore=split";
+ List<HeaderDeclaration> packageDeclarations = parseTestHeader(test);
+ assertNotNull(packageDeclarations);
+ assertEquals(1, packageDeclarations.size());
+
+ HeaderDeclaration decl = packageDeclarations.get(0);
+ assertEquals("a.long.package.name", decl.getNames().get(0));
+ assertEquals("split", decl.getAttributes().get("test.split_mixed_with.underscore"));
+ }
+
+ public void testPackageAttributeNameWithUnderscore() throws Exception {
String test = "package;test_split=split";
List<HeaderDeclaration> packageDeclarations = parseTestHeader(test);
assertNotNull(packageDeclarations);
@@ -60,7 +82,7 @@ public class StandardHeaderParserTests extends TestCase {
assertEquals("split", decl.getAttributes().get("test_split"));
}
- public void testInvalidPackageAttributeName() throws Exception {
+ public void testPackageAttributeNameWithDot() throws Exception {
String test = "package;test.split=split";
List<HeaderDeclaration> packageDeclarations = parseTestHeader(test);
assertNotNull(packageDeclarations);