当前位置: 首页>>代码示例>>Java>>正文


Java ConversionException.getMessage方法代码示例

本文整理汇总了Java中com.thoughtworks.xstream.converters.ConversionException.getMessage方法的典型用法代码示例。如果您正苦于以下问题:Java ConversionException.getMessage方法的具体用法?Java ConversionException.getMessage怎么用?Java ConversionException.getMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.thoughtworks.xstream.converters.ConversionException的用法示例。


在下文中一共展示了ConversionException.getMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testIgnoreUnknownElementsMatchingPattern

import com.thoughtworks.xstream.converters.ConversionException; //导入方法依赖的package包/类
public void testIgnoreUnknownElementsMatchingPattern() {
    String actualXml = ""
        + "<thing>\n"
        + "  <sometimesIgnore>foo</sometimesIgnore>\n" 
        + "  <neverIgnore>c</neverIgnore>\n" 
        + "  <foobar>f</foobar>\n" 
        + "  <derived>d</derived>\n" 
        + "</thing>";

    xstream.alias("thing", DerivedThing.class);
    xstream.omitField(Thing.class, "sometimesIgnore");
    xstream.ignoreUnknownElements("foo.*");

    DerivedThing out = (DerivedThing)xstream.fromXML(actualXml);
    assertEquals(null, out.alwaysIgnore);
    assertEquals(null, out.sometimesIgnore);
    assertEquals("c", out.neverIgnore);
    assertEquals("d", out.derived);
    
    try {
        xstream.fromXML(actualXml.replaceAll("foobar", "unknown"));
        fail("Thrown " + ConversionException.class.getName() + " expected");
    } catch (final ConversionException e) {
        String message = e.getMessage();
        assertTrue(message,
            e.getMessage().substring(0, message.indexOf('\n')).endsWith(
                DerivedThing.class.getName() + ".unknown"));
    }
}
 
开发者ID:x-stream,项目名称:xstream,代码行数:30,代码来源:OmitFieldsTest.java

示例2: readXMLObject

import com.thoughtworks.xstream.converters.ConversionException; //导入方法依赖的package包/类
/**
     *
     *
     * @param filename
     * @param doValidate the value of doValidate
     * @return
     * @throws FileNotFoundException
     * @throws ETException
     * @throws BadOrMissingXMLSchemaException
     */
    public Object readXMLObject(String filename, boolean doValidate)
            throws FileNotFoundException, ETException, BadOrMissingXMLSchemaException {
        PhysicalConstants myPhysicalConstants = null;

        BufferedReader reader = URIHelper.getBufferedReader(filename);

        if (reader != null) {
            boolean temp = false;
            XStream xstream = getXStreamReader();

            temp = URIHelper.validateXML(reader, filename, physicalConstantsXMLSchemaURL);

            if (temp) {
                // re-create reader
                reader = URIHelper.getBufferedReader(filename);
                try {
                    myPhysicalConstants = (PhysicalConstants) xstream.fromXML(reader);
                } catch (ConversionException e) {
                    throw new ETException(null, e.getMessage());
                }

//                System.out.println("This is your PhysicalConstants that was just read successfully:\n");

//                String xml2 = getXStreamWriter().toXML(myPhysicalConstants);
//
//                System.out.println(xml2);
//                System.out.flush();
            } else {
                throw new ETException(null, "Badly formed PhysicalConstants XML data file.");
            }
        } else {
            throw new FileNotFoundException("Missing XML data file.");
        }

        return myPhysicalConstants;
    }
 
开发者ID:CIRDLES,项目名称:ET_Redux,代码行数:47,代码来源:PhysicalConstants.java

示例3: readXMLObject

import com.thoughtworks.xstream.converters.ConversionException; //导入方法依赖的package包/类
/**
 *
 * @param filename
 * @param doValidate
 * @return
 * @throws FileNotFoundException
 * @throws ETException
 * @throws BadOrMissingXMLSchemaException
 */
@Override
public Object readXMLObject(String filename, boolean doValidate)
        throws FileNotFoundException,
        ETException,
        FileNotFoundException,
        BadOrMissingXMLSchemaException {

    AliquotInterface myAliquot = null;

    BufferedReader reader = URIHelper.getBufferedReader(filename);

    if (reader != null) {
        boolean isValidOrAirplaneMode = true;

        XStream xstream = getXStreamReader();

        if (doValidate) {
            isValidOrAirplaneMode = URIHelper.validateXML(reader, filename, aliquotUThXMLSchemaURL);
        }

        if (isValidOrAirplaneMode) {
            // re-create reader
            reader = URIHelper.getBufferedReader(filename);
            try {
                myAliquot = (AliquotInterface) xstream.fromXML(reader);
            } catch (ConversionException e) {
                throw new ETException(null, e.getMessage());
            }
        } else {
            throw new ETException(null, "XML data file does not conform to schema.");
        }
    } else {
        throw new FileNotFoundException("Missing XML data file.");
    }

    return myAliquot;
}
 
开发者ID:CIRDLES,项目名称:ET_Redux,代码行数:47,代码来源:UThReduxAliquot.java

示例4: readXMLObject

import com.thoughtworks.xstream.converters.ConversionException; //导入方法依赖的package包/类
/**
     * decodes <code>PbBlank</code> from <code>file</code> specified by argument
     * <code>filename</code>
     *
     * @param filename location to read data from
     * @param doValidate the value of doValidate
     * @return <code>Object</code> - the <code>PbBlank</code> created from the
     * specified XML <code>file</code>
     * @throws java.io.FileNotFoundException
     * @throws org.earthtime.XMLExceptions.BadOrMissingXMLSchemaException @pre
     * <code>filename</code> references an XML <code>file</code> @post
     * <code>PbBlank</code> stored in <code>filename</code> is returned
     */
    public Object readXMLObject(String filename, boolean doValidate)
            throws FileNotFoundException, ETException, FileNotFoundException, BadOrMissingXMLSchemaException {
        PbBlank retPbBlank = null;

        BufferedReader reader = URIHelper.getBufferedReader(filename);

        if (reader != null) {
            boolean validXML = true;
            XStream xstream = getXStreamReader();

            if (doValidate) {
                validXML = URIHelper.validateXML(reader, filename, PbBlankXMLSchemaURL);
            }

            if (validXML) {

                // re-create reader
                reader = URIHelper.getBufferedReader(filename);
                try {
                    retPbBlank = (PbBlank) xstream.fromXML(reader);
                } catch (ConversionException e) {
                    throw new ETException(null, e.getMessage());
                }

//                System.out.println( "This is your PbBlank that was just read successfully:\n" );
//                String xml2 = getXStreamWriter().toXML( retPbBlank );
//
//                System.out.println( xml2 );
//                System.out.flush();
            }

        } else {
            throw new FileNotFoundException("Badly formed or missing XML data file.");
        }

        return retPbBlank;
    }
 
开发者ID:CIRDLES,项目名称:ET_Redux,代码行数:51,代码来源:PbBlank.java

示例5: readXMLObject

import com.thoughtworks.xstream.converters.ConversionException; //导入方法依赖的package包/类
/**
 *
 *
 * @param filename
 * @param doValidate the value of doValidate
 * @return
 * @throws FileNotFoundException
 * @throws ETException
 * @throws BadOrMissingXMLSchemaException
 */
@Override
public Object readXMLObject(String filename, boolean doValidate)
        throws FileNotFoundException,
        ETException,
        FileNotFoundException,
        BadOrMissingXMLSchemaException {

    MineralStandardModel myMineralStandardModel = null;

    BufferedReader reader = URIHelper.getBufferedReader(filename);

    if (reader != null) {
        boolean temp = true;
        XStream xstream = getXStreamReader();

        if (doValidate) {
            temp = URIHelper.validateXML(reader, filename, mineralStandardModelXMLSchemaURL);
        }

        if (temp) {
            // re-create reader
            reader = URIHelper.getBufferedReader(filename);
            try {
                myMineralStandardModel = (MineralStandardModel) xstream.fromXML(reader);
            } catch (ConversionException e) {
                throw new ETException(null, e.getMessage());
            }

        } else {
            throw new FileNotFoundException("Badly formed or unvalidated XML data file.");
        }

    } else {
        throw new FileNotFoundException("Missing XML data file.");
    }

    return myMineralStandardModel;
}
 
开发者ID:CIRDLES,项目名称:ET_Redux,代码行数:49,代码来源:MineralStandardModel.java

示例6: readXMLObject

import com.thoughtworks.xstream.converters.ConversionException; //导入方法依赖的package包/类
/**
     * decodes <code>MeasuredRatioModel</code> from <code>file</code> specified
     * by argument <code>filename</code>
     *
     * @param filename location to read data from
     * @param doValidate the value of doValidate
     * @return <code>Object</code> - the <code>MeasuredRatioModel</code> created
     * from the specified XML <code>file</code>
     * @throws java.io.FileNotFoundException
     * @throws org.earthtime.XMLExceptions.BadOrMissingXMLSchemaException
     * @pre <code>filename</code> references an XML <code>file</code>
     * @post <code>MeasuredRatioModel</code> stored in <code>filename</code> is
     * returned
     */
    @Override
    public Object readXMLObject(String filename, boolean doValidate)
            throws FileNotFoundException, ETException, FileNotFoundException, BadOrMissingXMLSchemaException {
        ValueModel myValueModel = null;

        BufferedReader reader = URIHelper.getBufferedReader(filename);

        if (reader != null) {
            boolean isValidOrAirplaneMode = true;
            XStream xstream = getXStreamReader();

            if (doValidate) {
                isValidOrAirplaneMode = URIHelper.validateXML(reader, filename, getValueModelXMLSchemaURL());
            }

            if (isValidOrAirplaneMode) {
                // re-create reader
                reader = URIHelper.getBufferedReader(filename);
                try {
                    myValueModel = (MeasuredRatioModel) xstream.fromXML(reader);
                } catch (ConversionException e) {
                    throw new ETException(null, e.getMessage());
                }

////                System.out.println( "\nThis is your MeasuredRatioModel that was just read successfully:\n" );
//                String xml2 = getXStreamWriter().toXML( myValueModel );
//
//                System.out.println( xml2 );
//                System.out.flush();
            } else {
                throw new ETException(null, "XML data file does not conform to schema.");
            }
        } else {
            throw new FileNotFoundException("Missing XML data file.");
        }

        return myValueModel;
    }
 
开发者ID:CIRDLES,项目名称:ET_Redux,代码行数:53,代码来源:MeasuredRatioModel.java

示例7: readXMLObject

import com.thoughtworks.xstream.converters.ConversionException; //导入方法依赖的package包/类
/**
     * decodes <code>ValueModelReferenced</code> from <code>file</code>
     * specified by argument <code>filename</code>
     *
     * @param filename location to read data from
     * @param doValidate the value of doValidate
     * @return <code>Object</code> - the <code>ValueModelReferenced</code>
     * created from the specified XML <code>file</code>
     * @throws java.io.FileNotFoundException
     * @throws org.earthtime.XMLExceptions.BadOrMissingXMLSchemaException @pre
     * <code>filename</code> references an XML <code>file</code> @post
     * <code>ValueModelReferenced</code> stored in <code>filename</code> is
     * returned
     */
    @Override
    public Object readXMLObject(String filename, boolean doValidate)
            throws FileNotFoundException, ETException, FileNotFoundException, BadOrMissingXMLSchemaException {
        ValueModel myValueModel = null;

        BufferedReader reader = URIHelper.getBufferedReader(filename);

        if (reader != null) {
            boolean isValidOrAirplaneMode = true;

            XStream xstream = getXStreamReader();

            if (doValidate) {
                isValidOrAirplaneMode = URIHelper.validateXML(reader, filename, getValueModelXMLSchemaURL());
            }

            if (isValidOrAirplaneMode) {
                // re-create reader
                reader = URIHelper.getBufferedReader(filename);
                try {
                    myValueModel = (ValueModelReferenced) xstream.fromXML(reader);
                } catch (ConversionException e) {
                    throw new ETException(null, e.getMessage());
                }

//                System.out.println( "\nThis is your ValueModelReferenced that was just read successfully:\n" );
//                String xml2 = getXStreamWriter().toXML( myValueModel );
//
//                System.out.println( xml2 );
//                System.out.flush();
            } else {
                throw new ETException(null, "XML data file does not conform to schema.");
            }
        } else {
            throw new FileNotFoundException("Missing XML data file.");
        }
        return myValueModel;
    }
 
开发者ID:CIRDLES,项目名称:ET_Redux,代码行数:53,代码来源:ValueModelReferenced.java

示例8: readXMLObject

import com.thoughtworks.xstream.converters.ConversionException; //导入方法依赖的package包/类
@Override
public Object readXMLObject(String filename, boolean doValidate)
        throws FileNotFoundException, ETException, FileNotFoundException, BadOrMissingXMLSchemaException {
    ValueModel myValueModel = null;

    BufferedReader reader = URIHelper.getBufferedReader(filename);

    if (reader != null) {
        boolean isValidOrAirplaneMode = true;

        XStream xstream = getXStreamReader();

        if (doValidate) {
            isValidOrAirplaneMode = validateXML(filename);
        }

        if (isValidOrAirplaneMode) {
            // re-create reader
            reader = URIHelper.getBufferedReader(filename);
            try {
                myValueModel = (ValueModel) xstream.fromXML(reader);
            } catch (ConversionException e) {
                throw new ETException(null, e.getMessage());
            }

        } else {
            throw new ETException(null, "XML data file does not conform to schema.");
        }
    } else {
        throw new FileNotFoundException("Missing XML data file.");
    }

    return myValueModel;
}
 
开发者ID:CIRDLES,项目名称:ET_Redux,代码行数:35,代码来源:ValueModel.java

示例9: readXMLObject

import com.thoughtworks.xstream.converters.ConversionException; //导入方法依赖的package包/类
/**
     *
     *
     * @param filename
     * @param doValidate the value of doValidate
     * @return
     * @throws FileNotFoundException
     * @throws ETException
     * @throws BadOrMissingXMLSchemaException
     */
    public Object readXMLObject ( String filename, boolean doValidate )
            throws FileNotFoundException, ETException, FileNotFoundException, BadOrMissingXMLSchemaException {
        InitialPbModel myInitialPbModel = null;

        BufferedReader reader = URIHelper.getBufferedReader( filename );

        if ( reader != null ) {
            boolean temp = false;
            XStream xstream = getXStreamReader();

            temp = URIHelper.validateXML( reader, filename, initialPbModelXMLSchemaURL );

            if ( temp ) {
                // re-create reader
                reader = URIHelper.getBufferedReader( filename );
                try {
                    myInitialPbModel = (InitialPbModel) xstream.fromXML( reader );
                } catch (ConversionException e) {
                    throw new ETException( null, e.getMessage() );
                }

//                System.out.println( "This is your InitialPbModel that was just read successfully:\n" );
//
//                String xml2 = getXStreamWriter().toXML( myInitialPbModel );
//
//                System.out.println( xml2 );
//                System.out.flush();
            }

        } else {
            throw new FileNotFoundException( "Badly formed or missing XML data file." );
        }



        return myInitialPbModel;
    }
 
开发者ID:CIRDLES,项目名称:ET_Redux,代码行数:48,代码来源:InitialPbModel.java

示例10: readXMLObject

import com.thoughtworks.xstream.converters.ConversionException; //导入方法依赖的package包/类
/**
     * decodes
     * <code>Tracer</code> from
     * <code>file</code> specified by argument
     * <code>filename</code>
     *
     * @param filename location to read data from
     * @param doValidate the value of doValidate
     * @return
     * <code>Object</code> - the
     * <code>Tracer</code> created from the specified XML
     * <code>file</code>
     * @throws java.io.FileNotFoundException
     * @throws org.earthtime.XMLExceptions.ETException
     * @throws org.earthtime.XMLExceptions.BadOrMissingXMLSchemaException @pre
     * <code>filename</code> references an XML
     * <code>file</code> @post
     * <code>Tracer</code> stored in
     * <code>filename</code> is returned
     */
    @Override
    public Object readXMLObject ( String filename, boolean doValidate )
            throws FileNotFoundException, ETException, BadOrMissingXMLSchemaException {
        Tracer myTracer = null;

        BufferedReader reader = URIHelper.getBufferedReader( filename );

        if ( reader != null ) {
            XStream xstream = getXStreamReader();

            boolean temp = URIHelper.validateXML( reader, filename, tracerXMLSchemaURL );

            if ( temp ) {
                // re-create reader
                reader = URIHelper.getBufferedReader( filename );
                try {
                    myTracer = (Tracer) xstream.fromXML( reader );
                } catch (ConversionException e) {
                    throw new ETException( null, e.getMessage() );
                }

//                System.out.println( "This is your Tracer that was just read successfully:\n" );

//                String xml2 = getXStreamWriter().toXML( myTracer );
//
//                System.out.println( xml2 );
//                System.out.flush();

            } else {
                throw new ETException( null, "Badly formed XML data file." );
            }
        } else {
            throw new FileNotFoundException( "Missing XML data file." );
        }

        return myTracer;
    }
 
开发者ID:CIRDLES,项目名称:ET_Redux,代码行数:58,代码来源:Tracer.java

示例11: readXMLObject

import com.thoughtworks.xstream.converters.ConversionException; //导入方法依赖的package包/类
/**
 *
 * @param filename
 * @param doValidate
 * @return
 * @throws FileNotFoundException
 * @throws ETException
 * @throws BadOrMissingXMLSchemaException
 */
@Override
public Object readXMLObject(String filename, boolean doValidate)
        throws FileNotFoundException,
        ETException,
        FileNotFoundException,
        BadOrMissingXMLSchemaException {

    FractionI myUPbReduxFraction = null;

    BufferedReader reader = URIHelper.getBufferedReader(filename);

    if (reader != null) {
        boolean isValidOrAirplaneMode = true;

        XStream xstream = getXStreamReader();

        if (doValidate) {
            isValidOrAirplaneMode = URIHelper.validateXML(reader, filename, XMLSchemaURL);
        }

        if (isValidOrAirplaneMode) {
            // re-create reader
            reader = URIHelper.getBufferedReader(filename);
            try {
                myUPbReduxFraction = (FractionI) xstream.fromXML(reader);
            } catch (ConversionException e) {
                throw new ETException(null, e.getMessage());
            }
        } else {
            throw new ETException(null, "XML data file does not conform to schema.");
        }
    } else {
        throw new FileNotFoundException("Missing XML data file.");
    }

    return myUPbReduxFraction;

}
 
开发者ID:CIRDLES,项目名称:ET_Redux,代码行数:48,代码来源:UPbFraction.java

示例12: readXMLObject

import com.thoughtworks.xstream.converters.ConversionException; //导入方法依赖的package包/类
/**
 *
 * @param filename
 * @param doValidate
 * @return
 * @throws FileNotFoundException
 * @throws ETException
 * @throws BadOrMissingXMLSchemaException
 */
@Override
public Object readXMLObject(String filename, boolean doValidate)
        throws FileNotFoundException,
        ETException,
        FileNotFoundException,
        BadOrMissingXMLSchemaException {

    AliquotInterface myAliquot = null;

    BufferedReader reader = URIHelper.getBufferedReader(filename);

    if (reader != null) {
        boolean isValidOrAirplaneMode = true;

        XStream xstream = getXStreamReader();

        if (doValidate) {
            isValidOrAirplaneMode = URIHelper.validateXML(reader, filename, aliquotXMLSchemaURL);
        }

        if (isValidOrAirplaneMode) {
            // re-create reader
            reader = URIHelper.getBufferedReader(filename);
            try {
                myAliquot = (AliquotInterface) xstream.fromXML(reader);
            } catch (ConversionException e) {
                throw new ETException(null, e.getMessage());
            }
        } else {
            throw new ETException(null, "XML data file does not conform to schema.");
        }
    } else {
        throw new FileNotFoundException("Missing XML data file.");
    }

    return myAliquot;
}
 
开发者ID:CIRDLES,项目名称:ET_Redux,代码行数:47,代码来源:UPbReduxAliquot.java

示例13: readXMLObject

import com.thoughtworks.xstream.converters.ConversionException; //导入方法依赖的package包/类
/**
     * decodes <code>ValueModel</code> from <code>file</code> specified by
     * argument <code>filename</code>
     *
     * @param filename    location to read data from
     * @param doValidate the value of doValidate
     * @return <code>Object</code> - the <code>ValueModel</code> created from
     * the specified XML <code>file</code>
     * @throws java.io.FileNotFoundException
     * @throws org.earthtime.XMLExceptions.BadOrMissingXMLSchemaException
     * @pre <code>filename</code> references an XML <code>file</code>
     * @post <code>ValueModel</code> stored in <code>filename</code> is returned
     */
    public Object readXMLObject(String filename, boolean doValidate)
            throws FileNotFoundException, ETException, FileNotFoundException, BadOrMissingXMLSchemaException {
        SampleMetaData mySampleMetaData = null;

        BufferedReader reader = URIHelper.getBufferedReader(filename);

        if (reader != null) {
            boolean validXML = false;
            XStream xstream = getXStreamReader();

            validXML = true;//URIHelper.validateXML(reader, getSampleMetaDataXMLSchemaURL());

            if (validXML) {
                // re-create reader
                reader = URIHelper.getBufferedReader(filename);
                try {
                    mySampleMetaData = (SampleMetaData) xstream.fromXML(reader);
                } catch (ConversionException e) {
                    throw new ETException(null, e.getMessage());
                }

//                System.out.println("\nThis is your SampleMetaData that was just read successfully:\n");

//                String xml2 = getXStreamWriter().toXML(mySampleMetaData);
//
//                System.out.println(xml2);
//                System.out.flush();
            }

        } else {
            throw new FileNotFoundException("Badly formed or missing XML data file.");
        }



        return mySampleMetaData;
    }
 
开发者ID:CIRDLES,项目名称:ET_Redux,代码行数:51,代码来源:SampleMetaData.java

示例14: readXMLObject

import com.thoughtworks.xstream.converters.ConversionException; //导入方法依赖的package包/类
/**
     * decodes <code>SESARSampleMetadata</code> from <code>file</code> specified
     * by argument <code>filename</code>
     *
     * @param filename location to read data from
     * @param doValidate the value of doValidate
     * @return <code>Object</code> - the <code>SESARSampleMetadata</code>
     * created from the specified XML <code>file</code>
     * @throws java.io.FileNotFoundException
     * @throws org.earthtime.XMLExceptions.BadOrMissingXMLSchemaException
     * @pre <code>filename</code> references an XML <code>file</code>
     * @post <code>SESARSampleMetadata</code> stored in <code>filename</code> is
     * returned
     */
    public Object readXMLObject(String filename, boolean doValidate)
            throws FileNotFoundException, ETException, FileNotFoundException, BadOrMissingXMLSchemaException {
        SESARSampleMetadata SESARSampleMetadata = null;

        BufferedReader reader = URIHelper.getBufferedReader(filename);

        if (reader != null) {
            boolean isValidOrAirplaneMode = true;

            XStream xstream = getXStreamReader();

            if (doValidate) {
                isValidOrAirplaneMode = URIHelper.validateXML(reader, filename, SESARSampleMetadataSchemaURL);
            }

            if (isValidOrAirplaneMode) {
                // re-create reader
                reader = URIHelper.getBufferedReader(filename);
                try {
                    SESARSampleMetadata = (SESARSampleMetadata) xstream.fromXML(reader);
                } catch (ConversionException e) {
                    throw new ETException(null, e.getMessage());
                }

//                System.out.println("This is your SESARSampleMetadata that was just read successfully:\n");
//                String xml2 = getXStreamWriter().toXML(SESARSampleMetadata);
//
//                System.out.println(xml2);
//                System.out.flush();
            } else {
                throw new ETException(null, "XML data file does not conform to schema.");
            }
        } else {
            throw new FileNotFoundException("Missing XML data file.");
        }

        return SESARSampleMetadata;
    }
 
开发者ID:CIRDLES,项目名称:ET_Redux,代码行数:53,代码来源:SESARSampleMetadata.java

示例15: readXMLObject

import com.thoughtworks.xstream.converters.ConversionException; //导入方法依赖的package包/类
/**
 * decodes <code>AbstractRatiosDataModel</code> from <code>file</code>
 * specified by argument <code>filename</code>
 *
 * @throws org.earthtime.exceptions.ETException
 * @pre <code>filename</code> references an XML <code>file</code>
 * @post <code>AbstractRatiosDataModel</code> stored in
 * <code>filename</code> is returned
 *
 * @param filename location to read data from
 * @param doValidate
 * @return <code>Object</code> - the <code>AbstractRatiosDataModel</code>
 * created from the specified XML <code>file</code>
 * @throws java.io.FileNotFoundException
 * @throws org.earthtime.XMLExceptions.BadOrMissingXMLSchemaException
 */
@Override
public AbstractRatiosDataModel readXMLObject(String filename, boolean doValidate)
        throws FileNotFoundException, ETException, BadOrMissingXMLSchemaException {
    AbstractRatiosDataModel myModelClassInstance = null;

    BufferedReader reader = URIHelper.getBufferedReader(filename);

    if (reader != null) {
        XStream xstream = getXStream();

        boolean isValidOrAirplaneMode = true;

        if (doValidate) {
            isValidOrAirplaneMode = URIHelper.validateXML(reader, filename, XMLSchemaURL);
        }

        if (isValidOrAirplaneMode) {
            // re-create reader
            reader = URIHelper.getBufferedReader(filename);
            try {
                myModelClassInstance = (AbstractRatiosDataModel) xstream.fromXML(reader);
                myModelClassInstance.initializeModel();
            } catch (ConversionException e) {
                throw new ETException(null, e.getMessage());
            }

        } else {
            throw new ETException(null, "XML data file does not conform to schema.");
        }
    } else {
        throw new FileNotFoundException("Missing XML data file.");
    }

    return myModelClassInstance;
}
 
开发者ID:CIRDLES,项目名称:ET_Redux,代码行数:52,代码来源:AbstractRatiosDataModel.java


注:本文中的com.thoughtworks.xstream.converters.ConversionException.getMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。