⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 directobject.java

📁 对xml很好的java处理引擎,编译中绑定xml
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                            init = base.getInitializerMethod(sig);                            dual = true;                        }                                        }                }            }        }                // make sure the initializer is defined and public        if (init == null || ((init.getAccessFlags() &            Constants.ACC_PUBLIC) == 0)) {            throw new JiBXException("No usable constructor for " +                "marshaller or unmarshaller based on " + base.getName());        }                // get package and target name from bound class        String tname = base.getName();        int split = tname.lastIndexOf('.');        if (split >= 0) {            tname = tname.substring(split+1);         }                // create the helper class        BindingDefinition def = m_parent.getBindingRoot();        String pack = def.getDefaultPackage();        if (pack.length() > 0) {            pack += '.';        }        String name = pack + def.getPrefix() + tname + '_' + getSlot();        String[] intfs = def.isInput() ? (def.isOutput() ?            MappingDefinition.BOTH_INTERFACES :            MappingDefinition.UNMARSHALLER_INTERFACES) :            MappingDefinition.MARSHALLER_INTERFACES;        ClassFile cf = new ClassFile(name, def.getDefaultRoot(),            base, Constants.ACC_PUBLIC, intfs);                // add the public constructor method        ExceptionMethodBuilder mb = new ExceptionMethodBuilder("<init>",            Type.VOID, new Type[0], cf, Constants.ACC_PUBLIC);                // call the superclass constructor        mb.appendLoadLocal(0);        if (m_name == null) {            if (named) {                if (dual) {                    mb.appendACONST_NULL();                    mb.appendICONST_0();                    mb.appendACONST_NULL();                } else if (out) {                    mb.appendICONST_0();                    mb.appendACONST_NULL();                } else {                    mb.appendACONST_NULL();                    mb.appendACONST_NULL();                }            }        } else {            if (dual) {                m_name.genPushUri(mb);                m_name.genPushIndexPair(mb);            } else if (out) {                m_name.genPushIndexPair(mb);            } else {                m_name.genPushUriPair(mb);            }        }        if (classed) {            mb.appendLoadConstant(m_targetClass.getName());        }        mb.appendCallInit(base.getName(), init.getSignature());                    // finish with return        mb.appendReturn();        mb.codeComplete(false);                // add method and class        mb.addMethod();        cf = MungedClass.getUniqueSupportClass(cf);                // save as appropriate type(s)        if (dual) {            m_marshaller = m_unmarshaller = cf;        } else if (out) {            m_marshaller = cf;        } else {            m_unmarshaller = cf;        }    }    /**     * Generate presence test code for this mapping. The generated code finds     * the unmarshaller and calls the test method, leaving the result on the     * stack.     *     * @param mb method builder     * @throws JiBXException if error in generating code     */    public void genTestPresent(ContextMethodBuilder mb) throws JiBXException {                // start with call to unmarshalling context method to get the        //  unmarshaller instance        mb.loadContext();        genLoadSlot(mb);        mb.appendCallInterface(GETUNMARSHALLER_METHOD,            GETUNMARSHALLER_SIGNATURE);                // call the actual unmarshaller test method with context as argument        mb.loadContext();        mb.appendCallInterface(UNMARSHALLER_TESTPRESENT_METHOD,            UNMARSHALLER_TESTPRESENT_SIGNATURE);    }    /**     * Generate unmarshalling code for this mapping. The generated code finds     * and calls the unmarshaller with the object to be unmarshaller (which     * needs to be loaded on the stack by the code prior to this call, but may     * be <code>null</code>). The unmarshalled object (or <code>null</code> in     * the case of a missing optional item) is left on the stack after this     * call. The calling method generally needs to cast this object reference to     * the appropriate type before using it.     *     * @param mb method builder     * @throws JiBXException if error in generating code     */    public void genUnmarshal(ContextMethodBuilder mb) throws JiBXException {                // start with call to unmarshalling context method to get the        //  unmarshaller instance        mb.loadContext();        genLoadSlot(mb);        mb.appendCallInterface(GETUNMARSHALLER_METHOD,            GETUNMARSHALLER_SIGNATURE);                // call the actual unmarshaller with object and context as arguments        mb.appendSWAP();        mb.loadContext();        mb.appendCallInterface(UNMARSHALLER_UNMARSHAL_METHOD,            UNMARSHALLER_UNMARSHAL_SIGNATURE);    }    /**     * Generate marshalling code for this mapping. The generated code finds     * and calls the marshaller, passing the object to be marshalled (which     * should have been loaded to the stack by the prior generated code)..     *     * @param mb method builder     * @throws JiBXException if error in configuration     */    public void genMarshal(ContextMethodBuilder mb) throws JiBXException {                // start with call to marshalling context method to get the marshaller        //  instance        mb.loadContext();        genLoadSlot(mb);        mb.appendLoadConstant(m_targetClass.getName());        mb.appendCallInterface(GETMARSHALLER_METHOD, GETMARSHALLER_SIGNATURE);                // check for an abstract mapping being used        if (m_isAbstract) {                        // make sure returned marshaller implements required interface            mb.appendCreateCast(ABSTRACTMARSHALLER_INTERFACE);                    // swap to reorder object and marshaller            mb.appendSWAP();                    // call indirect marshaller for abstract base class with the object            //  itself and context as arguments            mb.loadContext();            mb.appendCallInterface(ABSTRACTMARSHAL_METHOD,                ABSTRACTMARSHAL_SIGNATURE);                        } else {                    // swap to reorder object and marshaller            mb.appendSWAP();                    // call the direct marshaller with the object itself and context as            //  arguments            mb.loadContext();            mb.appendCallInterface(MARSHALLER_MARSHAL_METHOD,                MARSHALLER_MARSHAL_SIGNATURE);        }    }    /**     * Get target class for mapping.     *     * @return target class information     */    public ClassFile getTargetClass() {        return m_targetClass;    }    /**     * Get marshaller class used for mapping. If a name has been supplied the     * actual marshaller class is created by extending the base class the first     * time this method is called.     *     * @return marshaller class information     * @throws JiBXException if error in transformation     */    public ClassFile getMarshaller() throws JiBXException {        if (m_marshaller == null && m_marshallerBase != null) {            createSubclass(true);        }        return m_marshaller;    }    /**     * Get unmarshaller class used for mapping. If a name has been supplied the     * actual unmarshaller class is created by extending the base class the     * first time this method is called.     *     * @return unmarshaller class information     * @throws JiBXException if error in transformation     */    public ClassFile getUnmarshaller() throws JiBXException {        if (m_unmarshaller == null && m_unmarshallerBase != null) {            createSubclass(false);        }        return m_unmarshaller;    }        //    // IComponent interface method definitions    public boolean isOptional() {        return false;    }    public boolean hasAttribute() {        return false;    }    public void genAttrPresentTest(ContextMethodBuilder mb) {        throw new IllegalStateException            ("Internal error - no attributes defined");    }    public void genAttributeUnmarshal(ContextMethodBuilder mb) {        throw new IllegalStateException            ("Internal error - no attributes defined");    }    public void genAttributeMarshal(ContextMethodBuilder mb) {        throw new IllegalStateException            ("Internal error - no attributes defined");    }    public boolean hasContent() {        return true;    }    public void genContentPresentTest(ContextMethodBuilder mb)        throws JiBXException {        genTestPresent(mb);    }    public void genContentUnmarshal(ContextMethodBuilder mb)        throws JiBXException {        genUnmarshal(mb);    }    public void genContentMarshal(ContextMethodBuilder mb)        throws JiBXException {        genMarshal(mb);    }        public void genNewInstance(ContextMethodBuilder mb) {        throw new IllegalStateException            ("Internal error - no instance creation");    }    public String getType() {        return m_targetClass.getFile().getName();    }    public boolean hasId() {        return false;    }    public void genLoadId(ContextMethodBuilder mb) {        throw new IllegalStateException("Internal error - no ID allowed");    }        public NameDefinition getWrapperName() {        return m_name;    }    public void setLinkages() throws JiBXException {        if (m_name != null) {            m_name.fixNamespace(m_defContext);        }    }        // DEBUG    public void print(int depth) {        BindingDefinition.indent(depth);        System.out.println("direct marshaller/unmarshaller reference" );    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -