From: Dennis S. <dso...@us...> - 2005-07-21 08:13:11
|
Update of /cvsroot/jibx/core/build/src/org/jibx/runtime/impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13803/src/org/jibx/runtime/impl Modified Files: MarshallingContext.java UnmarshallingContext.java Log Message: Track the binding factory used to create the context, and provide an access method. Index: UnmarshallingContext.java =================================================================== RCS file: /cvsroot/jibx/core/build/src/org/jibx/runtime/impl/UnmarshallingContext.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** UnmarshallingContext.java 24 Jun 2005 20:06:21 -0000 1.8 --- UnmarshallingContext.java 21 Jul 2005 08:00:24 -0000 1.9 *************** *** 65,79 **** /** Default parser factory name when nothing else found. */ ! protected static final String DEFAULT_PARSER_NAME = "org.xmlpull.mxp1.MXParserFactory"; /** Starting size for object stack. */ ! protected static final int INITIAL_STACK_SIZE = 20; /** Empty array of strings. */ ! protected static final String[] EMPTY_STRING_ARRAY = new String[0]; /** Factory used for constructing parser instances. */ ! protected static XmlPullParserFactory s_factory; /** Wrapper for supplied input stream. */ --- 65,82 ---- /** Default parser factory name when nothing else found. */ ! private static final String DEFAULT_PARSER_NAME = "org.xmlpull.mxp1.MXParserFactory"; /** Starting size for object stack. */ ! private static final int INITIAL_STACK_SIZE = 20; /** Empty array of strings. */ ! private static final String[] EMPTY_STRING_ARRAY = new String[0]; /** Factory used for constructing parser instances. */ ! private static XmlPullParserFactory s_factory; ! ! /** Binding factory used to create this unmarshaller. */ ! private IBindingFactory m_factory; /** Wrapper for supplied input stream. */ *************** *** 81,88 **** /** Parser in use. */ ! protected XmlPullParser m_parser; /** Document name (may be <code>null</code>). */ ! protected String m_docName; // --- 84,91 ---- /** Parser in use. */ ! private XmlPullParser m_parser; /** Document name (may be <code>null</code>). */ ! private String m_docName; // *************** *** 155,161 **** * @param idcs array of class names with IDs (<code>null</code> if no IDs or * global IDs) */ public UnmarshallingContext(int nmap, String[] umcs, String[] nss, ! String[] names, String[] idcs) { // initialize internal unmarshaller state --- 158,165 ---- * @param idcs array of class names with IDs (<code>null</code> if no IDs or * global IDs) + * @param ifact binding factory creating this unmarshaller */ public UnmarshallingContext(int nmap, String[] umcs, String[] nss, ! String[] names, String[] idcs, IBindingFactory ifact) { // initialize internal unmarshaller state *************** *** 172,175 **** --- 176,180 ---- m_idMaps = new HashMap[size]; m_objectStack = new Object[INITIAL_STACK_SIZE]; + m_factory = ifact; } *************** *** 180,184 **** public UnmarshallingContext() { this(0, EMPTY_STRING_ARRAY, EMPTY_STRING_ARRAY, EMPTY_STRING_ARRAY, ! EMPTY_STRING_ARRAY); } --- 185,189 ---- public UnmarshallingContext() { this(0, EMPTY_STRING_ARRAY, EMPTY_STRING_ARRAY, EMPTY_STRING_ARRAY, ! EMPTY_STRING_ARRAY, null); } *************** *** 463,466 **** --- 468,472 ---- */ public void setFromContext(UnmarshallingContext parent) { + m_factory = parent.m_factory; m_parser = parent.m_parser; m_docName = parent.m_docName; *************** *** 2752,2755 **** --- 2758,2770 ---- /** + * Return the binding factory used to create this unmarshaller. + * + * @return binding factory + */ + public IBindingFactory getFactory() { + return m_factory; + } + + /** * Return the supplied document name. * *************** *** 3133,3136 **** --- 3148,3163 ---- /** + * Get namespace URI matching prefix. + * + * @param prefix namespace prefix to be matched (<code>null</code> for + * default namespace) + * @return namespace URI for prefix + * @exception JiBXException on any error (possibly wrapping other exception) + */ + public String getNamespaceUri(String prefix) throws JiBXException { + return m_parser.getNamespace(prefix); + } + + /** * Get text value for current event. * Index: MarshallingContext.java =================================================================== RCS file: /cvsroot/jibx/core/build/src/org/jibx/runtime/impl/MarshallingContext.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** MarshallingContext.java 24 Jun 2005 20:02:14 -0000 1.9 --- MarshallingContext.java 21 Jul 2005 08:00:24 -0000 1.10 *************** *** 54,84 **** /** Starting size for object stack. */ ! protected static final int INITIAL_STACK_SIZE = 20; /** Names of classes included in mapping definition. */ ! protected String[] m_classes; /** Number of classes with global marshallers. */ ! protected int m_globalCount; /** Marshaller classes for mapping definition (<code>null</code> for mappings out of context). */ ! protected String[] m_marshallerClasses; /** Marshallers for classes in mapping definition (lazy create of actual marshaller instances) */ ! protected IMarshaller[] m_marshallers; /** URIs for namespaces used in binding. */ ! protected String[] m_uris; /** Map from URI to index number. */ ! protected HashMap m_uriMap; /** Current marshalling stack depth. */ ! protected int m_stackDepth; /** Stack of objects being marshalled. */ ! protected Object[] m_objectStack; /** Indent character count per level. */ --- 54,87 ---- /** Starting size for object stack. */ ! private static final int INITIAL_STACK_SIZE = 20; ! ! /** Binding factory used to create this unmarshaller. */ ! private IBindingFactory m_factory; /** Names of classes included in mapping definition. */ ! private String[] m_classes; /** Number of classes with global marshallers. */ ! private int m_globalCount; /** Marshaller classes for mapping definition (<code>null</code> for mappings out of context). */ ! private String[] m_marshallerClasses; /** Marshallers for classes in mapping definition (lazy create of actual marshaller instances) */ ! private IMarshaller[] m_marshallers; /** URIs for namespaces used in binding. */ ! private String[] m_uris; /** Map from URI to index number. */ ! private HashMap m_uriMap; /** Current marshalling stack depth. */ ! private int m_stackDepth; /** Stack of objects being marshalled. */ ! private Object[] m_objectStack; /** Indent character count per level. */ *************** *** 96,100 **** /** Output document handler. */ ! protected IXMLWriter m_writer; /** --- 99,103 ---- /** Output document handler. */ ! private IXMLWriter m_writer; /** *************** *** 110,116 **** * and the value in position 1 must always be the XML namespace * "http://www.w3.org/XML/1998/namespace") */ ! ! public MarshallingContext(String[] classes, String[] mcs, String[] uris) { m_classes = classes; m_globalCount = mcs.length; --- 113,120 ---- * and the value in position 1 must always be the XML namespace * "http://www.w3.org/XML/1998/namespace") + * @param ifact binding factory creating this unmarshaller */ ! public MarshallingContext(String[] classes, String[] mcs, String[] uris, ! IBindingFactory ifact) { m_classes = classes; m_globalCount = mcs.length; *************** *** 123,126 **** --- 127,131 ---- m_indentChar = ' '; m_newLine = "\n"; + m_factory = ifact; } *************** *** 132,136 **** * @throws JiBXException if error creating setting output */ - private ICharacterEscaper createEscaper(String enc) throws JiBXException { if (enc.equalsIgnoreCase("UTF-8") || enc.equalsIgnoreCase("UTF-16") || --- 137,140 ---- *************** *** 159,163 **** * @throws JiBXException if error setting output */ - public void setOutput(OutputStream outs, String enc, ICharacterEscaper esc) throws JiBXException { --- 163,166 ---- *************** *** 190,194 **** * @throws JiBXException if error creating setting output */ - public void setOutput(OutputStream outs, String enc) throws JiBXException { if (enc == null) { --- 193,196 ---- *************** *** 228,232 **** * @param esc escaper for writing characters */ - public void setOutput(Writer outw, ICharacterEscaper esc) { if (!(m_writer instanceof GenericXMLWriter)) { --- 230,233 ---- *************** *** 244,248 **** * @param outw writer for document data output */ - public void setOutput(Writer outw) { setOutput(outw, UTF8Escaper.getInstance()); --- 245,248 ---- *************** *** 254,258 **** * @return XML writer used for output */ - public IXMLWriter getXmlWriter() { return m_writer; --- 254,257 ---- *************** *** 264,268 **** * @param xwrite XML writer used for output */ - public void setXmlWriter(IXMLWriter xwrite) { m_writer = xwrite; --- 263,266 ---- *************** *** 276,280 **** * disabled */ - public int getIndent() { return m_indentCount; --- 274,277 ---- *************** *** 289,293 **** * indentation if negative */ - public void setIndent(int count) { if (m_writer != null) { --- 286,289 ---- *************** *** 308,312 **** * @param indent whitespace character used for indentation */ - public void setIndent(int count, String newline, char indent) { if (m_writer != null) { --- 304,307 ---- *************** *** 327,331 **** * @param parent context supplying target for marshalled document text */ - public void setFromContext(MarshallingContext parent) { reset(); --- 322,325 ---- *************** *** 338,342 **** * between uses. It is automatically called when output is set. */ - public void reset() { if (m_writer != null) { --- 332,335 ---- *************** *** 351,354 **** --- 344,356 ---- m_stackDepth = 0; } + + /** + * Return the binding factory used to create this unmarshaller. + * + * @return binding factory + */ + public IBindingFactory getFactory() { + return m_factory; + } /** |