[Practicalxml-commits] SF.net SVN: practicalxml:[119] branches/dev-1.1/src/main/java/net/sf/ pract
Brought to you by:
kdgregory
|
From: Auto-Generated S. C. M. <pra...@li...> - 2009-08-18 19:54:39
|
Revision: 119
http://practicalxml.svn.sourceforge.net/practicalxml/?rev=119&view=rev
Author: kdgregory
Date: 2009-08-18 19:54:24 +0000 (Tue, 18 Aug 2009)
Log Message:
-----------
remove unused file
Removed Paths:
-------------
branches/dev-1.1/src/main/java/net/sf/practicalxml/converter/bean/Xml2BeanHandler.java
Deleted: branches/dev-1.1/src/main/java/net/sf/practicalxml/converter/bean/Xml2BeanHandler.java
===================================================================
--- branches/dev-1.1/src/main/java/net/sf/practicalxml/converter/bean/Xml2BeanHandler.java 2009-08-18 19:50:39 UTC (rev 118)
+++ branches/dev-1.1/src/main/java/net/sf/practicalxml/converter/bean/Xml2BeanHandler.java 2009-08-18 19:54:24 UTC (rev 119)
@@ -1,190 +0,0 @@
-// Copyright 2008-2009 severally by the contributors
-//
-// 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.
-
-package net.sf.practicalxml.converter.bean;
-
-import java.util.Date;
-import java.util.EnumSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import javax.xml.XMLConstants;
-
-import org.w3c.dom.Element;
-
-import net.sf.practicalxml.DomUtil;
-import net.sf.practicalxml.converter.ConversionException;
-import net.sf.practicalxml.converter.internal.PrimitiveConversionHelper;
-import net.sf.practicalxml.internal.StringUtils;
-
-
-/**
- * Invoked by {@link Xml2BeanDriver} to convert a DOM <code>Element</code>
- * into the appropriate Java object. Unlike {@link Bean2XmlHandler}, there
- * will only be one instance of this object created during conversion; all
- * intermediate data can be held on the stack.
- */
-public class Xml2BeanHandler
-{
- private EnumSet<Xml2BeanOptions> _options;
- private PrimitiveConversionHelper _primitiveHelper;
-
-
- /**
- * Public constructor, allowing various options specifications.
- */
- public Xml2BeanHandler(Xml2BeanOptions... options)
- {
- _options = EnumSet.noneOf(Xml2BeanOptions.class);
- for (Xml2BeanOptions option : options)
- _options.add(option);
-
- _primitiveHelper = new PrimitiveConversionHelper(true);
- }
-
-
-//----------------------------------------------------------------------------
-// Public Methods
-//----------------------------------------------------------------------------
-
- public Boolean convertBoolean(Element elem)
- {
- return (Boolean)_primitiveHelper.parse(getText(elem), Boolean.class);
- }
-
-
- public Byte convertByte(Element elem)
- {
- return (Byte)_primitiveHelper.parse(getText(elem), Byte.class);
- }
-
-
- public Character convertCharacter(Element elem)
- {
- return (Character)_primitiveHelper.parse(getText(elem), Character.class);
- }
-
-
- public Date convertDate(Element elem)
- {
- throw new UnsupportedOperationException("not implemented yet");
- }
-
-
- public Double convertDouble(Element elem)
- {
- return (Double)_primitiveHelper.parse(getText(elem), Double.class);
- }
-
-
- public Float convertFloat(Element elem)
- {
- return (Float)_primitiveHelper.parse(getText(elem), Float.class);
- }
-
-
- public Integer convertInteger(Element elem)
- {
- return (Integer)_primitiveHelper.parse(getText(elem), Integer.class);
- }
-
-
- public Long convertLong(Element elem)
- {
- return (Long)_primitiveHelper.parse(getText(elem), Long.class);
- }
-
-
- public Number convertNumber(Element elem)
- {
- throw new UnsupportedOperationException("not implemented yet");
- }
-
-
- public Short convertShort(Element elem)
- {
- return (Short)_primitiveHelper.parse(getText(elem), Short.class);
- }
-
-
- public String convertString(Element elem)
- {
- return (String)_primitiveHelper.parse(getText(elem), String.class);
- }
-
-
- public List<?> convertList(Element elem)
- {
- throw new UnsupportedOperationException("not implemented yet");
- }
-
-
- public Set<?> convertSet(Element elem)
- {
- throw new UnsupportedOperationException("not implemented yet");
- }
-
-
- public Map<?,?> convertMap(Element elem)
- {
- throw new UnsupportedOperationException("not implemented yet");
- }
-
-
- public Object convertObject(Element elem)
- {
- throw new UnsupportedOperationException("not implemented yet");
- }
-
-
- public Object[] convertObjectArray(Element elem)
- {
- throw new UnsupportedOperationException("not implemented yet");
- }
-
-
-//----------------------------------------------------------------------------
-// Internals
-//----------------------------------------------------------------------------
-
- /**
- * Returns the text from a passed element, applying any low-level options
- * along the way.
- */
- private String getText(Element elem)
- {
- String text = DomUtil.getText(elem);
- if (_options.contains(Xml2BeanOptions.CONVERT_BLANK_AS_NULL) && StringUtils.isBlank(text))
- text = null;
- validateXsiNil(elem, text);
- return text;
- }
-
-
- /**
- * Checks for elements that require <code>xsi:nil</code>, and throws if missing.
- */
- private void validateXsiNil(Element elem, String text)
- {
- if (text != null)
- return;
- if (!_options.contains(Xml2BeanOptions.REQUIRE_XSI_NIL))
- return;
-
- String attr = elem.getAttributeNS(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI, "nil");
- if ((attr == null) || !attr.equals("true"))
- throw new ConversionException("empty element without required xsi:nil");
- }
-
-}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|