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

📄 abstractmodelreader.java

📁 这是一个segy数据显示程序
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            }            else if (qName.equals(ClassModelTags.MAPPING_TAG)) {                setState(MAPPING_STATE);                final String typeAttr = attributes.getValue(ClassModelTags.TYPE_ATTR);                final String baseClass = attributes.getValue(ClassModelTags.BASE_CLASS_ATTR);                startMultiplexMapping(baseClass, typeAttr);            }        }        /**         * Returns the current state.         *         * @return the state.         */        private int getState() {            return this.state;        }        /**         * Sets the current state.         *         * @param state  the state.         */        private void setState(final int state) {            this.state = state;        }    }    /** The comment handler. */    private CommentHandler commentHandler;        /** The close comments. */    private String[] closeComment;        /** The open comments. */    private String[] openComment;    /**     * Default Constructor.     */    public AbstractModelReader() {        this.commentHandler = new CommentHandler();    }    /**     * Returns the comment handler.     *      * @return The comment handler.     */    private CommentHandler getCommentHandler() {        return this.commentHandler;    }    /**     * Returns the close comment.      *      * @return The close comment.     */    protected String[] getCloseComment() {        return this.closeComment;    }    /**     * Returns the open comment.      *      * @return The open comment.     */    protected String[] getOpenComment() {        return this.openComment;    }    /**     * Sets the close comment.     *      * @param closeComment  the close comment.     */    protected void setCloseComment(final String[] closeComment) {        this.closeComment = closeComment;    }    /**     * Sets the open comment.     *      * @param openComment  the open comment.     */    protected void setOpenComment(final String[] openComment) {        this.openComment = openComment;    }    /**     * Parses an XML document at the given URL.     *      * @param resource  the document URL.     *      * @throws ObjectDescriptionException ??     */    protected void parseXml(final URL resource) throws ObjectDescriptionException {        parseXmlDocument(resource, false);    }    /**     * Parses the given specification and loads all includes specified in the files.     * This implementation does not check for loops in the include files.     *     * @param resource  the url of the xml specification.     * @param isInclude  an include?     *      * @throws org.jfree.xml.util.ObjectDescriptionException if an error occured which prevented the     * loading of the specifications.     */    protected void parseXmlDocument(final URL resource, final boolean isInclude)        throws ObjectDescriptionException {                try {            final InputStream in = new BufferedInputStream(resource.openStream());            final SAXParserFactory factory = SAXParserFactory.newInstance();            final SAXParser saxParser = factory.newSAXParser();            final XMLReader reader = saxParser.getXMLReader();            final SAXModelHandler handler = new SAXModelHandler(resource, isInclude);            try {                reader.setProperty                    ("http://xml.org/sax/properties/lexical-handler",                        getCommentHandler());            }            catch (SAXException se) {                Log.debug("Comments are not supported by this SAX implementation.");            }            reader.setContentHandler(handler);            reader.setDTDHandler(handler);            reader.setErrorHandler(handler);            reader.parse(new InputSource(in));            in.close();        }        catch (Exception e) {            // unable to init            Log.warn("Unable to load factory specifications", e);            throw new ObjectDescriptionException("Unable to load object factory specs.", e);        }    }    /**     * Start the root document.     */    protected void startRootDocument() {        // nothing required    }    /**     * End the root document.     */    protected void endRootDocument() {        // nothing required    }    /**     * Start handling an include.     *      * @param resource  the URL.     */    protected void startIncludeHandling(final URL resource) {        // nothing required    }    /**     * End handling an include.     */    protected void endIncludeHandling() {        // nothing required    }    /**     * Callback method for ignored properties. Such properties get marked so that     * the information regarding these properties won't get lost.     *     * @param name the name of the ignored property.     */    protected void handleIgnoredProperty(final String name) {        // nothing required    }    /**     * Handles a manual mapping definition. The manual mapping maps specific     * read and write handlers to a given base class. Manual mappings always     * override any other definition.     *     * @param className the base class name     * @param readHandler the class name of the read handler     * @param writeHandler the class name of the write handler     * @return true, if the mapping was accepted, false otherwise.     * @throws ObjectDescriptionException if an unexpected error occured.     */    protected abstract boolean handleManualMapping(String className, String readHandler,         String writeHandler) throws ObjectDescriptionException;    /**     * Starts a object definition. The object definition collects all properties of     * an bean-class and defines, which constructor should be used when creating the     * class.     *     * @param className the class name of the defined object     * @param register the (optional) register name, to lookup and reference the object     * later.     * @param ignored  ??.     *      * @return true, if the definition was accepted, false otherwise.     * @throws ObjectDescriptionException if an unexpected error occured.     */    protected abstract boolean startObjectDefinition(String className, String register,        boolean ignored) throws ObjectDescriptionException;    /**     * Handles an attribute definition. This method gets called after the object definition     * was started. The method will be called for every defined attribute property.     *     * @param name the name of the property     * @param attribName the xml-attribute name to use later.     * @param handlerClass the attribute handler class.     * @throws ObjectDescriptionException if an error occured.     */    protected abstract void handleAttributeDefinition(String name, String attribName,                                                      String handlerClass)        throws ObjectDescriptionException;    /**     * Handles an element definition. This method gets called after the object definition     * was started. The method will be called for every defined element property. Element     * properties are used to describe complex objects.     *     * @param name the name of the property     * @param element the xml-tag name for the child element.     * @throws ObjectDescriptionException if an error occurs.     */    protected abstract void handleElementDefinition(String name, String element)         throws ObjectDescriptionException;    /**     * Handles an lookup definition. This method gets called after the object definition     * was started. The method will be called for every defined lookup property. Lookup properties     * reference previously created object using the object's registry name.     *     * @param name the property name of the base object     * @param lookupKey the register key of the referenced object     * @throws ObjectDescriptionException if an error occured.     */    protected abstract void handleLookupDefinition(String name, String lookupKey)         throws ObjectDescriptionException;    /**     * Finializes the object definition.     *     * @throws ObjectDescriptionException if an error occures.     */    protected abstract void endObjectDefinition() throws ObjectDescriptionException;    /**     * Starts a multiplex mapping. Multiplex mappings are used to define polymorphic     * argument handlers. The mapper will collect all derived classes of the given     * base class and will select the corresponding mapping based on the given type     * attribute.     *     * @param className the base class name     * @param typeAttr the xml-attribute name containing the mapping key     */    protected abstract void startMultiplexMapping(String className, String typeAttr);    /**     * Defines an entry for the multiplex mapping. The new entry will be activated     * when the base mappers type attribute contains this <code>typename</code> and     * will resolve to the handler for the given classname.     *     * @param typeName the type value for this mapping.     * @param className the class name to which this mapping resolves.     * @throws ObjectDescriptionException if an error occurs.     */    protected abstract void handleMultiplexMapping(String typeName, String className)         throws ObjectDescriptionException;    /**     * Finializes the multiplexer mapping.     *     * @throws ObjectDescriptionException if an error occurs.     */    protected abstract void endMultiplexMapping() throws ObjectDescriptionException;    /**     * Handles a constructor definition. Only one constructor can be defined for     * a certain object type. The constructor will be filled using the given properties.     *     * @param propertyName the property name of the referenced local property     * @param parameterClass the parameter class for the parameter.     * @throws ObjectDescriptionException if an error occured.     */    protected abstract void handleConstructorDefinition(String propertyName, String parameterClass)        throws ObjectDescriptionException;    /**     * Loads the given class, and ignores all exceptions which may occur     * during the loading. If the class was invalid, null is returned instead.     *     * @param className the name of the class to be loaded.     * @return the class or null.     */    protected Class loadClass(final String className) {        if (className == null) {            return null;        }        if (className.startsWith("::")) {            return BasicTypeSupport.getClassRepresentation(className);        }        try {            return this.getClass().getClassLoader().loadClass(className);        }        catch (Exception e) {            // ignore buggy classes for now ..            Log.warn("Unable to load class", e);            return null;        }    }}

⌨️ 快捷键说明

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