<p>Only accept simpleTypes which are restrictions to either <code>xs:string</code> or <code>xs:integer</code>.
The former is generated by JAXB when the Java Enum uses String values, and the latter is used
for ordinal values.</p>

{@inheritDoc}
335106
@Override
    public boolean accept(final Node aNode) {

        // Only deal with Element nodes.
        if (aNode.getNodeType() != Node.ELEMENT_NODE) {
            return false;
        }

        // We should accept:
        //
        // 1) A simpleType Element
        // 2) An enumeration Element
        final Element theElement = (Element) aNode;

        final String localName = theElement.getLocalName();
        if (localName != null) {

            final String trimmed = localName.trim();
            return trimmed.equalsIgnoreCase("enumeration")
                    || trimmed.equalsIgnoreCase("simpleType");
        }

        /*
        <xs:simpleType name="foodPreference">
            <!-- ClassLocation JavaDocData insertion point -->

            <xs:restriction base="xs:string">

                <!-- FieldLocation or MethodLocation JavaDocData insertion point (within child) -->
                <xs:enumeration value="NONE"/>

                <!-- FieldLocation or MethodLocation JavaDocData insertion point (within child) -->
                <xs:enumeration value="LACTO_VEGETARIAN"/>

                <!-- FieldLocation or MethodLocation JavaDocData insertion point (within child) -->
                <xs:enumeration value="VEGAN"/>

            </xs:restriction>
        </xs:simpleType>
         */

        /*
  <xs:simpleType name="foodPreference">
    <xs:restriction base="xs:string">
      <xs:enumeration value="NONE"/>
      <xs:enumeration value="LACTO_VEGETARIAN"/>
      <xs:enumeration value="VEGAN"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="americanCoin">
    <xs:restriction base="xs:int">
      <xs:enumeration value="25"/>
      <xs:enumeration value="1"/>
      <xs:enumeration value="5"/>
      <xs:enumeration value="10"/>
    </xs:restriction>
  </xs:simpleType>
        */

        // All done.
        return false;
    }
563477
private void checkType(FieldType type, Field field) {
        Class<?> cls = field.getType();

        if (type == FieldType.OBJECT || type == FieldType.ENUM) {
            return;
        }

        String javaType = type.getJavaType();
        if (Integer.class.getSimpleName().equals(javaType)) {
            if (cls.getSimpleName().equals("int") || Integer.class.getSimpleName().equals(cls.getSimpleName())) {
                return;
            }
            throw new IllegalArgumentException(getMismatchTypeErroMessage(type, field));
        }
        if (!javaType.equalsIgnoreCase(cls.getSimpleName())) {
            throw new IllegalArgumentException(getMismatchTypeErroMessage(type, field));
        }
    }
9259
@Nullable
  public static PrimitiveNode convertPrimitiveDataToExpr(
      PrimitiveData primitiveData, SourceLocation location) {
    if (primitiveData instanceof StringData) {
      return new StringNode(primitiveData.stringValue(), QuoteStyle.SINGLE, location);
    } else if (primitiveData instanceof BooleanData) {
      return new BooleanNode(primitiveData.booleanValue(), location);
    } else if (primitiveData instanceof IntegerData) {
      // NOTE: We only support numbers in the range of JS [MIN_SAFE_INTEGER, MAX_SAFE_INTEGER]
      if (!IntegerNode.isInRange(primitiveData.longValue())) {
        return null;
      } else {
        return new IntegerNode(primitiveData.longValue(), location);
      }
    } else if (primitiveData instanceof FloatData) {
      return new FloatNode(primitiveData.floatValue(), location);
    } else if (primitiveData instanceof NullData) {
      return new NullNode(location);
    } else {
      throw new IllegalArgumentException();
    }
  }
98515
public static boolean isInteger(String string) {
    if (string == null) {
      return false;
    }

    try {
      Integer.parseInt(string);
    } catch (NumberFormatException e) {
      return false;
    }

    return true;
  }
363240
public final void annotationTypeElementDeclarations() throws RecognitionException {
		int annotationTypeElementDeclarations_StartIndex = input.index();

		try {
			if ( state.backtracking>0 && alreadyParsedRule(input, 73) ) { return; }

			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:647:5: ( ( annotationTypeElementDeclaration ) ( annotationTypeElementDeclaration )* )
			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:647:7: ( annotationTypeElementDeclaration ) ( annotationTypeElementDeclaration )*
			{
			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:647:7: ( annotationTypeElementDeclaration )
			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:647:8: annotationTypeElementDeclaration
			{
			pushFollow(FOLLOW_annotationTypeElementDeclaration_in_annotationTypeElementDeclarations2523);
			annotationTypeElementDeclaration();
			state._fsp--;
			if (state.failed) return;
			}

			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:647:42: ( annotationTypeElementDeclaration )*
			loop95:
			while (true) {
				int alt95=2;
				int LA95_0 = input.LA(1);
				if ( (LA95_0==ENUM||LA95_0==Identifier||LA95_0==58||LA95_0==63||LA95_0==65||LA95_0==67||(LA95_0 >= 71 && LA95_0 <= 72)||LA95_0==77||LA95_0==83||LA95_0==85||(LA95_0 >= 92 && LA95_0 <= 94)||LA95_0==96||(LA95_0 >= 100 && LA95_0 <= 102)||(LA95_0 >= 105 && LA95_0 <= 107)||LA95_0==110||LA95_0==114||LA95_0==119) ) {
					alt95=1;
				}

				switch (alt95) {
				case 1 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:647:43: annotationTypeElementDeclaration
					{
					pushFollow(FOLLOW_annotationTypeElementDeclaration_in_annotationTypeElementDeclarations2527);
					annotationTypeElementDeclaration();
					state._fsp--;
					if (state.failed) return;
					}
					break;

				default :
					break loop95;
				}
			}

			}

		}
		catch (RecognitionException re) {
			reportError(re);
			recover(input,re);
		}
		finally {
			// do for sure before leaving
			if ( state.backtracking>0 ) { memoize(input, 73, annotationTypeElementDeclarations_StartIndex); }

		}
	}
31508
private String genericTypeAsString(GenericsType genericsType) {
        StringBuilder ret = new StringBuilder(genericsType.getName());
        if (genericsType.getUpperBounds() != null) {
            ret.append(" extends ");
            for (int i = 0; i < genericsType.getUpperBounds().length; i++) {
                ClassNode classNode = genericsType.getUpperBounds()[i];
                if (classNode.equals(this)) {
                    ret.append(classNode.getName());
                } else {
                    ret.append(classNode.toString(false));
                }
                if (i + 1 < genericsType.getUpperBounds().length) ret.append(" & ");
            }
        } else if (genericsType.getLowerBound() !=null) {
            ClassNode classNode = genericsType.getLowerBound();
            if (classNode.equals(this)) {
                ret.append(" super ").append(classNode.getName());
            } else {
                ret.append(" super ").append(classNode);
            }
        }
        return ret.toString();
    }
1149774
private static void validateTypeStr(String typeStr) {
    if (typeStr.contains("[") || typeStr.contains("]")) {
      throw new IllegalArgumentException(
          String.format(
              "Cannot convert array types (%s), please build them using getType()", typeStr));
    }
    if (typeStr.contains("<") || typeStr.contains(">")) {
      throw new IllegalArgumentException(
          String.format(
              "Cannot convert generic types (%s), please build them using getType()", typeStr));
    }
  }
1353738
private Object toEnum(ParameterType parameterType, String enumTextValue, String paramName, boolean hardFailEnumDeserialisation) {
        try {
            return EnumUtils.readEnum(parameterType.getImplementationClass(), enumTextValue, hardFailEnumDeserialisation);
        } catch (Exception e) {
            throw XMLTranscriptionInput.exceptionDuringDeserialisation(parameterType, paramName, e, false);
        }
    }
846384
@Override
	protected R parseValueFromString(String s)
	{
		Class<R> range = this.getRange();
		R value = null;
		try
		{
			if (range.equals(double.class))
			{
				value= (R) Double.valueOf(s);
			}
			else if (range.equals(float.class))
			{
				value=  (R) Float.valueOf(s);
			}
			else if (range.equals(int.class))
			{
				value= (R) Integer.valueOf(s);
			}
			else if (range.equals(Boolean.class))
			{
				value= (R) Boolean.valueOf(s);
			}
		}

		catch (NumberFormatException e)

		{
			throw new IllegalBioPAXArgumentException(
					"Failed to convert literal " + s +
					" to " + range.getSimpleName()
					+ " for " + property, e);
		}
		return value;
	}
692843
public static boolean isJavaLangType(String s) {
		return getJavaDefaultTypes().contains(s) && Character.isUpperCase(s.charAt(0));
	}
815047
static <T extends Enum<T>> T getEnumFromString(Class<T> c, String string) throws
            XmlPullParserException {
        if (c != null && string != null) {
            try {
                T t = Enum.valueOf(c, string.trim().toUpperCase());
                return t;
            } catch (IllegalArgumentException e) {
                throw new XmlPullParserException("Invalid value for " + c.getSimpleName());
            }
        } else {
            throw new XmlPullParserException("Null class or string");
        }
    }
138604
public final Object convert(Class<?> type, String s) throws ParseException {
		// mysql type: varchar, char, enum, set, text, tinytext, mediumtext, longtext
		if (type == String.class) {
			return ("".equals(s) ? null : s);	// 用户在表单域中没有输入内容时将提交过来 "", 因为没有输入,所以要转成 null.
		}
		s = s.trim();
		if ("".equals(s)) {	// 前面的 String跳过以后,所有的空字符串全都转成 null,  这是合理的
			return null;
		}
		// 以上两种情况无需转换,直接返回, 注意, 本方法不接受null为 s 参数(经测试永远不可能传来null, 因为无输入传来的也是"")
		//String.class提前处理
		
		// --------
		IConverter<?> converter = converterMap.get(type);
		if (converter != null) {
			return converter.convert(s);
		}
		if (JFinal.me().getConstants().getDevMode()) {
			throw new RuntimeException("Please add code in " + TypeConverter.class  + ". The type can't be converted: " + type.getName());
		} else {
			throw new RuntimeException(type.getName() + " can not be converted, please use other type of attributes in your model!");
		}
	}
642596
@Override
    public String execute(EditXmlInputs inputs) throws Exception {
        Document doc = XmlUtils.createDocument(inputs.getXml(), inputs.getFilePath(), inputs.getParsingFeatures());
        NodeList nodeList = XmlUtils.readNode(doc, inputs.getXpath1(), XmlUtils.getNamespaceContext(inputs.getXml(), inputs.getFilePath()));
        Node childNode = null;
        Node node;
        Node parentNode;
        // create new Node to insert
        if (Constants.Inputs.TYPE_ELEM.equals(inputs.getType())) {
            childNode = XmlUtils.stringToNode(inputs.getValue(), doc.getXmlEncoding(), inputs.getParsingFeatures());
        }

        for (int i = 0; i < nodeList.getLength(); i++) {
            node = nodeList.item(i);
            if (Constants.Inputs.TYPE_ELEM.equals(inputs.getType())) {
                //check if provided xpath doesn't contain root node
                if (node != doc.getDocumentElement()) {
                    childNode = doc.importNode(childNode, true);
                    parentNode = node.getParentNode();
                    parentNode.insertBefore(childNode, node);
                }
            } else if (Constants.Inputs.TYPE_TEXT.equals(inputs.getType())) {
                node.setTextContent(inputs.getValue() + node.getTextContent());
            } else if (Constants.Inputs.TYPE_ATTR.equals(inputs.getType())) {
                ((Element) node).setAttribute(inputs.getName(), inputs.getValue());
            }
        }
        return DocumentUtils.documentToString(doc);
    }
1065282
static Class<?> getElementTypeFromEnumSet(Object enumSet)
    {
        if(__elementTypeFromEnumSet == null)
        {
            throw new RuntimeException("Could not access (reflection) the private " +
                    "field *elementType* (enumClass) from: class java.util.EnumSet");
        }
        
        try
        {
            return (Class<?>)__elementTypeFromEnumSet.get(enumSet);
        }
        catch (IllegalArgumentException e)
        {
            throw new RuntimeException(e);
        }
        catch (IllegalAccessException e)
        {
            throw new RuntimeException(e);
        }
    }
1037232
public final void primitiveType() throws RecognitionException {
		try {
			// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:526:5: ( boolean_key | char_key | byte_key | short_key | int_key | long_key | float_key | double_key )
			int alt55=8;
			int LA55_0 = input.LA(1);
			if ( (LA55_0==ID) && ((((helper.validateIdentifierKey(DroolsSoftKeywords.SHORT)))||((helper.validateIdentifierKey(DroolsSoftKeywords.LONG)))||((helper.validateIdentifierKey(DroolsSoftKeywords.BOOLEAN)))||((helper.validateIdentifierKey(DroolsSoftKeywords.BYTE)))||((helper.validateIdentifierKey(DroolsSoftKeywords.FLOAT)))||((helper.validateIdentifierKey(DroolsSoftKeywords.DOUBLE)))||((helper.validateIdentifierKey(DroolsSoftKeywords.INT)))||((helper.validateIdentifierKey(DroolsSoftKeywords.CHAR)))))) {
				int LA55_1 = input.LA(2);
				if ( (((helper.validateIdentifierKey(DroolsSoftKeywords.BOOLEAN)))) ) {
					alt55=1;
				}
				else if ( (((helper.validateIdentifierKey(DroolsSoftKeywords.CHAR)))) ) {
					alt55=2;
				}
				else if ( (((helper.validateIdentifierKey(DroolsSoftKeywords.BYTE)))) ) {
					alt55=3;
				}
				else if ( (((helper.validateIdentifierKey(DroolsSoftKeywords.SHORT)))) ) {
					alt55=4;
				}
				else if ( (((helper.validateIdentifierKey(DroolsSoftKeywords.INT)))) ) {
					alt55=5;
				}
				else if ( (((helper.validateIdentifierKey(DroolsSoftKeywords.LONG)))) ) {
					alt55=6;
				}
				else if ( (((helper.validateIdentifierKey(DroolsSoftKeywords.FLOAT)))) ) {
					alt55=7;
				}
				else if ( (((helper.validateIdentifierKey(DroolsSoftKeywords.DOUBLE)))) ) {
					alt55=8;
				}

				else {
					if (state.backtracking>0) {state.failed=true; return;}
					int nvaeMark = input.mark();
					try {
						input.consume();
						NoViableAltException nvae =
							new NoViableAltException("", 55, 1, input);
						throw nvae;
					} finally {
						input.rewind(nvaeMark);
					}
				}

			}

			switch (alt55) {
				case 1 :
					// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:526:9: boolean_key
					{
					pushFollow(FOLLOW_boolean_key_in_primitiveType2643);
					boolean_key();
					state._fsp--;
					if (state.failed) return;
					}
					break;
				case 2 :
					// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:527:7: char_key
					{
					pushFollow(FOLLOW_char_key_in_primitiveType2651);
					char_key();
					state._fsp--;
					if (state.failed) return;
					}
					break;
				case 3 :
					// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:528:7: byte_key
					{
					pushFollow(FOLLOW_byte_key_in_primitiveType2659);
					byte_key();
					state._fsp--;
					if (state.failed) return;
					}
					break;
				case 4 :
					// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:529:7: short_key
					{
					pushFollow(FOLLOW_short_key_in_primitiveType2667);
					short_key();
					state._fsp--;
					if (state.failed) return;
					}
					break;
				case 5 :
					// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:530:7: int_key
					{
					pushFollow(FOLLOW_int_key_in_primitiveType2675);
					int_key();
					state._fsp--;
					if (state.failed) return;
					}
					break;
				case 6 :
					// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:531:7: long_key
					{
					pushFollow(FOLLOW_long_key_in_primitiveType2683);
					long_key();
					state._fsp--;
					if (state.failed) return;
					}
					break;
				case 7 :
					// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:532:7: float_key
					{
					pushFollow(FOLLOW_float_key_in_primitiveType2691);
					float_key();
					state._fsp--;
					if (state.failed) return;
					}
					break;
				case 8 :
					// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:533:7: double_key
					{
					pushFollow(FOLLOW_double_key_in_primitiveType2699);
					double_key();
					state._fsp--;
					if (state.failed) return;
					}
					break;

			}
		}

		catch (RecognitionException re) {
		    throw re;
		}

		finally {
			// do for sure before leaving
		}
	}
1196450
protected void checkXmlSpaceAttr(int type, WordResolver enumValues)
        throws XMLStreamException
    {
        boolean ok = (type == DTDAttribute.TYPE_ENUMERATED);
        if (ok) {
            switch (enumValues.size()) {
            case 1:
                ok = (enumValues.find("preserve") != null)
                    || (enumValues.find("default") != null);
                break;
            case 2:
                ok = (enumValues.find("preserve") != null)
                    && (enumValues.find("default") != null);
                break;
            default:
                ok = false;
            }
        }
        
        if (!ok) {
            _reportVCViolation(ErrorConsts.ERR_DTD_XML_SPACE);
        }
    }
653236
static Class<?> getElementTypeFromEnumSet(Object enumSet)
    {
        if (__elementTypeFromEnumSet == null)
        {
            throw new RuntimeException(
                    "Could not access (reflection) the private "
                            + "field *elementType* (enumClass) from: class java.util.EnumSet");
        }

        try
        {
            return (Class<?>) __elementTypeFromEnumSet.get(enumSet);
        }
        catch (Exception e)
        {
            throw new RuntimeException(e);
        }
    }