public static String getMessage(String key, Object p1) { return Common.getMessage(key, new Object[] {p1}); }
/** * Return the internal object representation of the property. This method * cannot return null. If there is no object available for the specified * property name, an exception is thrown. */ public BeanProp beanProp(String name) { BeanProp prop = (BeanProp)this.propByName.get(name); if (prop == null) { // Search using the dtd name String beanName = Common.convertName(name); prop = (BeanProp)this.propByName.get(beanName); if (prop == null) throw new IllegalArgumentException(Common. getMessage("BeanPropertyDoesntExist_msg", this.getClass().getName(), name)); } return prop; }
public boolean isLockWhenModified() { Boolean ret = (Boolean)this.getValue(LOCK_WHEN_MODIFIED); if (ret == null) ret = (Boolean)Common.defaultScalarValue(Common.TYPE_BOOLEAN); return ((java.lang.Boolean)ret).booleanValue(); }
private boolean checkVetoable(boolean raise) { if (Common.isVetoable(this.type) || Common.isBean(this.type)) return true; if (raise) { if (!Common.isBean(this.type)) { throw new Schema2BeansRuntimeException(Common. getMessage("PropertyDoesntSupportVeto_msg", this.beanName)); } } return false; }
/** * If the property is an indexed property, return all the values * as an array of its type. */ public Object[] getValues() { if (!Common.isArray(this.type)) throw new IllegalStateException(Common. getMessage("NotIndexedProperty_msg")); return this.getObjectArray(0); }
String constName; if (l.name != null) { name = Common.convertName(l.name); dtdName = l.getSchemaName(); namespace = l.getNamespace(); config.messageOut.println("buildProperties: property in "+e.getBeanName()+" has been renamed to "+name); constName = Common.constName(dtdName); if ("#PCDATA".equals(dtdName)) { config.messageOut.println(Common.getMessage("RenamedProperty_msg", baseName, name, e.getBeanName())); if (JavaUtil.isPrimitiveType(classType)) { classType = JavaUtil.toObjectType(classType); type = Common.wrapperToType(classType); if (type == Common.NONE) type = Common.TYPE_STRING; if (!Common.isBean(be.type) && config.isAttributesAsProperties()) { addAttrProps(bc, attrs, name, usedNames, int childGroupInstance = Common.widestInstance(groupInstance, l.getGroupInstance()); buildProperties(l.getFirstChild(), bc, nestedLevel+1,
throw new IllegalStateException(Common.getMessage("DTDObjectGraphIsNull_msg")); getMessage("CantCreateDirIsFile_msg", dir)); } else { if (!dir.exists()) { if (dir.mkdirs()) { if (!config.isQuiet()) config.messageOut.println(Common.getMessage("MSG_CreatedDirectory", dir)); // NOI18N } else if (suggestedJavaType != null) { e.setWrapperClass(suggestedJavaType); } else if (be != rootElement && Common.isScalar(be.type)) { e.setWrapperClass(Common.wrapperClass(be.type)); suggestedJavaType = e.getWrapperClass(); } else if (be != rootElement && !Common.isBean(be.type)) { e.setWrapperClass(be.typeToString()); suggestedJavaType = e.getWrapperClass(); int proposedType = Common.wrapperToType(suggestedJavaType); if (proposedType != Common.NONE) be.type = proposedType; String prefix; if (graphNode.getNamespace() != null) { prefix = Common.convertName(graphNode.getNamespace()); } else { prefix = UNIQUE_PREFIX; config.messageOut.println(Common.getMessage("MSG_SkippingGenerationDueToTime"));
/** * Get the bean using its unique identifier. This identifier is not * the indexed position of the element in the array but a unique id * associated to the DOMBinding object (see the BeanProp and DOMBinding * classes) */ public Bean propertyById(String name, int id) { BeanProp bp = this.beanProp(name); if (Common.isBean(bp.type)) { if (Common.isArray(bp.type)) return (BaseBean)bp.getValueById(id); else return (BaseBean)bp.getValue(0); } else throw new IllegalStateException(Common. getMessage("PropertyIsNotABean_msg", name)); }
throw new Schema2BeansException(Common.getMessage( "CurrentNodeHasNoBinding_msg", new Integer(node.hashCode()))); if (!Common.isArray(matchingProp.type)) { Iterator propIt = (Iterator) dupDtdNameIterators.get(eltName); if (Common.isBean(matchingProp.type)) bean = (BaseBean)newBinding.getBean(matchingProp); else DDLogFlags.NOTELT, DDFactory.typeToString(t) + " = " + Common.dumpHex(v));
String name; if (directChild) name = Common.convertName(attr.getName()); else name = Common.convertName(propertyName+"_"+attr.getName()); if (usedNames.containsKey(name)) { int uniqNum = 2; uniqNum++; attr.setName(name); config.messageOut.println(Common.getMessage("RenamedProperty_msg", baseName, name, propertyName)); javaType = "java.lang.String"; // NOI18N } else { type = Common.wrapperToType(javaType); if (type == Common.NONE) type = Common.TYPE_STRING; false, null, Common.constName(name), attr.getDefaultValue(), directChild, extraData, false)
if (Common.isBean(this.type)) { try { Constructor c = null; TraceLogger.error(e); throw new Schema2BeansRuntimeException(Common. getMessage("CantInstantiateBean_msg", e.getMessage()));
/** * Same as convertName, except the name that comes out will * be suitable as an instance variable (first letter is lowercase). */ public static String convertNameInstance(String name) { return convertName(name, false); }
keyVar = Common.convertNameInstance(dtdName); keyType = "String"; jw.comment("Did not figure out proper expression to find the key. This method may not work."); nameToFind = Common.convertName(selectorProp.dtdName); if (returnType == null) { if (selectorProp.getPropertyInterface() == null) methodName = "find"+nameToFind; if (!keyName.equals(".")) methodName = methodName+"By"+Common.convertName(keyName); String arguments; if (keyTypeInterface == null)
Object o1 = Common.getComparableObject(this.keyValue); for (int i=0; i<this.values.length; i++) { BaseBean bb = (BaseBean)(this.values[i]); if (bb != null) { Object o2 = Common. getComparableObject(bb.getValue(this.keyName)); if (this.keyValue != null) { ArrayList arr = new ArrayList(); Object o1 = Common.getComparableObject(this.keyValue); for (int i=0; i<this.values.length; i++) { if (this.values[i] != null) { Object o2 = Common.getComparableObject(this.values[i]);
if (declaredQNames.size() == 0) jw.cr(); String qNameName = "QNAME_"+Common.constName(localPart); while (declaredQNames.containsKey(qNameName)) qNameName = qNameName + "2";
/** * Returns the position of the indexed property element. * If the type of the property is a bean, use the == comparison, * else use the equals() method. * If the element is not found, return -1. */ public int indexOf(String name, Object value) throws Schema2BeansRuntimeException { BeanProp bp = this.beanProp(name); if (bp == null) throw new Schema2BeansRuntimeException(Common. getMessage("UnknownPropertyName_msg", name)); if (Common.isArray(bp.type)) { boolean isBean = Common.isBean(bp.type); int size = bp.size(); for (int i=0; i<size; i++) { Object obj = bp.getValue(i); if (isBean && (obj == value)) return i; else if (!isBean && (obj.equals(value))) return i; } } return -1; }
private void checkParams(int index, Object value, boolean add) { if (add) { if (value == null) throw new IllegalArgumentException(Common. getMessage("CannotAddNullValue_msg")); } else { if (!Common.isArray(this.type)) { if (index > 0) throw new IllegalArgumentException(Common. getMessage("InvalidIndexForTypeProperty_msg")); } else { if ((index < 0) || (index >= this.bindingsSize())) throw new IndexOutOfBoundsException(); } } }
/** * Convert a DTD name into a bean name: * * Any - or _ character is removed. The letter following - and _ * is changed to be upper-case. * If the user mixes upper-case and lower-case, the case is not * changed. * If the Word is entirely in upper-case, the word is changed to * lower-case (except the characters following - and _) * The first letter is always upper-case. */ public static String convertName(String name) { return convertName(name, true); }
for (int k=0; k<size; k++) { String v = bp.getAttributeValue(k, name); v = (String)Common.getComparableObject(v); v = (String)Common.getComparableObject(v);
void genAttribute(String name, AttrProp attr) { String constName = Common.constName(attr.getDtdName()); gen("this.createAttribute("); if (name != null) gen(name, ", "); gen("\"", attr.getDtdName(), "\", "); gen("\"", attr.getName(), "\", "); cr(); gentab(4); gencr(attr.typeAsString(), ","); gentab(4); String[] values = attr.getValues(); if (values.length > 0) { gencr("new String[] {"); for (int k=0; k<values.length; k++) { if (k>0) gencr(","); gentab(5); gen("\"", values[k], "\""); } cr(); gentab(4); gen("}, "); } else gen("null, "); String value = attr.getDefaultValue(); if (value != null) gen("\"", value, "\")"); else gen("null)"); eol(); }