org.reflections.serializers
Class JavaCodeSerializer

java.lang.Object
  extended by org.reflections.serializers.JavaCodeSerializer
All Implemented Interfaces:
Serializer

public class JavaCodeSerializer
extends java.lang.Object
implements Serializer

serialization of Reflections to java code

serializes types and types elements into interfaces respectively to fully qualified name,

for example:

 public interface MyTestModelStore {
        public interface org extends IPackage {
            public interface reflections extends IPackage {
                        public interface TestModel$AC1 extends IClass {}
                        public interface TestModel$C4 extends IClass {
                                public interface f1 extends IField {}
                                public interface m1 extends IMethod {}
                                public interface m1_int_java$lang$String$$$$ extends IMethod {}
        ...
 }
 

use the different resolve methods to resolve the serialized element into Class, Field or Method. for example:

  Class<? extends IMethod> imethod = MyTestModelStore.org.reflections.TestModel$C4.m1_int_java$lang$String$$$$.class;
  Method method = JavaCodeSerializer.resolve(imethod);
 

depends on Reflections configured with TypesScanner and TypeElementsScanner

the save(org.reflections.Reflections, String) method filename should be in the pattern: path/path/path/package.package.classname


Nested Class Summary
static interface JavaCodeSerializer.IClass
           
static interface JavaCodeSerializer.IElement
           
static interface JavaCodeSerializer.IField
           
static interface JavaCodeSerializer.IMethod
           
static interface JavaCodeSerializer.IPackage
           
 
Constructor Summary
JavaCodeSerializer()
           
 
Method Summary
 Reflections read(java.io.InputStream inputStream)
          reads the input stream into a new Reflections instance, populating it's store
static java.lang.Class<?> resolveClass(java.lang.Class<? extends JavaCodeSerializer.IClass> aClass)
           
static java.lang.Class<?> resolveClassOf(java.lang.Class<? extends JavaCodeSerializer.IElement> element)
           
static java.lang.reflect.Field resolveField(java.lang.Class<? extends JavaCodeSerializer.IField> aField)
           
static java.lang.reflect.Method resolveMethod(java.lang.Class<? extends JavaCodeSerializer.IMethod> aMethod)
           
 java.io.File save(Reflections reflections, java.lang.String name)
          name should be in the pattern: path/path/path/package.package.classname, for example
 java.lang.String toString(Reflections reflections)
          returns a string serialization of the given Reflections instance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavaCodeSerializer

public JavaCodeSerializer()
Method Detail

read

public Reflections read(java.io.InputStream inputStream)
Description copied from interface: Serializer
reads the input stream into a new Reflections instance, populating it's store

Specified by:
read in interface Serializer

save

public java.io.File save(Reflections reflections,
                         java.lang.String name)
name should be in the pattern: path/path/path/package.package.classname, for example
/data/projects/my/src/main/java/org.my.project.MyStore
would create class MyStore in package org.my.project in the path /data/projects/my/src/main/java

Specified by:
save in interface Serializer

toString

public java.lang.String toString(Reflections reflections)
Description copied from interface: Serializer
returns a string serialization of the given Reflections instance

Specified by:
toString in interface Serializer

resolveClassOf

public static java.lang.Class<?> resolveClassOf(java.lang.Class<? extends JavaCodeSerializer.IElement> element)
                                         throws java.lang.ClassNotFoundException
Throws:
java.lang.ClassNotFoundException

resolveClass

public static java.lang.Class<?> resolveClass(java.lang.Class<? extends JavaCodeSerializer.IClass> aClass)

resolveField

public static java.lang.reflect.Field resolveField(java.lang.Class<? extends JavaCodeSerializer.IField> aField)

resolveMethod

public static java.lang.reflect.Method resolveMethod(java.lang.Class<? extends JavaCodeSerializer.IMethod> aMethod)


Copyright © 2010. All Rights Reserved.