Author: scabanovich
Date: 2011-02-23 17:37:51 -0500 (Wed, 23 Feb 2011)
New Revision: 29291
Added:
branches/jbosstools-3.2.x/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/constraint/impl/XAttributeConstraintNmtoken.java
Modified:
branches/jbosstools-3.2.x/common/plugins/org.jboss.tools.common.model/plugin.xml
branches/jbosstools-3.2.x/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/plugin/ModelMessages.java
branches/jbosstools-3.2.x/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/plugin/messages.properties
Log:
JBIDE-8443
https://issues.jboss.org/browse/JBIDE-8443
Modified:
branches/jbosstools-3.2.x/common/plugins/org.jboss.tools.common.model/plugin.xml
===================================================================
---
branches/jbosstools-3.2.x/common/plugins/org.jboss.tools.common.model/plugin.xml 2011-02-23
22:14:46 UTC (rev 29290)
+++
branches/jbosstools-3.2.x/common/plugins/org.jboss.tools.common.model/plugin.xml 2011-02-23
22:37:51 UTC (rev 29291)
@@ -339,6 +339,8 @@
class="org.jboss.tools.common.meta.constraint.impl.XAttributeConstraintInt"/>
<xclass
id="org.jboss.tools.common.meta.constraint.impl.XAttributeConstraintJavaName"
class="org.jboss.tools.common.meta.constraint.impl.XAttributeConstraintJavaName"/>
+ <xclass
id="org.jboss.tools.common.meta.constraint.impl.XAttributeConstraintNmtoken"
+ class="org.jboss.tools.common.meta.constraint.impl.XAttributeConstraintNmtoken"/>
<xclass
id="org.jboss.tools.common.meta.constraint.impl.XAttributeConstraintJavaNameOrEmpty"
class="org.jboss.tools.common.meta.constraint.impl.XAttributeConstraintJavaNameOrEmpty"/>
<xclass
id="org.jboss.tools.common.meta.constraint.impl.XAttributeConstraintList"
Added:
branches/jbosstools-3.2.x/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/constraint/impl/XAttributeConstraintNmtoken.java
===================================================================
---
branches/jbosstools-3.2.x/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/constraint/impl/XAttributeConstraintNmtoken.java
(rev 0)
+++
branches/jbosstools-3.2.x/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/constraint/impl/XAttributeConstraintNmtoken.java 2011-02-23
22:37:51 UTC (rev 29291)
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.meta.constraint.impl;
+
+import org.jboss.tools.common.model.XModelObjectConstants;
+import org.jboss.tools.common.model.plugin.ModelMessages;
+
+public class XAttributeConstraintNmtoken extends XAttributeConstraintProperties {
+
+ char[][] intervals = {
+ {':', ':'}, {'A', 'Z'}, {'_',
'_'}, {'a', 'z'}, {0xC0, 0xD6},
+ {0xD8, 0xF6}, {0xF8 , 0x2FF}, {0x370, 0x37D}, {0x37F, 0x1FFF},
+ {0x200C, 0x200D}, {0x2070, 0x218F}, {0x2C00, 0x2FEF}, {0x3001, 0xD7FF},
+ {0xF900, 0xFDCF}, {0xFDF0, 0xFFFD}, // {0x10000, 0xEFFFF},
+ {'-', '-'}, {'.', '.'}, {'0', '9'},
+ {0xB7, 0xB7}, {0x0300, 0x036F}, {0x203F, 0x2040},
+ };
+
+ public XAttributeConstraintNmtoken() {}
+
+ public boolean accepts(String value) {
+ if(value == null) return false;
+ if(value.length() == 0) return true;
+ for (int i = 1; i < value.length(); i++) {
+ char ch = value.charAt(i);
+ boolean ok = false;
+ for (int k = 0; k < intervals.length; k++) {
+ if(ch >= intervals[k][0] && ch <= intervals[k][1]) {
+ ok = true;
+ break;
+ }
+ }
+ if(!ok) return false;
+ }
+ return true;
+ }
+
+ public String getError(String value) {
+ return (value.length() == 0) ? (isRequired() ? ModelMessages.CONSTRAINT_NONEMPTY
: null) :
+ accepts(value) ? null :
+ ModelMessages.CONSTRAINT_NMTOKEN;
+ }
+
+ boolean isRequired() {
+ return attribute != null &&
"always".equals(attribute.getProperty("save")); //$NON-NLS-1$
//$NON-NLS-2$
+ }
+
+ public String getCorrectedValue(String value) {
+ if(value == null || value.length() == 0) return null;
+
if(XModelObjectConstants.TRUE.equals(getProperties().getProperty("acceptIncorrect")))
return value; //$NON-NLS-1$
+ //
+ return value;
+ }
+
+
+}
+
Property changes on:
branches/jbosstools-3.2.x/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/constraint/impl/XAttributeConstraintNmtoken.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
branches/jbosstools-3.2.x/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/plugin/ModelMessages.java
===================================================================
---
branches/jbosstools-3.2.x/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/plugin/ModelMessages.java 2011-02-23
22:14:46 UTC (rev 29290)
+++
branches/jbosstools-3.2.x/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/plugin/ModelMessages.java 2011-02-23
22:37:51 UTC (rev 29291)
@@ -18,6 +18,7 @@
public static String CONSTRAINT_NONEMPTY;
public static String CONSTRAINT_NO_JAVA_KEYWORD;
public static String CONSTRAINT_JAVA_NAME;
+ public static String CONSTRAINT_NMTOKEN;
public static String CONSTRAINT_INTEGER_OR_LIST;
public static String CONSTRAINT_RED_HAT_TEMPLATE_NAME;
public static String CONSTRAINT_XML_NAME;
Modified:
branches/jbosstools-3.2.x/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/plugin/messages.properties
===================================================================
---
branches/jbosstools-3.2.x/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/plugin/messages.properties 2011-02-23
22:14:46 UTC (rev 29290)
+++
branches/jbosstools-3.2.x/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/plugin/messages.properties 2011-02-23
22:37:51 UTC (rev 29291)
@@ -7,6 +7,7 @@
CONSTRAINT_NONEMPTY = cannot be empty
CONSTRAINT_NO_JAVA_KEYWORD = is a Java keyword
CONSTRAINT_JAVA_NAME = is not a Java name
+CONSTRAINT_NMTOKEN = is not a valid NMToken
CONSTRAINT_INTEGER_OR_LIST = must be an integer or be selected from the list
CONSTRAINT_RED_HAT_TEMPLATE_NAME = is not an Red Hat project template name
CONSTRAINT_XML_NAME = is not xml name