Author: scabanovich
Date: 2010-02-02 09:17:05 -0500 (Tue, 02 Feb 2010)
New Revision: 20075
Modified:
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/AuxEntityRecognizer.java
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/SeamPagesEntityRecognizer.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5781
Modified:
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/AuxEntityRecognizer.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/AuxEntityRecognizer.java 2010-02-02
14:15:58 UTC (rev 20074)
+++
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/AuxEntityRecognizer.java 2010-02-02
14:17:05 UTC (rev 20075)
@@ -16,7 +16,11 @@
public AuxEntityRecognizer() {}
- public String getEntityName(String ext, String body) {
+ public String getEntityName(EntityRecognizerContext context) {
+ return getEntityName(context.getExtension(), context.getBody());
+ }
+
+ String getEntityName(String ext, String body) {
if (body == null) return null;
return SeamPagesFileLoader.AUXILIARY_FILE_EXTENSION.equals(ext) ?
"FileAnyAuxiliary" : null;
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/SeamPagesEntityRecognizer.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/SeamPagesEntityRecognizer.java 2010-02-02
14:15:58 UTC (rev 20074)
+++
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/SeamPagesEntityRecognizer.java 2010-02-02
14:17:05 UTC (rev 20075)
@@ -13,6 +13,8 @@
import java.io.IOException;
import org.jboss.tools.common.model.loaders.EntityRecognizer;
+import org.jboss.tools.common.model.loaders.EntityRecognizerContext;
+import org.jboss.tools.common.model.loaders.XMLRecognizerContext;
import org.jboss.tools.common.xml.XMLEntityResolver;
import org.jboss.tools.seam.pages.xml.SeamPagesXMLPlugin;
@@ -29,25 +31,34 @@
public SeamPagesEntityRecognizer() {}
- public String getEntityName(String ext, String body) {
+ public String getEntityName(EntityRecognizerContext context) {
+ String body = context.getBody();
if(body == null) return null;
- Parser p = new Parser(body);
- if(!p.recognized) {
- return null;
- } else if(p.is12) {
- return p.isSingle ? ENT_FILE_SEAM_PAGE_12 : ENT_FILE_SEAM_PAGES_12;
- } else if(p.is20) {
- return p.isSingle ? ENT_FILE_SEAM_PAGE_20 : ENT_FILE_SEAM_PAGES_20;
- } else if(p.is21) {
- return p.isSingle ? ENT_FILE_SEAM_PAGE_21 : ENT_FILE_SEAM_PAGES_21;
- } else {
- return p.isSingle ? ENT_FILE_SEAM_PAGE_22 : ENT_FILE_SEAM_PAGES_22;
- }
+ XMLRecognizerContext xml = context.getXMLContext();
+ if(xml.isDTD()) {
+ String publicId = xml.getPublicId();
+ String name = xml.getRootName();
+ if(PUBLIC_ID_12.equals(publicId)) {
+ if("page".equals(name)) return ENT_FILE_SEAM_PAGE_12;
+ if("pages".equals(name)) return ENT_FILE_SEAM_PAGES_12;
+ }
+ return null;
+ } else {
+ Parser p = new Parser(body);
+ if(!p.recognized) {
+ return null;
+ } else if(p.is20) {
+ return p.isSingle ? ENT_FILE_SEAM_PAGE_20 : ENT_FILE_SEAM_PAGES_20;
+ } else if(p.is21) {
+ return p.isSingle ? ENT_FILE_SEAM_PAGE_21 : ENT_FILE_SEAM_PAGES_21;
+ } else {
+ return p.isSingle ? ENT_FILE_SEAM_PAGE_22 : ENT_FILE_SEAM_PAGES_22;
+ }
+ }
}
class Parser {
boolean recognized = false;
- boolean is12 = false;
boolean isSingle = false;
boolean is20 = false;
boolean is21 = false;
@@ -59,18 +70,14 @@
if(i2 < 0) {
isSingle = true;
}
- if(body.indexOf(PUBLIC_ID_12) >= 0) {
- is12 = true;
- } else {
- int j = body.indexOf(">", i); //$NON-NLS-1$
- if(j < 0) return;
- String s = body.substring(i, j);
-
if(s.indexOf("\"http://jboss.com/products/seam/pages\"")
< 0) { //$NON-NLS-1$
- return;
- }
- if(s.indexOf("2.0") >= 0) is20 = true;
- if(s.indexOf("2.1") >= 0) is21 = true;
- }
+ int j = body.indexOf(">", i); //$NON-NLS-1$
+ if(j < 0) return;
+ String s = body.substring(i, j);
+
if(s.indexOf("\"http://jboss.com/products/seam/pages\"")
< 0) { //$NON-NLS-1$
+ return;
+ }
+ if(s.indexOf("2.0") >= 0) is20 = true;
+ if(s.indexOf("2.1") >= 0) is21 = true;
recognized = true;
}
}