/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* Property customization.
*
* This customization turns an arbitrary schema component
* into a Java property (some restrictions apply.)
*
* <p>
* All the getter methods (such as <code>getBaseType</code> or
* <code>getBindStyle</code>) honors the delegation chain of
* property customization specified in the spec. Namely,
* if two property customizations are attached to an attribute
* use and an attribute decl, then anything unspecified in the
* attribute use defaults to attribute decl.
*
* <p>
* Property customizations are acknowledged
* (1) when they are actually used, and
* (2) when they are given at the component, which is mapped to a class.
* (so-called "point of declaration" customization)
*
* @author
* Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
*/
// can be null
// can be null
// can be null
// TODO: report 'unsupported' error if this is true
private boolean generateFailFastSetterMethod = false;
super(loc);
this.collectionType = collectionType;
this.isConstantProperty = isConst;
this.optionalProperty = optionalProperty;
this.generateElementProperty = genElemProp;
}
protected BIProperty() {}
return super.getChildren();
else
}
}
/**
* Returns the customized property name.
*
* This method honors the "enableJavaNamingConvention" customization
* and formats the property name accordingly if necessary.
*
* Thus the caller should <em>NOT</em> apply the XML-to-Java name
* conversion algorithm to the value returned from this method.
*
* @param forConstant
* If the property name is intended for a constant property name,
* set to true. This will change the result
*
* @return
* This method can return null if the customization doesn't
* specify the name.
*/
// apply XML->Java conversion
else
return name; // ... or don't change the value
}
else return null;
}
/**
* Gets the associated javadoc.
*
* @return
* null if none is specfieid.
*/
return javadoc;
}
// can be null
}
else return null;
}
// can be null
/**
* Gets the realization of this field.
* @return Always return non-null.
*/
return getDefault().getCollectionType();
}
// virtual property for @generateIsSetMethod
void setGenerateIsSetMethod(boolean b) {
}
return getDefault().getOptionalPropertyMode();
}
// null if delegated
/**
* If true, the property will automatically be a reference property.
* (Talk about confusing names!)
*/
return null;
}
// true, false, or null (which means the value should be inherited.)
/**
* Gets the inherited value of the "fixedAttrToConstantProperty" customization.
*
* <p>
* Note that returning true from this method doesn't necessarily mean
* that a property needs to be mapped to a constant property.
* It just means that it's mapped to a constant property
* <b>if an attribute use carries a fixed value.</b>
*
* <p>
* I don't like this semantics but that's what the spec implies.
*/
public boolean isConstantProperty() {
// globalBinding always has true or false in this property,
// so this can't happen
throw new AssertionError();
}
name = defaultName;
}
CValuePropertyInfo prop = wrapUp(new CValuePropertyInfo(name, source, getCustomizations(source), source.getLocator(), tu, typeName), source);
return prop;
}
boolean forConstant =
if(forConstant)
else
}
}
/**
*
*
* @param defaultName
* If the name is not customized, this name will be used
* as the default. Note that the name conversion <b>MUST</b>
* be applied before this method is called if necessary.
* @param source
* Source schema component from which a field is built.
*/
public CElementPropertyInfo createElementProperty(String defaultName, boolean forConstant, XSParticle source,
RawTypeSet types) {
// if this property is empty, don't acknowleedge the customization
// this allows pointless property customization to be reported as an error
name = defaultName;
new CElementPropertyInfo(
source);
return prop;
}
return createReferenceProperty(
false,
true,
true,
false,
true);
}
return createReferenceProperty(
false,
true,
false,
true,
true);
}
if (types == null) { // this is a special case where we need to generate content because potential subtypes would need to be able to override what's store inside
content = true;
} else {
// if this property is empty, don't acknowleedge the customization
// this allows pointless property customization to be reported as an error
}
name = defaultName;
name,
source);
}
return prop;
}
RawTypeSet types) {
boolean generateRef;
switch(types.canBeTypeRefs) {
case CAN_BE_TYPEREF:
case SHOULD_BE_TYPEREF:
// it's up to the use
Boolean b = generateElementProperty();
if(b==null) // follow XJC recommendation
else // use the value user gave us
generateRef = b;
break;
case MUST_BE_REFERENCE:
generateRef = true;
break;
default:
throw new AssertionError();
}
if(generateRef) {
} else {
}
}
/**
* Common finalization of {@link CPropertyInfo} for the create***Property methods.
*/
// decide the realization.
if(prop.isCollection()) {
} else {
if(prop.isOptionalPrimitive()) {
// the property type can be primitive type if we are to ignore absence
switch(opm) {
case PRIMITIVE:
r = frf.getRequiredUnboxed();
break;
case WRAPPER:
// force the wrapper type
break;
case ISSET:
r = frf.getSinglePrimitiveAccess();
break;
default:
throw new Error();
}
} else {
r = frf.getDefault();
}
}
// only isSet is allowed on a collection. these 3 modes aren't really symmetric.
// if the property is a primitive type, we need an explicit unset because
// we can't overload the meaning of set(null).
// if it's a collection, we need to be able to unset it so that we can distinguish
// null list and empty list.
}
prop.realization = r;
return prop;
}
}
CCustomizations c = null;
for (XSComponent s : src) {
CCustomizations r = getCustomizations(s);
if(c==null) c = r;
else c = CCustomizations.merge(c,r);
}
return c;
}
// customizations for an attribute use should include those defined in the local attribute.
// this is so that the schema like:
//
// <xs:attribute name="foo" type="xs:int">
// <xs:annotation><xs:appinfo>
// <hyperjaxb:... />
//
// would be picked up
else
}
// customizations for a particle should include those defined in the term unless it's global
// this is so that the schema like:
//
// <xs:sequence>
// <xs:element name="foo" type="xs:int">
// <xs:annotation><xs:appinfo>
// <hyperjaxb:... />
//
// would be picked up
}
}
public void markAsAcknowledged() {
if( isAcknowledged() ) return;
// mark the parent as well.
super.markAsAcknowledged();
}
private void constantPropertyErrorCheck() {
// run additional check on the isCOnstantProperty value.
// this value is not allowed if the schema component doesn't have
// a fixed value constraint.
//
// the setParent method associates a customization with the rest of
// XSOM object graph, so this is the earliest possible moment where
// we can test this.
getLocation(),
);
// set this value to null to avoid the same error to be reported more than once.
}
}
}
/**
* Function object that returns true if a component has
* a fixed value constraint.
*/
}
}
// we allow globalBindings to have isConstantProperty==true,
// so this method returns true to allow this.
return true;
}
};
/**
* Finds a BIProperty which this object should delegate to.
*
* @return
* always return non-null for normal BIProperties.
* If this object is contained in the BIGlobalBinding, then
* this method returns null to indicate that there's no more default.
*/
else return next;
}
while(c!=null) {
c = c.apply(defaultCustomizationFinder);
if(c!=null) {
}
}
// default to the global one
}
/**
* Finds a property customization that describes how the given
* component should be mapped to a property (if it's mapped to
* a property at all.)
*
* <p>
* Consider an attribute use that does NOT carry a property
* customization. This schema component is nonetheless considered
* to carry a (sort of) implicit property customization, whose values
* are defaulted.
*
* <p>
* This method can be think of the method that returns this implied
* property customization.
*
* <p>
* Note that this doesn't mean the given component needs to be
* mapped to a property. But if it does map to a property, it needs
* to follow this customization.
*
* I think this semantics is next to non-sense but I couldn't think
* of any other way to follow the spec.
*
* @param c
* A customization effective on this component will be returned.
* Can be null just to get the global customization.
* @return
* Always return non-null valid object.
*/
// look for a customization on this component
if( c!=null ) {
}
// if no such thing exists, defeault.
return getDefault(builder,c);
}
private final static XSFunction<XSComponent> defaultCustomizationFinder = new XSFunction<XSComponent>() {
}
}
// no more delegation
return null;
}
// delegates to the context schema object
// property customizations are not allowed on these components.
public XSComponent identityConstraint(XSIdentityConstraint x) { throw new IllegalStateException(); }
};
}
/** Name of this declaration. */
else
return null;
}
private static final class BaseTypeBean {
/**
* If there's a nested javaType customization, this field
* will keep that customization. Otherwise null.
*
* This customization, if present, is used to customize
* the simple type mapping at the point of reference.
*/
/**
* Java type name.
*/
}
}