/*
* 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.
*/
/**
* Conversion declaration.
*
* <p>
* A conversion declaration specifies how an XML type gets mapped
* to a Java type.
*
* @author
* Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
*/
super(loc);
}
protected BIConversion() {
}
/**
* Gets the {@link TypeUse} object that this conversion represents.
* <p>
* The returned {@link TypeUse} object is properly adapted.
*
* @param owner
* A {@link BIConversion} is always associated with one
* {@link XSSimpleType}, but that's not always available
* when a {@link BIConversion} is built. So we pass this
* as a parameter to this method.
*/
/** Name of the conversion declaration. */
/**
* Implementation that returns a statically-determined constant {@link TypeUse}.
*/
/**
* Always non-null.
*/
super(loc);
this.transducer = transducer;
}
return transducer;
}
}
/**
* User-specified <javaType> customization.
*
* and their default values are determined based on the
* owner of the token.
*/
/**
* If null, computed from {@link #type}.
* Sometimes this can be set instead of {@link #type}.
*/
super(loc);
this.parseMethod = parseMethod;
this.printMethod = printMethod;
this.inMemoryType = inMemoryType;
}
public User() {
}
/**
* Cache used by {@link #getTypeUse(XSSimpleType)} to improve the performance.
*/
return typeUse;
if(inMemoryType==null)
// XmlJavaType customization always converts between string and an user-defined type.
return typeUse;
}
/**
* generate the adapter class.
*/
int id = 1;
try {
} catch (JClassAlreadyExistsException e) {
// try another name in search for an unique name.
// this isn't too efficient, but we expect people to usually use
// a very small number of adapters.
id++;
}
}
// "new" indicates that the constructor of the target type
// will do the unmarshalling.
// RESULT: new <type>()
} else {
if(idx<0) {
// parseMethod specifies the static method of the target type
// which will do the unmarshalling.
// because of an error check at the constructor,
// we can safely assume that this cast works.
} else {
}
}
// UGLY: if this conversion is the system-driven conversion,
// check for null
}
if(idx<0) {
// printMethod specifies a method in the target type
// which performs the serialization.
// RESULT: <value>.<method>()
// check value is not null ... if(value == null) return null;
} else {
// RESULT: <className>.<method>(<value>)
if(this.printMethod==null) {
// HACK HACK HACK
inv = JExpr.direct(printMethod+"(("+findBaseConversion(owner).toLowerCase()+")("+t.fullName()+")value)");
} else
}
return adapter;
}
return method;
}
return "toString";
}
// this cast is necessary for conversion between primitive Java types
}
}
return "new";
}
"Float", "Double", "Byte", "Short", "Int", "Long", "Boolean"
};
}
// find the base simple type mapping.
continue; // user-defined type
for( String s : knownBases )
if(name.equalsIgnoreCase(s))
return s;
}
return null;
}
/** Name of the conversion declaration. */
}
return typeUse;
try {
a.hide(); // we assume this is given by the user
} catch (JClassAlreadyExistsException e) {
a = e.getExistingClass();
}
// TODO: it's not correct to say that it adapts from String,
// but OTOH I don't think we can compute that.
new CAdapter(a));
return typeUse;
}
}
}