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

📄 abstractxercesregpopulator.java

📁 JavaPOS的最新版本!这是源代码!零售业的请看!
💻 JAVA
📖 第 1 页 / 共 2 页
字号:

        document.getDocumentElement().
        insertBefore( comment, document.getDocumentElement().getFirstChild() );

        document.getDocumentElement().
        insertBefore(  document.createTextNode( "\n" ), comment );
        
        document.getDocumentElement().
        appendChild( document.createTextNode( "\n" ) );
    }
    
    /**
     * Appends the <creation> element to the document
     * @param doc the XML Document object
     * @param jposEntryElement the <JposEntryElement> XML Element object
     * @param jposEntry the JposEntry object
     * @since 1.2 (NY 2K meeting)
     */
    protected void appendCreationElement( Document doc, 
    										Element jposEntryElement,
                                            JposEntry jposEntry )
    {
        jposEntryElement.appendChild( doc.createTextNode( "    " + "    " ) );

        Element creationElement = doc.createElement( "creation" );

        Attr factoryClassAttr = doc.createAttribute( "factoryClass" );
        Attr serviceClassAttr = doc.createAttribute( "serviceClass" );

        factoryClassAttr.setValue( (String)jposEntry.
        						   getPropertyValue( "serviceInstanceFactoryClass" ) );

        serviceClassAttr.setValue( (String)jposEntry.
        						   getPropertyValue( "serviceClass" ) );

        creationElement.setAttributeNode( factoryClassAttr );
        creationElement.setAttributeNode( serviceClassAttr );

        jposEntryElement.appendChild( creationElement );
        jposEntryElement.appendChild( doc.createTextNode( "\n" ) );
    }

    /**
     * Appends the <vendor> element to the document
     * @param doc the XML Document object
     * @param jposEntryElement the <JposEntryElement> XML Element object
     * @param jposEntry the JposEntry object
     * @since 1.2 (NY 2K meeting)
     */
    protected void appendVendorElement( Document doc, Element jposEntryElement,
                                        JposEntry jposEntry )
    {
        jposEntryElement.appendChild( doc.createTextNode( "    " + "    " ) );

        Element vendorElement = doc.createElement( "vendor" );

        Attr nameAttr = doc.createAttribute( "name" );
        Attr urlAttr = doc.createAttribute( "url" );

        nameAttr.setValue( (String)jposEntry.getPropertyValue( "vendorName" ) );
        urlAttr.setValue( (String)jposEntry.getPropertyValue( "vendorURL" ) );

        vendorElement.setAttributeNode( nameAttr );
        vendorElement.setAttributeNode( urlAttr );

        jposEntryElement.appendChild( vendorElement );
        jposEntryElement.appendChild( doc.createTextNode( "\n" ) );
    }

    /**
     * Appends the <jpos> element to the document
     * @param doc the XML Document object
     * @param jposEntryElement the <JposEntryElement> XML Element object
     * @param jposEntry the JposEntry object
     * @since 1.2 (NY 2K meeting)
     */
    protected void appendJposElement( Document doc, Element jposEntryElement,
                                      JposEntry jposEntry )
    {
        jposEntryElement.appendChild( doc.createTextNode( "    " + "    " ) );

        Element jposElement = doc.createElement( "jpos" );

        Attr versionAttr = doc.createAttribute( "version" );
        Attr categoryAttr = doc.createAttribute( "category" );

        versionAttr.setValue( (String)jposEntry.
        					   getPropertyValue( "jposVersion" ) );
        
        categoryAttr.setValue( (String)jposEntry.
        						getPropertyValue( "deviceCategory" ) );

        jposElement.setAttributeNode( versionAttr );
        jposElement.setAttributeNode( categoryAttr );

        jposEntryElement.appendChild( jposElement );
        jposEntryElement.appendChild( doc.createTextNode( "\n" ) );
    }

    /**
     * Appends the <product> element to the document
     * @param doc the XML Document object
     * @param jposEntryElement the <JposEntryElement> XML Element object
     * @param jposEntry the JposEntry object
     * @since 1.2 (NY 2K meeting)
     */
    protected void appendProductElement( Document doc, 
                      					   Element jposEntryElement,
                                           JposEntry jposEntry )
    {
        jposEntryElement.appendChild( doc.createTextNode( "    " + "    " ) );

        Element productElement = doc.createElement( "product" );

        Attr nameAttr = doc.createAttribute( "name" );
        Attr descriptionAttr = doc.createAttribute( "description" );
        Attr urlAttr = doc.createAttribute( "url" );

        nameAttr.setValue( (String)jposEntry.getPropertyValue( "productName" ) );
        
        descriptionAttr.
        setValue( (String)jposEntry.getPropertyValue( "productDescription" ) );
        
        urlAttr.setValue( (String)jposEntry.getPropertyValue( "productURL" ) );

        productElement.setAttributeNode( nameAttr );
        productElement.setAttributeNode( descriptionAttr );
        productElement.setAttributeNode( urlAttr );

        jposEntryElement.appendChild( productElement );
        jposEntryElement.appendChild( doc.createTextNode( "\n" ) );
    }

    /**
     * Appends the <prop> element to the document
     * @param doc the XML Document object
     * @param jposEntryElement the <JposEntryElement> XML Element object
     * @param propName the property name
     * @param propValue the property value
     * @since 1.2 (NY 2K meeting)
     */
    protected void appendPropElement( Document doc, Element jposEntryElement,
                                      String propName, Object propValue )
    {
        jposEntryElement.appendChild( doc.createTextNode( "    " + "    " ) );

        Element propElement = doc.createElement( "prop" );

        Attr nameAttr = doc.createAttribute( "name" );
        Attr valueAttr = doc.createAttribute( "value" );
        Attr typeAttr = doc.createAttribute( "type" );

        nameAttr.setValue( propName );
        valueAttr.setValue( propValue.toString() );
        typeAttr.setValue( JposEntryUtility.
                           shortClassName( propValue.getClass() ) );

        propElement.setAttributeNode( nameAttr );
        propElement.setAttributeNode( valueAttr );
        propElement.setAttributeNode( typeAttr );

        jposEntryElement.appendChild( propElement );
        jposEntryElement.appendChild( doc.createTextNode( "\n" ) );
    }

    /**
     * Appends non-required properties name and value
     * @param doc the XML Document object
     * @param jposEntryElement the <JposEntryElement> XML Element object
     * @param jposEntry the JposEntry object
     * @since 1.2 (NY 2K meeting)
     */
    protected void appendPropElements( Document doc, Element jposEntryElement,
                                         JposEntry jposEntry )
    {
        jposEntryElement.appendChild( doc.
        				 createTextNode( "\n" + "    " + "    " ) );

		String comment = "Other non JavaPOS required property" +
						 " (mostly vendor properties and bus specific " + 
						 "properties i.e. RS232 )";
        
        jposEntryElement.appendChild( doc.createComment( comment ) );
        
        jposEntryElement.appendChild( doc.createTextNode( "\n" ) );

        Enumeration props = jposEntry.getPropertyNames();

        while( props.hasMoreElements() )
        {
            String propName = (String)props.nextElement();

            if( !JposEntryUtility.isRequiredPropName( propName ) )
                appendPropElement( doc, jposEntryElement, propName, 
                				   jposEntry.getPropertyValue( propName ) );
        }
    }

    /**
     * Insert the <JposEntryElement> in the XML document object
     * @param doc the XML Document object
     * @param jposEntryElement the <JposEntryElement> XML Element object
     * @param jposEntry the JposEntry object
     * @since 1.2 (NY 2K meeting)
     */
    protected void insertJposEntryInDoc( Document doc, Element jposEntryElement,
                                         JposEntry jposEntry )
    {
        appendCreationElement( doc, jposEntryElement, jposEntry );
        appendVendorElement( doc, jposEntryElement, jposEntry );
        appendJposElement( doc, jposEntryElement, jposEntry );
        appendProductElement( doc, jposEntryElement, jposEntry );
        appendPropElements( doc, jposEntryElement, jposEntry );

        doc.getDocumentElement().
        	appendChild( doc.createTextNode( "\n" + "    " ) );
        doc.getDocumentElement().
        	appendChild( jposEntryElement );
        doc.getDocumentElement().
        	appendChild( doc.createTextNode( "\n" + "    " ) );
    }

    /**
     * Insert an Enumeration of <JposEntryElement> objects in the XML document
     * @param doc the XML Document object
     * @param entries an Enumeration of JposEntry objects
     * @since 1.2 (NY 2K meeting)
     */
    protected void insertJposEntriesInDoc( Document doc, Enumeration entries )
    {
        while( entries.hasMoreElements() )
        {
            JposEntry jposEntry = (JposEntry)entries.nextElement();

            if( JposEntryUtility.isValidJposEntry( jposEntry ) )
            {
                doc.getDocumentElement().
                    appendChild( doc.createTextNode( "\n" + "    " ) );

                Element jposEntryElement = doc.createElement( "JposEntry" );

                Attr logicalNameAttr = doc.createAttribute( "logicalName" );
                logicalNameAttr.setValue( (String)jposEntry.
                                          getPropertyValue( "logicalName" ) );

                jposEntryElement.setAttributeNode( logicalNameAttr ); 

                jposEntryElement.appendChild( doc.createTextNode( "\n" ) );

                insertJposEntryInDoc( doc, jposEntryElement, jposEntry );
            }
        }
    }

    //--------------------------------------------------------------------------
    // Instance variables
    //

	protected String xmlFileName = DEFAULT_XML_FILE_NAME;
	
    protected DOMParser domParser = new DOMParser();

	private Tracer tracer = TracerFactory.getInstance().
						     createTracer( "AbstractXercesRegPopulator" );
    
    //--------------------------------------------------------------------------
    // Public constants
    //

    public static final String DTD_FILE_PATH = "jpos" + File.separator + "res";
    public static final String DTD_FILE_NAME = DTD_FILE_PATH + File.separator + "jcl.dtd";
}

⌨️ 快捷键说明

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