📄 parser.java
字号:
package org.abeesoft.fsmgenerator.parser.xml;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import org.abeesoft.fsmgenerator.configuration.Configuration;
import org.abeesoft.fsmgenerator.exception.Exception;
import org.abeesoft.fsmgenerator.specification.Specification;
public class Parser extends org.abeesoft.fsmgenerator.parser.Parser
{
private static final String FORMAT = "xml";
/**
* @param configuration
* @param specification
*/
public Parser( Configuration configuration )
{
super( configuration, FORMAT );
}
public Specification parse() throws Exception
{
if( configuration == null )
throw new Exception();
if( configuration.getSpecification().getFile() == null )
throw new Exception();
if( !configuration.getSpecification().getFormat().equals(getFormat()) )
throw new Exception();
Specification specification = null;
try
{
JAXBContext jc = JAXBContext.newInstance("org.abeesoft.fsmgenerator.specification");
Unmarshaller u = jc.createUnmarshaller();
specification = (Specification)u.unmarshal(new FileInputStream(configuration.getSpecification().getFile()));
}
catch ( JAXBException e )
{
throw new Exception(e);
}
catch ( FileNotFoundException e )
{
throw new Exception(e);
}
return specification;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -