Added: webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/helpers/AbstractUnmarshallerImpl.java URL: http://svn.apache.org/viewvc/webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/helpers/AbstractUnmarshallerImpl.java?view=auto&rev=494575 ============================================================================== --- webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/helpers/AbstractUnmarshallerImpl.java (added) +++ webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/helpers/AbstractUnmarshallerImpl.java Tue Jan 9 13:07:17 2007 @@ -0,0 +1,335 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package javax.xml.bind.helpers; + +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.Reader; + +import javax.xml.bind.JAXBElement; +import javax.xml.bind.JAXBException; +import javax.xml.bind.PropertyException; +import javax.xml.bind.UnmarshalException; +import javax.xml.bind.Unmarshaller; +import javax.xml.bind.ValidationEventHandler; +import javax.xml.bind.annotation.adapters.XmlAdapter; +import javax.xml.bind.attachment.AttachmentUnmarshaller; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; +import javax.xml.stream.XMLEventReader; +import javax.xml.stream.XMLStreamReader; +import javax.xml.transform.Source; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.sax.SAXSource; +import javax.xml.transform.stream.StreamSource; +import javax.xml.validation.Schema; + +import org.w3c.dom.Node; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.XMLReader; + + +/** <p>This is an abstract default implementation of an + * [EMAIL PROTECTED] javax.xml.bind.Unmarshaller}. Subclasses only need to implement + * [EMAIL PROTECTED] javax.xml.bind.Unmarshaller#getUnmarshallerHandler()}, + * [EMAIL PROTECTED] javax.xml.bind.Unmarshaller#unmarshal(org.w3c.dom.Node)}, and + * [EMAIL PROTECTED] #unmarshal(org.xml.sax.XMLReader, org.xml.sax.InputSource)}.</p> + * + * @author JSR-31 + * @since JAXB1.0 + */ +public abstract class AbstractUnmarshallerImpl implements Unmarshaller { + protected boolean validating; + private XMLReader xmlReader; + private static SAXParserFactory saxParserFactory; + private ValidationEventHandler validationEventHandler = DefaultValidationEventHandler.theInstance; + + static { + saxParserFactory = SAXParserFactory.newInstance(); + saxParserFactory.setNamespaceAware(true); + saxParserFactory.setValidating(false); + } + + /** <p>Creates a new instance of AbstractUnmarshallerImpl.</p> + */ + public AbstractUnmarshallerImpl() { + // Does nothing. + } + + /** <p>Creates a configured [EMAIL PROTECTED] org.xml.sax.XMLReader}. + * Unmarshaller is not re-entrant, so we will use a single instance + * of [EMAIL PROTECTED] org.xml.sax.XMLReader}.</p> + * @throws JAXBException Encapsulates a + * [EMAIL PROTECTED] javax.xml.parsers.ParserConfigurationException} + */ + protected XMLReader getXMLReader() throws JAXBException { + if (xmlReader == null) { + try { + SAXParser sp = saxParserFactory.newSAXParser(); + xmlReader = sp.getXMLReader(); + } catch (ParserConfigurationException e) { + throw new JAXBException("Failed to create a JAXP compliant SAX parser.", e); + } catch (SAXException e) { + throw new JAXBException("Failed to create a JAXP compliant SAX parser.", e); + } + } + return xmlReader; + } + + /* @see javax.xml.bind.Unmarshaller#unmarshal(javax.xml.transform.Source) + */ + public Object unmarshal(Source pSource) throws JAXBException { + if (pSource instanceof SAXSource) { + SAXSource ss = (SAXSource) pSource; + InputSource is = ss.getInputSource(); + XMLReader xr = ss.getXMLReader(); + if (xr == null) { + xr = getXMLReader(); + } + return unmarshal(xr, is); + } else if (pSource instanceof StreamSource) { + StreamSource ss = (StreamSource) pSource; + InputSource is; + InputStream istream = ss.getInputStream(); + if (istream == null) { + Reader r = ss.getReader(); + if (r == null) { + throw new JAXBException("The specified StreamSource must have configured either of its InputStream or Reader."); + } + is = new InputSource(r); + } else { + is = new InputSource(istream); + } + is.setSystemId(ss.getSystemId()); + is.setPublicId(ss.getPublicId()); + return unmarshal(getXMLReader(), is); + } else if (pSource instanceof DOMSource) { + DOMSource ds = (DOMSource) pSource; + return unmarshal(ds.getNode()); + } else { + throw new JAXBException("Unsupported type of " + Source.class.getName() + + ", expected either of " + + SAXSource.class.getName() + ", " + + StreamSource.class.getName() + ", or " + + DOMSource.class.getName()); + } + } + + /** <p>Unmarshals an object by using the given instance + * of [EMAIL PROTECTED] org.xml.sax.XMLReader} to parse the XML + * document read from the byte or character stream + * given by the [EMAIL PROTECTED] org.xml.sax.InputSource} + * <code>pSource</code>.</p> + * <p>The implementation should call the method + * [EMAIL PROTECTED] org.xml.sax.XMLReader#setErrorHandler(org.xml.sax.ErrorHandler)} + * in order to pass errors provided by the SAX parser to the + * [EMAIL PROTECTED] javax.xml.bind.ValidationEventHandler} provided by + * the client.</p> + * @throws JAXBException An error occurred while unmarshalling + * the JAXB object. + */ + protected abstract java.lang.Object unmarshal(XMLReader pReader, + InputSource pSource) + throws JAXBException; + + /* @see javax.xml.bind.Unmarshaller#unmarshal(org.xml.sax.InputSource) + */ + public final Object unmarshal(InputSource pSource) throws JAXBException { + return unmarshal(getXMLReader(), pSource); + } + + /* @see javax.xml.bind.Unmarshaller#unmarshal(java.net.URL) + */ + public final java.lang.Object unmarshal(java.net.URL pURL) throws JAXBException { + InputSource isource; + try { + isource = new InputSource(pURL.openStream()); + } catch (IOException e) { + throw new JAXBException("Failed to open URL " + pURL + ": " + e.getMessage(), e); + } + isource.setSystemId(pURL.toExternalForm()); + return unmarshal(getXMLReader(), isource); + } + + /* @see javax.xml.bind.Unmarshaller#unmarshal(java.io.File) + */ + public final java.lang.Object unmarshal(java.io.File pFile) throws JAXBException { + InputSource isource; + try { + isource = new InputSource(new FileInputStream(pFile)); + } catch (IOException e) { + throw new JAXBException("Failed to open file " + pFile + ": " + e.getMessage(), e); + } + try { + isource.setSystemId(pFile.toURL().toExternalForm()); + } catch (IOException e) { + throw new JAXBException("Malformed URL: " + pFile, e); + } + return unmarshal(getXMLReader(), isource); + } + + /* + * @see javax.xml.bind.Unmarshaller#unmarshal(java.io.InputStream) + */ + public final java.lang.Object unmarshal(java.io.InputStream pSource) + throws JAXBException { + return unmarshal(getXMLReader(), new InputSource(pSource)); + } + + /* + * @see javax.xml.bind.Unmarshaller#unmarshal(java.io.Reader) + */ + public final java.lang.Object unmarshal(java.io.Reader pReader) + throws JAXBException { + return unmarshal(getXMLReader(), new InputSource(pReader)); + } + + /* @see javax.xml.bind.Unmarshaller#isValidating() + */ + public boolean isValidating() throws JAXBException { + return validating; + } + + /* @see javax.xml.bind.Unmarshaller#setValidating(boolean) + */ + public void setValidating(boolean pValidating) throws JAXBException { + validating = pValidating; + } + + /* @see javax.xml.bind.Unmarshaller#getEventHandler() + */ + public ValidationEventHandler getEventHandler() + throws JAXBException { + return validationEventHandler; + } + + /* @see javax.xml.bind.Unmarshaller#setEventHandler(javax.xml.bind.ValidationEventHandler) + */ + public void setEventHandler(ValidationEventHandler pHandler) + throws JAXBException { + validationEventHandler = pHandler; + } + + /** <p>Helper method to concert a [EMAIL PROTECTED] org.xml.sax.SAXException} + * into an [EMAIL PROTECTED] javax.xml.bind.UnmarshalException}.</p> + * @param pException If the parameter contains a nested instance of + * [EMAIL PROTECTED] javax.xml.bind.UnmarshalException}, throws that instance. + * Otherwise wraps the parameter in a new + * [EMAIL PROTECTED] javax.xml.bind.UnmarshalException} and throws that. + */ + protected UnmarshalException createUnmarshalException(SAXException pException) { + Exception ex = pException.getException(); + if (ex != null && ex instanceof UnmarshalException) { + return (UnmarshalException) ex; + } + return new UnmarshalException(pException); + } + + /** <p>Always throws a [EMAIL PROTECTED] javax.xml.bind.PropertyException}, + * because the default implementation does not support any + * properties. If you want to change this, override the class.</p> + * @throws IllegalArgumentException The property name was null. + * @throws PropertyException The name was not null. :-) + */ + public void setProperty(String pName, Object pValue) throws PropertyException { + if (pName == null) { + throw new IllegalArgumentException("The property name must not be null."); + } + throw new PropertyException("Unsupported property name: " + pName); + } + + /** <p>Always throws a [EMAIL PROTECTED] javax.xml.bind.PropertyException}, + * because the default implementation does not support any + * properties. If you want to change this, override the class.</p> + * @throws IllegalArgumentException The property name was null. + * @throws PropertyException The name was not null. :-) + */ + public Object getProperty(String pName) throws PropertyException { + if (pName == null) { + throw new IllegalArgumentException("The property name must not be null."); + } + throw new PropertyException("Unsupported property name: " + pName); + } + + public Object unmarshal(XMLEventReader reader) throws JAXBException { + + throw new UnsupportedOperationException(); + } + + public Object unmarshal(XMLStreamReader reader) throws JAXBException { + + throw new UnsupportedOperationException(); + } + + public <T> JAXBElement<T> unmarshal(Node node, Class<T> expectedType) throws JAXBException { + throw new UnsupportedOperationException(); + } + + public <T> JAXBElement<T> unmarshal(Source source, Class<T> expectedType) throws JAXBException { + throw new UnsupportedOperationException(); + } + + public <T> JAXBElement<T> unmarshal(XMLStreamReader reader, Class<T> expectedType) throws JAXBException { + throw new UnsupportedOperationException(); + } + + public <T> JAXBElement<T> unmarshal(XMLEventReader reader, Class<T> expectedType) throws JAXBException { + throw new UnsupportedOperationException(); + } + + public void setSchema(Schema schema) { + throw new UnsupportedOperationException(); + } + + public Schema getSchema() { + throw new UnsupportedOperationException(); + } + + @SuppressWarnings("unchecked") + public void setAdapter(XmlAdapter<?,?> adapter) { + if(adapter==null) + throw new IllegalArgumentException(); + setAdapter((Class)adapter.getClass(),adapter); + } + + public <A extends XmlAdapter<?,?>> void setAdapter(Class<A> type, A adapter) { + throw new UnsupportedOperationException(); + } + + public <A extends XmlAdapter<?,?>> A getAdapter(Class<A> type) { + throw new UnsupportedOperationException(); + } + + public void setAttachmentUnmarshaller(AttachmentUnmarshaller au) { + throw new UnsupportedOperationException(); + } + + public AttachmentUnmarshaller getAttachmentUnmarshaller() { + throw new UnsupportedOperationException(); + } + + public void setListener(Listener listener) { + throw new UnsupportedOperationException(); + } + + public Listener getListener() { + throw new UnsupportedOperationException(); + } +}
Added: webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/helpers/DefaultValidationEventHandler.java URL: http://svn.apache.org/viewvc/webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/helpers/DefaultValidationEventHandler.java?view=auto&rev=494575 ============================================================================== --- webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/helpers/DefaultValidationEventHandler.java (added) +++ webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/helpers/DefaultValidationEventHandler.java Tue Jan 9 13:07:17 2007 @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package javax.xml.bind.helpers; + +import javax.xml.bind.ValidationEvent; +import javax.xml.bind.ValidationEventHandler; + +/** <p>Default implementation of a [EMAIL PROTECTED] javax.xml.bind.ValidationEventHandler}. + * Causes the validation to fail as soon as the first error or + * fatal error is encountered.</p> + * <p>This instance of [EMAIL PROTECTED] javax.xml.bind.ValidationEventHandler} is + * suitable for use of the unmarshallers or validators default event handler.</p> + * + * @author JSR-31 + * @since JAXB1.0 + */ +public class DefaultValidationEventHandler implements ValidationEventHandler { + static final DefaultValidationEventHandler theInstance = + new DefaultValidationEventHandler(); + + /** <p>Creates a new instance of <code>DefaultValidationEventHandler</code>.</p> + */ + public DefaultValidationEventHandler() { + } + + public boolean handleEvent(ValidationEvent event) { + if (event.getSeverity() == ValidationEvent.WARNING) { + return true; + } else { + return false; + } + } +} Added: webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/helpers/NotIdentifiableEventImpl.java URL: http://svn.apache.org/viewvc/webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/helpers/NotIdentifiableEventImpl.java?view=auto&rev=494575 ============================================================================== --- webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/helpers/NotIdentifiableEventImpl.java (added) +++ webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/helpers/NotIdentifiableEventImpl.java Tue Jan 9 13:07:17 2007 @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package javax.xml.bind.helpers; + +import javax.xml.bind.ValidationEventLocator; + +/** <p>Default implementation of a [EMAIL PROTECTED] javax.xml.bind.NotIdentifiableEvent}.</p> + * + * @author JSR-31 + * @since JAXB1.0 + */ +public class NotIdentifiableEventImpl extends ValidationEventImpl + implements javax.xml.bind.NotIdentifiableEvent { + + /** <p>Creates a new instance of <code>NotIdentifiableEventImpl</code>.</p> + */ + public NotIdentifiableEventImpl(int pSeverity, String pMessage, + ValidationEventLocator pLocator) { + super(pSeverity, pMessage, pLocator); + } + + /** <p>Creates a new instance of <code>NotIdentifiableEventImpl</code>.</p> + */ + public NotIdentifiableEventImpl(int pSeverity, String pMessage, + ValidationEventLocator pLocator, + Throwable pLinkedException) { + super(pSeverity, pMessage, pLocator, pLinkedException); + } +} Added: webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/helpers/ParseConversionEventImpl.java URL: http://svn.apache.org/viewvc/webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/helpers/ParseConversionEventImpl.java?view=auto&rev=494575 ============================================================================== --- webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/helpers/ParseConversionEventImpl.java (added) +++ webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/helpers/ParseConversionEventImpl.java Tue Jan 9 13:07:17 2007 @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package javax.xml.bind.helpers; + +import javax.xml.bind.ValidationEventLocator; + +/** <p>Default implementation of a [EMAIL PROTECTED] javax.xml.bind.ParseConversionEvent}.</p> + * + * @author JSR-31 + * @since JAXB1.0 + */ +public class ParseConversionEventImpl extends ValidationEventImpl + implements javax.xml.bind.ParseConversionEvent { + + /** <p>Creates a new instance of <code>ParseConversionEventImpl</code>.</p> + */ + public ParseConversionEventImpl(int pSeverity, String pMessage, + ValidationEventLocator pLocator) { + super(pSeverity, pMessage, pLocator); + } + + /** <p>Creates a new instance of <code>ParseConversionEventImpl</code>.</p> + */ + public ParseConversionEventImpl(int pSeverity, String pMessage, + ValidationEventLocator pLocator, + Throwable pLinkedException) { + super(pSeverity, pMessage, pLocator, pLinkedException); + } +} Added: webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/helpers/PrintConversionEventImpl.java URL: http://svn.apache.org/viewvc/webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/helpers/PrintConversionEventImpl.java?view=auto&rev=494575 ============================================================================== --- webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/helpers/PrintConversionEventImpl.java (added) +++ webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/helpers/PrintConversionEventImpl.java Tue Jan 9 13:07:17 2007 @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package javax.xml.bind.helpers; + +import javax.xml.bind.ValidationEventLocator; + +/** <p>Default implementation of a [EMAIL PROTECTED] javax.xml.bind.PrintConversionEvent}.</p> + * + * @author JSR-31 + * @since JAXB1.0 + */ +public class PrintConversionEventImpl extends ValidationEventImpl + implements javax.xml.bind.PrintConversionEvent { + + /** <p>Creates a new instance of <code>PrintConversionEventImpl</code>.</p> + */ + public PrintConversionEventImpl(int pSeverity, String pMessage, + ValidationEventLocator pLocator) { + super(pSeverity, pMessage, pLocator); + } + + /** <p>Creates a new instance of <code>PrintConversionEventImpl</code>.</p> + */ + public PrintConversionEventImpl(int pSeverity, String pMessage, + ValidationEventLocator pLocator, + Throwable pLinkedException) { + super(pSeverity, pMessage, pLocator, pLinkedException); + } +} Added: webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/helpers/ValidationEventImpl.java URL: http://svn.apache.org/viewvc/webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/helpers/ValidationEventImpl.java?view=auto&rev=494575 ============================================================================== --- webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/helpers/ValidationEventImpl.java (added) +++ webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/helpers/ValidationEventImpl.java Tue Jan 9 13:07:17 2007 @@ -0,0 +1,124 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package javax.xml.bind.helpers; + +import javax.xml.bind.ValidationEvent; +import javax.xml.bind.ValidationEventLocator; + + +/** <p>Default implementation of a [EMAIL PROTECTED] javax.xml.bind.ValidationEvent}.</p> + * + * @author JSR-31 + * @since JAXB1.0 + */ +public class ValidationEventImpl implements ValidationEvent { + private int severity; + private String message; + private Throwable linkedException; + private ValidationEventLocator locator; + + /** <p>Creates a new instance of <code>ValidationEventImpl</code>.</p> + */ + public ValidationEventImpl(int pSeverity, String pMessage, + ValidationEventLocator pLocator) { + severity = pSeverity; + message = pMessage; + locator = pLocator; + } + + /** <p>Creates a new instance of <code>ValidationEventImpl</code>.</p> + */ + public ValidationEventImpl(int pSeverity, String pMessage, + ValidationEventLocator pLocator, + Throwable pLinkedException) { + severity = pSeverity; + message = pMessage; + linkedException = pLinkedException; + locator = pLocator; + } + + /* @see javax.xml.bind.ValidationEvent#getSeverity() + */ + public int getSeverity() { + return severity; + } + + /** <p>Sets the events severity.</p> + * @param pSeverity The events severity, either of + * [EMAIL PROTECTED] javax.xml.bind.ValidationEvent#WARNING}, + * [EMAIL PROTECTED] javax.xml.bind.ValidationEvent#ERROR}, or + * [EMAIL PROTECTED] javax.xml.bind.ValidationEvent#FATAL_ERROR}.</p> + */ + public void setSeverity(int pSeverity) { + severity = pSeverity; + } + + /* @see javax.xml.bind.ValidationEvent#getMessage() + */ + public String getMessage() { + return message; + } + + /** <p>Sets the events message.</p> + */ + public void setMessage(String pMessage) { + message = pMessage; + } + + /* @see javax.xml.bind.ValidationEvent#getLinkedException() + */ + public Throwable getLinkedException() { + return linkedException; + } + + /** <p>Sets the exception, which is linked to the event.</p> + */ + public void setLinkedException(Throwable pLinkedException) { + linkedException = pLinkedException; + } + + /* @see javax.xml.bind.ValidationEvent#getLocator() + */ + public ValidationEventLocator getLocator() { + return locator; + } + + /** + * <p>Sets the events locator.</p> + */ + public void setLocator(ValidationEventLocator pLocator) { + locator = pLocator; + } + + /** + * Returns a string representation of this object in a format + * helpful to debugging. + * + * @see Object#equals(Object) + */ + public String toString() { + final String s; + switch(getSeverity()) { + case WARNING: s="WARNING"; break; + case ERROR: s="ERROR"; break; + case FATAL_ERROR: s="FATAL_ERROR"; break; + default: s = String.valueOf(getSeverity()); break; + } + return "[severity=" + s + ",message=" + getMessage() + ",locator=" + + getLocator() + "]"; + } +} Added: webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/helpers/ValidationEventLocatorImpl.java URL: http://svn.apache.org/viewvc/webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/helpers/ValidationEventLocatorImpl.java?view=auto&rev=494575 ============================================================================== --- webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/helpers/ValidationEventLocatorImpl.java (added) +++ webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/helpers/ValidationEventLocatorImpl.java Tue Jan 9 13:07:17 2007 @@ -0,0 +1,189 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package javax.xml.bind.helpers; + +import java.net.MalformedURLException; +import java.net.URL; + +import javax.xml.bind.ValidationEventLocator; + +import org.w3c.dom.Node; +import org.xml.sax.Locator; +import org.xml.sax.SAXParseException; + + +/** <p>Default implementation of a [EMAIL PROTECTED] javax.xml.bind.ValidationEventLocator}.</p> + * + * @author JSR-31 + * @since JAXB1.0 + */ +public class ValidationEventLocatorImpl implements ValidationEventLocator { + private URL url; + private int offset, lineNumber, columnNumber; + private Object object; + private Node node; + + /** <p>Creates a new instance of <code>ValidationEventLocatorImpl</code>.</p> + */ + public ValidationEventLocatorImpl() { + offset = lineNumber = columnNumber = -1; + } + + /** <p>Creates a new instance of <code>ValidationEventLocatorImpl</code> + * by copying data from the given [EMAIL PROTECTED] org.xml.sax.Locator}.</p> + * @param pLocator The SAX locator where to copy from. + */ + public ValidationEventLocatorImpl(Locator pLocator) { + if (pLocator == null) { + lineNumber = columnNumber = -1; + } else { + columnNumber = pLocator.getColumnNumber(); + lineNumber = pLocator.getLineNumber(); + String u = pLocator.getSystemId(); + if (u != null) { + try { + url = new URL(pLocator.getSystemId()); + } catch (MalformedURLException e) { + // Ignore me + } + } + } + offset = -1; + } + + /** <p>Creates a new instance of <code>ValidationEventLocatorImpl</code> + * by setting the node property.</p> + * @param pNode The node being referenced. + */ + public ValidationEventLocatorImpl(Node pNode) { + node = pNode; + offset = lineNumber = columnNumber = -1; + } + + /** <p>Creates a new instance of <code>ValidationEventLocatorImpl</code> + * by setting the object property.</p> + * @param pObject The object being referenced. + */ + public ValidationEventLocatorImpl(Object pObject) { + object = pObject; + offset = lineNumber = columnNumber = -1; + } + + /** <p>Creates a new instance of <code>ValidationEventLocatorImpl</code> + * by copying data from the given [EMAIL PROTECTED] org.xml.sax.SAXParseException}.</p> + * @param pException The SAX exception where to copy from. + */ + public ValidationEventLocatorImpl(SAXParseException pException) { + columnNumber = pException.getColumnNumber(); + lineNumber = pException.getLineNumber(); + String u = pException.getSystemId(); + if (u != null) { + try { + url = new URL(pException.getSystemId()); + } catch (MalformedURLException e) { + // Ignore me + } + } + offset = -1; + } + + /** <p>Sets the URL.</p> + */ + public void setURL(URL pURL) { + url = pURL; + } + + /* @see javax.xml.bind.ValidationEventLocator#getURL() + */ + public URL getURL() { + return url; + } + + /** <p>Sets the offset.</p> + */ + public void setOffset(int pOffset) { + offset = pOffset; + } + + /* @see javax.xml.bind.ValidationEventLocator#getOffset() + */ + public int getOffset() { + return offset; + } + + /** <p>Sets the line number.</p> + */ + public void setLineNumber(int pLineNumber) { + lineNumber = pLineNumber; + } + + /* @see javax.xml.bind.ValidationEventLocator#getLineNumber() + */ + public int getLineNumber() { + return lineNumber; + } + + /** <p>Sets the column number.</p> + */ + public void setColumnNumber(int pColumnNumber) { + columnNumber = pColumnNumber; + } + + /* @see javax.xml.bind.ValidationEventLocator#getColumnNumber() + */ + public int getColumnNumber() { + return columnNumber; + } + + /** <p>Sets the object.</p> + */ + public void setObject(Object pObject) { + object = pObject; + } + + /* @see javax.xml.bind.ValidationEventLocator#getObject() + */ + public Object getObject() { + return object; + } + + /** <p>Sets the node.</p> + */ + public void setNode(Node pNode) { + node = pNode; + } + + /* @see javax.xml.bind.ValidationEventLocator#getNode() + */ + public Node getNode() { + return node; + } + + /** + * Returns a string representation of this object in a format + * helpful to debugging. + * + * @see Object#equals(Object) + */ + @Override + public String toString() { + return "[node=" + getNode() + ",object=" + getObject() + + ",url=" + getURL() + ",line=" + getLineNumber() + + ",col=" + getColumnNumber() + ",offset={5}]" + + getOffset() + "]"; + } +} Added: webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/helpers/package.html URL: http://svn.apache.org/viewvc/webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/helpers/package.html?view=auto&rev=494575 ============================================================================== --- webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/helpers/package.html (added) +++ webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/helpers/package.html Tue Jan 9 13:07:17 2007 @@ -0,0 +1,30 @@ +<!-- + + Copyright 2004 The Apache Software Foundation. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> +<html> + <head> + <title> +Package Documentation for javax.xml.bind.helpers Package + </title> +</head> + <body bgcolor="white"> + <p> +Helper classes for JAXB implementations. +Contains standard implementations for several important JAXB interfaces. + </p> +</body> +</html> \ No newline at end of file Added: webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/package.html URL: http://svn.apache.org/viewvc/webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/package.html?view=auto&rev=494575 ============================================================================== --- webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/package.html (added) +++ webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/package.html Tue Jan 9 13:07:17 2007 @@ -0,0 +1,29 @@ +<!-- + + Copyright 2004 The Apache Software Foundation. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> +<html> + <head> + <title> +Package Documentation for javax.xml.bind Package + </title> +</head> + <body bgcolor="white"> + <p> +Clean room implementation of the JAXB standard xml-binding API. + </p> +</body> +</html> \ No newline at end of file Added: webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/util/JAXBResult.java URL: http://svn.apache.org/viewvc/webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/util/JAXBResult.java?view=auto&rev=494575 ============================================================================== --- webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/util/JAXBResult.java (added) +++ webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/util/JAXBResult.java Tue Jan 9 13:07:17 2007 @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package javax.xml.bind.util; + +import javax.xml.bind.JAXBException; +import javax.xml.bind.UnmarshallerHandler; +import javax.xml.transform.sax.SAXResult; + + +/** <p>Utility class that allows to catch the result of a + * stylesheet transformation in a JAXB object.</p> + * + * @author JSR-31 + * @since JAXB1.0 + */ +public class JAXBResult extends SAXResult { + /** <p>Creates a new instance of <code>JAXBResult</code>. + * The instance will use the specified [EMAIL PROTECTED] javax.xml.bind.JAXBContext} + * to create an [EMAIL PROTECTED] javax.xml.bind.Unmarshaller}.</p> + */ + public JAXBResult(javax.xml.bind.JAXBContext pContext) throws JAXBException { + this(pContext.createUnmarshaller()); + } + + /** <p>Creates a new instance of <code>JAXBResult</code>. + * The instance will use the given [EMAIL PROTECTED] javax.xml.bind.Unmarshaller} + * to create a [EMAIL PROTECTED] org.xml.sax.ContentHandler}.</p> + * <p>In most cases you will use the constructor taking a + * [EMAIL PROTECTED] javax.xml.bind.JAXBContext} as input. This additional + * constructor is required, if you want to configure the + * [EMAIL PROTECTED] javax.xml.bind.Unmarshaller}.</p> + * @param pUnmarshaller The Unmarshaller that may be queried for an + * [EMAIL PROTECTED] UnmarshallerHandler}. + */ + public JAXBResult(javax.xml.bind.Unmarshaller pUnmarshaller) throws JAXBException { + super(pUnmarshaller.getUnmarshallerHandler()); + } + + /** <p>Returns the result of a previous transformation.</p> + */ + public Object getResult() throws JAXBException { + return ((UnmarshallerHandler) super.getHandler()).getResult(); + } +} Added: webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/util/JAXBSource.java URL: http://svn.apache.org/viewvc/webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/util/JAXBSource.java?view=auto&rev=494575 ============================================================================== --- webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/util/JAXBSource.java (added) +++ webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/util/JAXBSource.java Tue Jan 9 13:07:17 2007 @@ -0,0 +1,175 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package javax.xml.bind.util; + +import java.io.IOException; + +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; +import javax.xml.transform.sax.SAXSource; + +import org.xml.sax.ContentHandler; +import org.xml.sax.DTDHandler; +import org.xml.sax.EntityResolver; +import org.xml.sax.ErrorHandler; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.SAXNotRecognizedException; +import org.xml.sax.SAXNotSupportedException; +import org.xml.sax.SAXParseException; +import org.xml.sax.XMLReader; +import org.xml.sax.helpers.XMLFilterImpl; + + +/** This utility class allows to use a JAXB object as the + * source of a stylesheet transformation.<br> + * If you depend on any methods from + * [EMAIL PROTECTED] javax.xml.transform.sax.SAXSource}, you should + * use this class. In particular, you must not use the + * methods + * [EMAIL PROTECTED] javax.xml.transform.sax.SAXSource#setInputSource(InputSource)}, + * or + * [EMAIL PROTECTED] javax.xml.transform.sax.SAXSource#setXMLReader(XMLReader)} + * on an instance of <code>JAXBSource</code>.<br> + * If you depend on these methods, a replacement for the + * <code>JAXBSource</code> can be obtained as follows: + * <pre> + * javax.xml.bind.JAXBContext context; + * javax.xml.bind.Element object; + * java.io.StringWriter sw = new java.io.StringWriter(); + * context.createMarshaller().marshal(object, sw); + * org.xml.sax.InputSource isource = new org.xml.sax.InputSource(new java.io.StringReader(sw.toString())); + * javax.xml.transform.sax.SAXSource source = new javax.xml.transform.sax.SAXSource(isource); + * </pre> + * + * @author JSR-31 + * @since JAXB1.0 + */ +public class JAXBSource extends SAXSource { + /** This private class basically wraps a marshaller and calls its marshal + * method when the parse methods are called on the XMLReader. + **/ + private class JAXBSourceXMLReader implements XMLReader { + private EntityResolver resolver; + private DTDHandler dtdHandler; + private ErrorHandler errorHandler; + private XMLFilterImpl contentHandlerProxy = new XMLFilterImpl(); + + public boolean getFeature(String name) throws SAXNotRecognizedException, SAXNotSupportedException { + if (name.equals("http://xml.org/sax/features/namespaces") + || name.equals("http://xml.org/sax/features/namespace-prefixes")) { + return true; + } else { + throw new SAXNotRecognizedException("Unknown feature: " + name); + } + } + + public void setFeature(String name, boolean value) throws SAXNotRecognizedException, SAXNotSupportedException { + if(name.equals("http://xml.org/sax/features/namespaces") + || name.equals("http://xml.org/sax/features/namespace-prefixes")) { + if(!value) { + throw new SAXNotSupportedException("The feature " + name + " cannot be disabled."); + } + } else { + throw new SAXNotRecognizedException("Unknown feature: " + name); + } + } + + public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException { + throw new SAXNotRecognizedException("Unknown property: " + name); + } + + public void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException { + throw new SAXNotRecognizedException("Unknown property: " + name); + } + + public EntityResolver getEntityResolver() { + return resolver; + } + + public void setEntityResolver(EntityResolver resolver) { + this.resolver = resolver; + } + + public DTDHandler getDTDHandler() { + return dtdHandler; + } + + public void setDTDHandler(DTDHandler handler) { + this.dtdHandler = handler; + } + + public ContentHandler getContentHandler() { + return contentHandlerProxy.getContentHandler(); + } + + public void setContentHandler(ContentHandler handler) { + contentHandlerProxy.setContentHandler(handler); + } + + public ErrorHandler getErrorHandler() { + return errorHandler; + } + + public void setErrorHandler(ErrorHandler handler) { + errorHandler = handler; + } + + public void parse(String systemId) throws IOException, SAXException { + throw new IllegalStateException("The XMLReader created by a JAXBSource must not be used to parse a system ID."); + } + + public void parse(InputSource pInput) throws IOException, SAXException { + if (pInput != inputSource) { + throw new IllegalArgumentException("The XMLReader created by an instance of JAXBSource can only be used to parse the InputSource returned by the same JAXBSource."); + } + try { + marshaller.marshal(contentObject, contentHandlerProxy); + } catch(JAXBException e) { + SAXParseException spe = new SAXParseException(e.getMessage(), null, null, -1, -1, e); + if(errorHandler!=null) { + errorHandler.fatalError(spe); + } + throw spe; + } + } + } + + private final Marshaller marshaller; + private final Object contentObject; + private final InputSource inputSource; + + /** <p>Creates a new instance of JAXBSource. The given + * [EMAIL PROTECTED] javax.xml.bind.JAXBContext} will be used to + * construct a [EMAIL PROTECTED] javax.xml.bind.Marshaller} and + * invoke the constructor + * [EMAIL PROTECTED] #JAXBSource(javax.xml.bind.Marshaller, Object)}.</p> + */ + public JAXBSource(javax.xml.bind.JAXBContext pContext, Object pObject) throws JAXBException { + this(pContext.createMarshaller(), pObject); + } + + /** <p>Creates a new instance of JAXBSource.</p> + */ + public JAXBSource(javax.xml.bind.Marshaller pMarshaller, Object pObject) throws JAXBException { + marshaller = pMarshaller; + contentObject = pObject; + inputSource = new InputSource(); + super.setInputSource(inputSource); + super.setXMLReader(new JAXBSourceXMLReader()); + } +} Added: webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/util/ValidationEventCollector.java URL: http://svn.apache.org/viewvc/webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/util/ValidationEventCollector.java?view=auto&rev=494575 ============================================================================== --- webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/util/ValidationEventCollector.java (added) +++ webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/util/ValidationEventCollector.java Tue Jan 9 13:07:17 2007 @@ -0,0 +1,68 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package javax.xml.bind.util; + + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.ValidationEvent; +import javax.xml.bind.ValidationEventHandler; + + +/** <p>Simple implementation of a [EMAIL PROTECTED] javax.xml.bind.ValidationEventHandler}, + * which simply collects all the events, regardless whether they + * are warnings, errors, or fatal errors. You may retrieve these events + * at a later time using [EMAIL PROTECTED] #getEvents()}.</p> + * + * @author JSR-31 + * @since JAXB1.0 + */ +public class ValidationEventCollector implements ValidationEventHandler { + private List events = new ArrayList(); + + /** <p>Creates a new instance of <code>ValidationEventCollector</code>.</p> + */ + public ValidationEventCollector() { + } + + /** <p>Returns the events collected so far. Empty array, if no + * events have been found.</p> + */ + public ValidationEvent[] getEvents() { + return (ValidationEvent[]) events.toArray(new ValidationEvent[events.size()]); + } + + /** <p>Clears the list of collected warnings, errors, and fatal errors.</p> + */ + public void reset() { + events.clear(); + } + + /** <p>Returns whether any event has been collected.</p> + */ + public boolean hasEvents() { + return !events.isEmpty(); + } + + /** <p>Will always return true.</p> + */ + public boolean handleEvent(ValidationEvent pEvent) { + events.add(pEvent); + return true; + } +} Added: webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/util/package.html URL: http://svn.apache.org/viewvc/webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/util/package.html?view=auto&rev=494575 ============================================================================== --- webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/util/package.html (added) +++ webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/main/java/javax/xml/bind/util/package.html Tue Jan 9 13:07:17 2007 @@ -0,0 +1,29 @@ +<!-- + + Copyright 2004 The Apache Software Foundation. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> +<html> + <head> + <title> +Package Documentation for javax.xml.bind.util Package + </title> +</head> + <body bgcolor="white"> + <p> +Utility classes used by the JAXB standard. + </p> +</body> +</html> \ No newline at end of file Added: webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/test/java/javax/xml/bind/annotation/adapters/AdapterTest.java URL: http://svn.apache.org/viewvc/webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/test/java/javax/xml/bind/annotation/adapters/AdapterTest.java?view=auto&rev=494575 ============================================================================== --- webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/test/java/javax/xml/bind/annotation/adapters/AdapterTest.java (added) +++ webservices/jaxme/trunk/ws-jaxme/jaxme-jaxb-api/src/test/java/javax/xml/bind/annotation/adapters/AdapterTest.java Tue Jan 9 13:07:17 2007 @@ -0,0 +1,56 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package javax.xml.bind.annotation.adapters; + +import junit.framework.TestCase; + +public class AdapterTest extends TestCase { + public void testCollapsedStringAdapter() { + CollapsedStringAdapter adapter = new CollapsedStringAdapter(); + assertNull(adapter.unmarshal(null)); + assertEquals("", adapter.unmarshal("")); + assertEquals("", adapter.unmarshal(" ")); + assertEquals("", adapter.unmarshal("\r")); + assertEquals("", adapter.unmarshal("\t")); + assertEquals("", adapter.unmarshal("\n")); + assertEquals("a", adapter.unmarshal(" a")); + assertEquals("a", adapter.unmarshal("\ra")); + assertEquals("a", adapter.unmarshal("\na")); + assertEquals("a", adapter.unmarshal("\ta")); + assertEquals("a", adapter.unmarshal("a ")); + assertEquals("a", adapter.unmarshal("a\r")); + assertEquals("a", adapter.unmarshal("a\n")); + assertEquals("a", adapter.unmarshal("a\t")); + assertEquals("a", adapter.unmarshal(" a ")); + assertEquals("a", adapter.unmarshal("\ra\r")); + assertEquals("a", adapter.unmarshal("\na\n")); + assertEquals("a", adapter.unmarshal("\ta\t")); + assertEquals("a b", adapter.unmarshal(" a b ")); + assertEquals("a b", adapter.unmarshal("\ra\r\rb\r")); + assertEquals("a b", adapter.unmarshal("\na\n\nb\n")); + assertEquals("a b", adapter.unmarshal("\ta\t\tb\t")); + + } + + public void testNormalizedStringAdapter() { + NormalizedStringAdapter adapter = new NormalizedStringAdapter(); + assertNull(adapter.unmarshal(null)); + assertEquals("", adapter.unmarshal("")); + assertEquals(" abcdefg ", adapter.unmarshal(" abcdefg ")); + assertEquals(" a b c defg ", adapter.unmarshal(" a\rb\nc\tdefg ")); + } +} --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]