diff options
Diffstat (limited to 'branches/sca-java-1.3/modules/databinding-jaxb/src')
-rw-r--r-- | branches/sca-java-1.3/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/BeanXMLStreamReaderImpl.java | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/branches/sca-java-1.3/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/BeanXMLStreamReaderImpl.java b/branches/sca-java-1.3/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/BeanXMLStreamReaderImpl.java index 730f9e4a66..0fde2ee9a5 100644 --- a/branches/sca-java-1.3/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/BeanXMLStreamReaderImpl.java +++ b/branches/sca-java-1.3/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/BeanXMLStreamReaderImpl.java @@ -196,16 +196,24 @@ public class BeanXMLStreamReaderImpl extends XmlTreeStreamReaderImpl { return getStringValue(value); } + private static String getPackageName(Class<?> cls) { + String name = cls.getName(); + int index = name.lastIndexOf('.'); + return index == -1 ? "" : name.substring(0, index); + } + public static QName getName(Class<?> cls) { if (cls == null) { return null; } - Package pkg = cls.getPackage(); - if (pkg == null) { + + String packageName = getPackageName(cls); + + if ("".equals(packageName)) { return new QName("", cls.getSimpleName()); } StringBuffer ns = new StringBuffer("http://"); - String[] names = pkg.getName().split("\\."); + String[] names = packageName.split("\\."); for (int i = names.length - 1; i >= 0; i--) { ns.append(names[i]); if (i != 0) { @@ -215,7 +223,6 @@ public class BeanXMLStreamReaderImpl extends XmlTreeStreamReaderImpl { ns.append('/'); return new QName(ns.toString(), cls.getSimpleName()); } - } public BeanXMLStreamReaderImpl(QName name, Object bean) { |