/** * Encodes a String into standard java attribute name convention. The following steps are performed * on the name: * 1. First character is set to lower case. * 2. Illegal characters like '-' and whitespace are removed. * 3. If attributetype is a Collection a 's'-character is appended. * * @param type the type of attribute. * @param name the original attribut name. * @return the attribute name complying with standard java attribute name convention. * @throws IllegalNameException when attribute name is a reserved keyword in java. */ public static String encodeAttributeName(JType type, String name) throws IllegalNameException { String result = encodeAttributeName(name); if(type != null && Collection.class.isAssignableFrom(type.getClass())) { result += "s"; } return result; }
/** * Encodes a String into standard java attribute name convention. The following steps are performed * on the name: * 1. First character is set to lower case. * 2. Illegal characters like '-' and whitespace are removed. * 3. If attributetype is a Collection a 's'-character is appended. * * @param type the type of attribute. * @param name the original attribut name. * @return the attribute name complying with standard java attribute name convention. * @throws IllegalNameException when attribute name is a reserved keyword in java. */ public static String encodeAttributeName(JType type, String name) throws IllegalNameException { String result = encodeAttributeName(name); if(type != null && Collection.class.isAssignableFrom(type.getClass())) { result += "s"; } return result; }
/** * Encodes a String into standard java attribute name convention. The following steps are performed * on the name: * 1. First character is set to lower case. * 2. Illegal characters like '-' and whitespace are removed. * 3. If attributetype is a Collection a 's'-character is appended. * * @param type the type of attribute. * @param name the original attribut name. * @return the attribute name complying with standard java attribute name convention. * @throws IllegalNameException when attribute name is a reserved keyword in java. */ public static String encodeAttributeName(JType type, String name) throws IllegalNameException { String result = encodeAttributeName(name); if(type != null && Collection.class.isAssignableFrom(type.getClass())) { result += "s"; } return result; }
/** * Encodes a String into standard java attribute name convention. The following steps are performed * on the name: * 1. First character is set to lower case. * 2. Illegal characters like '-' and whitespace are removed. * 3. If attributetype is a Collection a 's'-character is appended. * * @param type the type of attribute. * @param name the original attribut name. * @return the attribute name complying with standard java attribute name convention. * @throws IllegalNameException when attribute name is a reserved keyword in java. */ public static String encodeAttributeName(JType type, String name) throws IllegalNameException { String result = encodeAttributeName(name); if(type != null && Collection.class.isAssignableFrom(type.getClass())) { result += "s"; } return result; }
String packageName = rootClass.getPackageName(); String className = rootClass.getClassName(); String classId = EDIUtils.encodeAttributeName(null, rootClass.getClassName());
/** * Creates a {@link org.milyn.javabean.pojogen.JNamedType} given a {@link org.milyn.edisax.model.internal.ValueNode}. * When {@link org.milyn.edisax.model.internal.ValueNode} contains no type information String-type is used as default. * The new {@link org.milyn.javabean.pojogen.JNamedType} is inserted into parent and the xmltag- and * typeParameters-value is inserted into classModel. * @param valueNode the {@link org.milyn.edisax.model.internal.ValueNode} to process. * @param parent the {@link org.milyn.javabean.pojogen.JClass} 'owning' the valueNode. * @param delimiterType Node delimiter type. * @throws IllegalNameException when name found in a xmltag-attribute is a java keyword. */ private JNamedType createAndAddSimpleType(ValueNode valueNode, BindingConfig parent, DelimiterType delimiterType) throws IllegalNameException { JType jtype; JNamedType childToParentProperty; if (valueNode.getDataType() != null && !valueNode.getDataType().equals("")) { jtype = new JType(valueNode.getTypeClass()); } else { // Default type when no specific type is given. jtype = new JType(String.class); } String propertyName = EDIUtils.encodeAttributeName(jtype, valueNode.getJavaName()); childToParentProperty = new JNamedType(jtype, propertyName); JClass parentBeanClass = parent.getBeanClass(); if(!parentBeanClass.isFinalized() && !parentBeanClass.hasProperty(propertyName) && model.isClassCreator(parentBeanClass)) { parentBeanClass.addBeanProperty(childToParentProperty); getWriteMethod(parent).writeValue(childToParentProperty, valueNode, delimiterType); } parent.getValueBindings().add(new ValueNodeInfo(childToParentProperty, getCurrentNodePath(), valueNode)); return childToParentProperty; }
String propertyName = EDIUtils.encodeAttributeName(jtype, mappingNode.getJavaName()); JNamedType childProperty = new JNamedType(jtype, propertyName);