Package org.jboss.forge.roaster
Class Roaster
java.lang.Object
org.jboss.forge.roaster.Roaster
Responsible for parsing data into new
JavaType instances.- Author:
- Lincoln Baxter, III
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends JavaSource<?>>
TCreate a new emptyJavaSourceinstance.static StringFormat the givenStringas a Java source file, using the built in code format style.static Stringformat(Properties properties, String source) Format the givenStringas a Java source type, using the given code formatPropertiesstatic JavaType<?>parse(char[] data) Parse the given character array into a newJavaTypeinstance.static JavaType<?>static JavaType<?>parse(InputStream stream) Read the givenInputStreamand parse the data into a newJavaTypeinstance.static <T extends JavaType<?>>
TRead the given character array and parse its data into a newJavaTypeinstance of the given type.static <T extends JavaType<?>>
Tstatic <T extends JavaType<?>>
Tparse(Class<T> type, InputStream stream) Read the givenInputStreamand parse its data into a newJavaTypeinstance of the given type.static <T extends JavaType<?>>
TRead the given string and parse its data into a newJavaTypeinstance of the given type.static <T extends JavaType<?>>
Tstatic JavaType<?>Parse the given String data into a newJavaTypeinstance.static JavaType<?>static JavaUnitparseUnit(InputStream data) Read the givenInputStreamand parse its data into a newJavaUnitinstance of the given type.static JavaUnitvalidateSnippet(String snippet)
-
Method Details
-
create
Create a new emptyJavaSourceinstance.- Type Parameters:
T- the java type- Parameters:
type- the type of the source- Returns:
- a new
JavaTypeinstance of the given type - Throws:
IllegalStateException- if no parser is available in the classPathParserException- if no parser is capable of parsing the provided data
-
parse
- Parameters:
file- the file to read from- Returns:
- a the new
JavaTypeinstance - Throws:
IOException- if the reading of the file failsParserException- if no parser is capable of parsing the provided dataIllegalStateException- if no parser is available in the classPath
-
parse
- Parameters:
url- the url to read from- Returns:
- a the new
JavaTypeinstance - Throws:
IOException- if the reading failsParserException- if no parser is capable of parsing the provided dataIllegalStateException- if no parser is available in the classPath
-
parse
Read the givenInputStreamand parse the data into a newJavaTypeinstance. The caller is responsible to close the stream.- Parameters:
stream- the stream to read from- Returns:
- a new
JavaTypeinstance - Throws:
ParserException- if no parser is capable of parsing the provided dataIllegalStateException- if no parser is available in the classPath
-
parse
Parse the given character array into a newJavaTypeinstance.- Parameters:
data- the characters to parse- Returns:
- a the new
JavaTypeinstance - Throws:
ParserException- if no parser is capable of parsing the provided dataIllegalStateException- if no parser is available in the classPath
-
parse
Parse the given String data into a newJavaTypeinstance.- Parameters:
data- the data to parse- Returns:
- the new
JavaTypeinstance - Throws:
ParserException- if no parser is capable of parsing the provided dataIllegalStateException- if no parser is available in the classPath
-
parse
- Type Parameters:
T- the java type- Parameters:
type- the type of the sourceurl- the url to read from- Returns:
- a new
JavaTypeinstance of the given type - Throws:
IOException- if a exception occurs while readingParserException- if no parser is capable of parsing the provided dataIllegalStateException- if no parser is available in the classPath
-
parse
public static <T extends JavaType<?>> T parse(Class<T> type, File file) throws FileNotFoundException, IOException - Type Parameters:
T- the java type- Parameters:
type- the type of the sourcefile- the file to read from- Returns:
- a new
JavaTypeinstance of the given type - Throws:
IOException- if a exception occurs while readingFileNotFoundException- if the file doesn't existsParserException- if no parser is capable of parsing the provided dataIllegalStateException- if no parser is available in the classPath
-
parse
Read the given character array and parse its data into a newJavaTypeinstance of the given type.- Type Parameters:
T- the java type- Parameters:
type- the type of the sourcedata- the characters to parse- Returns:
- a new
JavaTypeinstance of the given type - Throws:
ParserException- if no parser is capable of parsing the provided dataIllegalStateException- if no parser is available in the classPath
-
validateSnippet
- Parameters:
snippet- any Java code- Returns:
- a list of problems (maybe empty)
- Throws:
ParserException- if noJavaParserimplementation could be found
-
parse
Read the given string and parse its data into a newJavaTypeinstance of the given type.- Type Parameters:
T- the java type- Parameters:
type- the type of the sourcedata- the data to parse- Returns:
- a new
JavaTypeinstance of the given type - Throws:
ParserException- if no parser is capable of parsing the provided dataIllegalStateException- if no parser is available in the classPath
-
parse
Read the givenInputStreamand parse its data into a newJavaTypeinstance of the given type. The caller is responsible for closing the stream.- Type Parameters:
T- the java type- Parameters:
stream- the stream to read fromtype- the type of the source- Returns:
- a new
JavaTypeinstance of the given type - Throws:
ParserException- if no parser is capable of parsing the provided dataIllegalStateException- if no parser is available in the classPath
-
parseUnit
- Parameters:
data- the data to parse- Returns:
- a new
JavaUnitinstance of the given type - Throws:
ParserException- if no parser is capable of parsing the requested dataIllegalStateException- if no parser is available in the classPath
-
parseUnit
Read the givenInputStreamand parse its data into a newJavaUnitinstance of the given type. The caller is responsible for closing the stream.- Parameters:
data- the stream to read from- Returns:
- a new
JavaUnitinstance of the given type - Throws:
ParserException- if no parser is capable of parsing the provided dataIllegalStateException- if no parser is available in the classPath
-
format
Format the givenStringas a Java source file, using the built in code format style.- Parameters:
source- a java source code- Returns:
- the formatted source code
- Throws:
IllegalStateException- if no formatter is available in the classPath
-
format
Format the givenStringas a Java source type, using the given code formatProperties- Parameters:
properties- the properties to use to formatsource- a java source code- Returns:
- the formatted source code
- Throws:
IllegalStateException- if no formatter is available in the classPath
-