Skip to content

Commit

Permalink
promote/repackage/rename
Browse files Browse the repository at this point in the history
  • Loading branch information
mbenson committed Nov 20, 2013
1 parent f7fe91e commit 93a6099
Show file tree
Hide file tree
Showing 140 changed files with 2,701 additions and 2,648 deletions.
60 changes: 30 additions & 30 deletions api/src/main/java/org/jboss/forge/parser/JavaParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
import java.util.List;
import java.util.ServiceLoader;

import org.jboss.forge.parser.java.ReadJavaSource;
import org.jboss.forge.parser.java.ReadJavaSource.JavaSource;
import org.jboss.forge.parser.java.JavaType;
import org.jboss.forge.parser.java.source.JavaSource;
import org.jboss.forge.parser.spi.JavaParserProvider;

/**
* Responsible for parsing data into new {@link ReadJavaSource} instances.
* Responsible for parsing data into new {@link JavaType} instances.
*
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
*/
Expand Down Expand Up @@ -69,90 +69,90 @@ public static <T extends JavaSource<?>> T create(final Class<T> type)
}

/**
* Open the given {@link File}, parsing its contents into a new {@link ReadJavaSource} instance.
* Open the given {@link File}, parsing its contents into a new {@link JavaType} instance.
*/
public static ReadJavaSource<?> parse(final File file) throws FileNotFoundException
public static JavaType<?> parse(final File file) throws FileNotFoundException
{
return parse(ReadJavaSource.class, file);
return parse(JavaType.class, file);
}

/**
* Parse the given {@link URL} data into a new {@link ReadJavaSource} instance.
* Parse the given {@link URL} data into a new {@link JavaType} instance.
*/
public static ReadJavaSource<?> parse(final URL data) throws IOException
public static JavaType<?> parse(final URL data) throws IOException
{
return parse(ReadJavaSource.class, data);
return parse(JavaType.class, data);
}

/**
* Read the given {@link InputStream} and parse the data into a new {@link ReadJavaSource} instance.
* Read the given {@link InputStream} and parse the data into a new {@link JavaType} instance.
*/
public static ReadJavaSource<?> parse(final InputStream data)
public static JavaType<?> parse(final InputStream data)
{
return parse(ReadJavaSource.class, data);
return parse(JavaType.class, data);
}

/**
* Parse the given character array into a new {@link ReadJavaSource} instance.
* Parse the given character array into a new {@link JavaType} instance.
*/
public static ReadJavaSource<?> parse(final char[] data)
public static JavaType<?> parse(final char[] data)
{
return parse(ReadJavaSource.class, data);
return parse(JavaType.class, data);
}

/**
* Parse the given String data into a new {@link ReadJavaSource} instance.
* Parse the given String data into a new {@link JavaType} instance.
*/
public static ReadJavaSource<?> parse(final String data)
public static JavaType<?> parse(final String data)
{
return parse(ReadJavaSource.class, data);
return parse(JavaType.class, data);
}

/**
* Read the given {@link URL} and parse its data into a new {@link ReadJavaSource} instance of the given type.
* Read the given {@link URL} and parse its data into a new {@link JavaType} instance of the given type.
*
* @throws FileNotFoundException
*/
public static <T extends ReadJavaSource<?>> T parse(final Class<T> type, final URL url) throws IOException
public static <T extends JavaType<?>> T parse(final Class<T> type, final URL url) throws IOException
{
return internalParse(type, url.openStream());
}

/**
* Read the given {@link File} and parse its data into a new {@link ReadJavaSource} instance of the given type.
* Read the given {@link File} and parse its data into a new {@link JavaType} instance of the given type.
*
* @throws FileNotFoundException
*/
public static <T extends ReadJavaSource<?>> T parse(final Class<T> type, final File file) throws FileNotFoundException
public static <T extends JavaType<?>> T parse(final Class<T> type, final File file) throws FileNotFoundException
{
return internalParse(type, new FileInputStream(file));
}

/**
* Read the given character array and parse its data into a new {@link ReadJavaSource} instance of the given type.
* Read the given character array and parse its data into a new {@link JavaType} instance of the given type.
*/
public static <T extends ReadJavaSource<?>> T parse(final Class<T> type, final char[] data)
public static <T extends JavaType<?>> T parse(final Class<T> type, final char[] data)
{
return parse(type, new String(data));
}

/**
* Read the given string and parse its data into a new {@link ReadJavaSource} instance of the given type.
* Read the given string and parse its data into a new {@link JavaType} instance of the given type.
*/
public static <T extends ReadJavaSource<?>> T parse(final Class<T> type, final String data)
public static <T extends JavaType<?>> T parse(final Class<T> type, final String data)
{
return parse(type, Streams.fromString(data));
}

/**
* Read the given {@link InputStream} and parse its data into a new {@link ReadJavaSource} instance of the given type.
* Read the given {@link InputStream} and parse its data into a new {@link JavaType} instance of the given type.
* The caller is responsible for closing the stream.
*/
public static <T extends ReadJavaSource<?>> T parse(final Class<T> type, final InputStream data)
public static <T extends JavaType<?>> T parse(final Class<T> type, final InputStream data)
{
for (JavaParserProvider parser : getParsers())
{
final ReadJavaSource<?> source = parser.parse(data);
final JavaType<?> source = parser.parse(data);

if (type.isInstance(source))
{
Expand All @@ -169,7 +169,7 @@ else if (source != null)
throw new ParserException("Cannot find JavaParserProvider capable of parsing the requested data");
}

private static <T extends ReadJavaSource<?>> T internalParse(final Class<T> type, final InputStream data)
private static <T extends JavaType<?>> T internalParse(final Class<T> type, final InputStream data)
{
try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,7 @@
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
*
*/
public interface ReadAbstractable<T>
public interface Abstractable<T>
{
public abstract boolean isAbstract();

/**
* Represents a Java source element that may be declared {@code abstract}.
*
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
*
*/
public interface Abstractable<T> extends ReadAbstractable<T>
{
public abstract T setAbstract(boolean abstrct);
}
}
60 changes: 60 additions & 0 deletions api/src/main/java/org/jboss/forge/parser/java/Annotation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright 2012-2013 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Eclipse Public License version 1.0, available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.jboss.forge.parser.java;

import java.util.List;

import org.jboss.forge.parser.Internal;
import org.jboss.forge.parser.Origin;

/**
* Represents an annotation on some Java element.
*
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
*/
public interface Annotation<O extends JavaType<O>> extends Internal, Origin<O>
{
boolean isSingleValue();

boolean isMarker();

boolean isNormal();

String getName();

String getQualifiedName();

<T extends Enum<T>> T getEnumValue(Class<T> type);

<T extends Enum<T>> T getEnumValue(Class<T> type, String name);

<T extends Enum<T>> T[] getEnumArrayValue(Class<T> type);

<T extends Enum<T>> T[] getEnumArrayValue(Class<T> type, String name);

String getLiteralValue();

String getLiteralValue(String name);

List<ValuePair> getValues();

String getStringValue();

String getStringValue(String name);

Annotation<O> getAnnotationValue();

Annotation<O> getAnnotationValue(String name);

Class<?> getClassValue();

Class<?> getClassValue(String name);

Class<?>[] getClassArrayValue();

Class<?>[] getClassArrayValue(String name);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* Copyright 2013 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Eclipse Public License version 1.0, available at
* http://www.eclipse.org/legal/epl-v10.html
*/

package org.jboss.forge.parser.java;

import org.jboss.forge.parser.Origin;

/**
* Represents an element definition of a {@link JavaAnnotation}.
*
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
* @author Matt Benson
*/
public interface AnnotationElement<O extends JavaAnnotation<O>> extends AnnotationTarget<O>,
Origin<O>, Named
{
/**
* Represents the default value of a given {@link AnnotationElement}.
*/
public interface ReadDefaultValue<O extends JavaAnnotation<O>>
{
String getString();

String getLiteral();

<T extends Enum<T>> T getEnum(Class<T> type);

<T extends Enum<T>> T[] getEnumArray(Class<T> type);

Annotation<O> getAnnotation();

Class<?> getSingleClass();

Class<?>[] getClassArray();
}

/**
* Get this annotation element's type.
*/
String getType();

/**
* Get this annotation element's fully qualified type.
*/
String getQualifiedType();

/**
* Get this annotation element's {@link Type}
*/
Type<O> getTypeInspector();

/**
* Attempt to determine if this annotation element is of the same type as the given type.
*/
boolean isType(Class<?> type);

/**
* Attempt to determine if this annotation element is of the same type as the given type.
*/
boolean isType(String type);

ReadDefaultValue<O> getDefaultValue();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright 2012 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Eclipse Public License version 1.0, available at
* http://www.eclipse.org/legal/epl-v10.html
*/

package org.jboss.forge.parser.java;

import java.util.List;

import org.jboss.forge.parser.Internal;
import org.jboss.forge.parser.Origin;

/**
* Represents a Java element that may carry annotations.
*
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
*/
public interface AnnotationTarget<O extends JavaType<O>> extends Internal, Origin<O>
{
public List<? extends Annotation<O>> getAnnotations();

public boolean hasAnnotation(final Class<? extends java.lang.annotation.Annotation> type);

public boolean hasAnnotation(final String type);

public Annotation<O> getAnnotation(final Class<? extends java.lang.annotation.Annotation> type);

public Annotation<O> getAnnotation(final String type);
}
24 changes: 9 additions & 15 deletions api/src/main/java/org/jboss/forge/parser/java/EnumConstant.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,26 @@
import org.jboss.forge.parser.Internal;
import org.jboss.forge.parser.Origin;

//TODO implement MethodHolder
public interface EnumConstant extends Internal, Origin<JavaEnum>
/**
* Represents one of the constant members of a {@link JavaEnum}.
*/
public interface EnumConstant<O extends JavaEnum<O>> extends Internal, Origin<O>,
AnnotationTarget<O>, Named
{
/**
* Represents the anonymous subclass "body" of an enum constant.
* Represents the anonymous subclass "body" of a {@link EnumConstant}.
*/
public interface Body extends JavaSource<Body>, FieldHolder<Body>, MethodHolder<Body> {
public interface ReadBody<O extends ReadBody<O>> extends JavaType<O>, FieldHolder<O>, MethodHolder<O>
{
}

/**
* Get the constructor arguments of this enum constant.
*/
List<String> getConstructorArguments();

/**
* Set the constructor arguments for this enum constant.
*/
EnumConstant<O> setConstructorArguments(String... literalArguments);

/**
* Get the {@link Body} of this enum constant.
*/
Body getBody();

/**
* Remove the {@link Body} of this enum constant.
*/
EnumConstant setName(String name);
ReadBody<?> getBody();
}
24 changes: 24 additions & 0 deletions api/src/main/java/org/jboss/forge/parser/java/Extendable.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright 2012 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Eclipse Public License version 1.0, available at
* http://www.eclipse.org/legal/epl-v10.html
*/

package org.jboss.forge.parser.java;

/**
* Represents a {@link JavaType} that can extend other types (Java inheritance and interfaces).
*
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
*
*/
public interface Extendable<O extends JavaType<O>>
{
/**
* Get this type's super class.
*
* @see #setSuperType(String)
*/
public String getSuperType();
}
Loading

0 comments on commit 93a6099

Please sign in to comment.