📄 defaultmodelreader.java
字号:
(getPropertyDescriptor(name));
if (propertyInfo == null) {
throw new ObjectDescriptionException("Unable to load property " + name);
}
propertyInfo.setComments(new Comments(getOpenComment(), getCloseComment()));
propertyInfo.setPropertyType(PropertyType.ATTRIBUTE);
propertyInfo.setXmlName(attribName);
propertyInfo.setXmlHandler(handlerClass);
this.propertyList.add(propertyInfo);
}
/**
* Handles the constructor definition.
*
* @param tagName the tag name.
* @param parameterClass the parameter class.
*
* @throws ObjectDescriptionException if there is a problem with the object description.
*/
protected void handleConstructorDefinition(final String tagName, final String parameterClass)
throws ObjectDescriptionException {
final Class c = loadClass(parameterClass);
if (c == null) {
throw new ObjectDescriptionException("Failed to load class " + parameterClass);
}
final TypeInfo ti = new TypeInfo(tagName, c);
ti.setComments(new Comments(getOpenComment(), getCloseComment()));
this.constructorList.add (ti);
}
/**
* Handles the description of an element within an object definition.
*
* @param name the property name.
* @param element the element name.
*
* @throws ObjectDescriptionException if there is a problem with the object description.
*/
protected void handleElementDefinition(final String name, final String element)
throws ObjectDescriptionException {
final PropertyInfo propertyInfo = ModelBuilder.getInstance().createSimplePropertyInfo
(getPropertyDescriptor(name));
if (propertyInfo == null) {
throw new ObjectDescriptionException("Unable to load property " + name);
}
propertyInfo.setComments(new Comments(getOpenComment(), getCloseComment()));
propertyInfo.setPropertyType(PropertyType.ELEMENT);
propertyInfo.setXmlName(element);
propertyInfo.setXmlHandler(null);
this.propertyList.add(propertyInfo);
}
/**
* Handles a lookup definition.
*
* @param name the name.
* @param lookupKey the lookup key.
*
* @throws ObjectDescriptionException if there is a problem with the object description.
*/
protected void handleLookupDefinition(final String name, final String lookupKey)
throws ObjectDescriptionException {
final PropertyInfo propertyInfo = ModelBuilder.getInstance().createSimplePropertyInfo
(getPropertyDescriptor(name));
if (propertyInfo == null) {
throw new ObjectDescriptionException("Unable to load property " + name);
}
propertyInfo.setComments(new Comments(getOpenComment(), getCloseComment()));
propertyInfo.setPropertyType(PropertyType.LOOKUP);
propertyInfo.setXmlName(lookupKey);
propertyInfo.setXmlHandler(null);
this.propertyList.add(propertyInfo);
}
/**
* Returns a property descriptor for the named property, or <code>null</code> if there is
* no descriptor with the given name.
*
* @param propertyName the property name.
*
* @return a property descriptor.
*/
protected PropertyDescriptor getPropertyDescriptor(final String propertyName) {
final PropertyDescriptor[] pds = this.currentBeanInfo.getPropertyDescriptors();
for (int i = 0; i < pds.length; i++) {
if (pds[i].getName().equals(propertyName)) {
return pds[i];
}
}
return null;
}
/**
* Handles an ignored property.
*
* @param name the name.
*/
protected void handleIgnoredProperty(final String name) {
final IgnoredPropertyInfo propertyInfo = new IgnoredPropertyInfo(name);
propertyInfo.setComments(new Comments(getOpenComment(), getCloseComment()));
this.propertyList.add(propertyInfo);
}
/**
* Handles a manual mapping.
*
* @param className the class name.
* @param readHandler the read handler.
* @param writeHandler the write handler.
*
* @return A boolean.
*
* @throws ObjectDescriptionException if there is a problem with the object description.
*/
protected boolean handleManualMapping(final String className, final String readHandler, final String writeHandler)
throws ObjectDescriptionException {
final ManualMappingInfo manualMappingInfo =
new ManualMappingInfo(loadClass(className),
loadClass(readHandler), loadClass(writeHandler));
manualMappingInfo.setComments(new Comments(getOpenComment(), getCloseComment()));
manualMappingInfo.setSource(this.source);
this.model.getMappingModel().addManualMapping(manualMappingInfo);
return true;
}
/**
* Start a multiplex mapping.
*
* @param className the class name.
* @param typeAttr the type.
*/
protected void startMultiplexMapping(final String className, final String typeAttr) {
this.multiplexInfo = new MultiplexMappingInfo(loadClass(className), typeAttr);
this.multiplexInfo.setSource(this.source);
this.multiplexTypeInfos = new ArrayList();
}
/**
* Handles a multiplex mapping.
*
* @param typeName the type name.
* @param className the class name.
*
* @throws ObjectDescriptionException if there is a problem with the object description.
*/
protected void handleMultiplexMapping(final String typeName, final String className)
throws ObjectDescriptionException {
final TypeInfo info = new TypeInfo(typeName, loadClass(className));
info.setComments(new Comments(getOpenComment(), getCloseComment()));
this.multiplexTypeInfos.add (info);
}
/**
* Ends a multiplex mapping.
*
* @throws ObjectDescriptionException if there is a problem with the object description.
*/
protected void endMultiplexMapping() throws ObjectDescriptionException {
final TypeInfo[] typeInfos = (TypeInfo[]) this.multiplexTypeInfos.toArray(
new TypeInfo[this.multiplexTypeInfos.size()]
);
this.multiplexInfo.setComments(new Comments(getOpenComment(), getCloseComment()));
this.multiplexInfo.setChildClasses(typeInfos);
this.model.getMappingModel().addMultiplexMapping(this.multiplexInfo);
this.multiplexInfo = null;
}
/**
* Starts include handling.
*
* @param resource the URL.
*/
protected void startIncludeHandling(final URL resource) {
this.source = IOUtils.getInstance().createRelativeURL(resource, this.baseURL);
this.model.addSource(this.source);
this.model.addIncludeComment(
this.source, new Comments(getOpenComment(), getCloseComment())
);
}
/**
* Ends include handling.
*/
protected void endIncludeHandling() {
this.source = "";
}
/**
* Starts the root document.
*/
protected void startRootDocument() {
this.source = "";
}
/**
* Ends the root document.
*/
protected void endRootDocument() {
this.model.setModelComments(new Comments(getOpenComment(), getCloseComment()));
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -