Package aQute.bnd.osgi
Class Descriptors
- java.lang.Object
-
- aQute.bnd.osgi.Descriptors
-
public class Descriptors extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
Descriptors.Descriptor
static class
Descriptors.PackageRef
static interface
Descriptors.TypeRef
-
Constructor Summary
Constructors Constructor Description Descriptors()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.lang.String
binaryClassToFQN(java.lang.String path)
static java.lang.String
binaryToFQN(java.lang.String binary)
static java.lang.String
binaryToSimple(java.lang.String resource)
Java really screwed up in using different names for the binary path and the fqns.static java.lang.String
classToPath(java.lang.String className)
Converts the class name (without the package qualifier) into the corresponding binary name.static aQute.bnd.result.Result<java.lang.String[]>
determine(java.lang.String fqn)
Return a 2 element array based on the fqn.static java.lang.String
fqnClassToBinary(java.lang.String fqn)
Converts the given fully-qualified top-level class name into the binary class path.static java.lang.String
fqnToBinary(java.lang.String fqn)
static java.lang.String
fqnToPath(java.lang.String s)
aQute.bnd.signatures.ClassSignature
getClassSignature(java.lang.String signature)
Descriptors.Descriptor
getDescriptor(java.lang.String descriptor)
aQute.bnd.signatures.FieldSignature
getFieldSignature(java.lang.String signature)
aQute.bnd.signatures.MethodSignature
getMethodSignature(java.lang.String signature)
static java.lang.String
getPackage(java.lang.String binaryNameOrFqn)
Descriptors.TypeRef
getPackageInfo(Descriptors.PackageRef packageRef)
Descriptors.PackageRef
getPackageRef(java.lang.String binaryPackName)
static java.lang.String
getShortName(java.lang.String fqn)
Return the short name of a FQNDescriptors.TypeRef
getTypeRef(java.lang.String binaryClassName)
Descriptors.TypeRef
getTypeRefFromFQN(java.lang.String fqn)
Descriptors.TypeRef
getTypeRefFromPath(java.lang.String path)
static boolean
isBinaryClass(java.lang.String resource)
static boolean
isClassName(java.lang.String fqn)
Heuristic for a class name.static java.lang.String
pathToFqn(java.lang.String path)
-
-
-
Method Detail
-
getTypeRef
public Descriptors.TypeRef getTypeRef(java.lang.String binaryClassName)
-
getPackageInfo
public Descriptors.TypeRef getPackageInfo(Descriptors.PackageRef packageRef)
-
getPackageRef
public Descriptors.PackageRef getPackageRef(java.lang.String binaryPackName)
-
getDescriptor
public Descriptors.Descriptor getDescriptor(java.lang.String descriptor)
-
getClassSignature
public aQute.bnd.signatures.ClassSignature getClassSignature(java.lang.String signature)
-
getMethodSignature
public aQute.bnd.signatures.MethodSignature getMethodSignature(java.lang.String signature)
-
getFieldSignature
public aQute.bnd.signatures.FieldSignature getFieldSignature(java.lang.String signature)
-
getShortName
public static java.lang.String getShortName(java.lang.String fqn)
Return the short name of a FQN
-
binaryToFQN
public static java.lang.String binaryToFQN(java.lang.String binary)
-
binaryClassToFQN
public static java.lang.String binaryClassToFQN(java.lang.String path)
-
fqnToBinary
public static java.lang.String fqnToBinary(java.lang.String fqn)
-
fqnClassToBinary
public static java.lang.String fqnClassToBinary(java.lang.String fqn)
Converts the given fully-qualified top-level class name into the binary class path. For example:my.pkg.And.Clazz
becomes:my/pkg/And$Clazz.class
This method uses
determine(String)
to split the class and package names, which is imperfect.- Parameters:
fqn
- the fully-qualified name to be converted.- Returns:
- The binary name corresponding to the fully-qualified name.
-
classToPath
public static java.lang.String classToPath(java.lang.String className)
Converts the class name (without the package qualifier) into the corresponding binary name. For example:my.pkg.and.Clazz
becomes:my$pkg$and$Clazz.class
As you can see, this method is not smart about distinguishing between package and class nesting - it always converts the . into a $.- Parameters:
className
- the name of the class to be converted.- Returns:
- The binary name corresponding to the class name.
-
getPackage
public static java.lang.String getPackage(java.lang.String binaryNameOrFqn)
-
fqnToPath
public static java.lang.String fqnToPath(java.lang.String s)
-
getTypeRefFromFQN
public Descriptors.TypeRef getTypeRefFromFQN(java.lang.String fqn)
-
getTypeRefFromPath
public Descriptors.TypeRef getTypeRefFromPath(java.lang.String path)
-
pathToFqn
public static java.lang.String pathToFqn(java.lang.String path)
-
isBinaryClass
public static boolean isBinaryClass(java.lang.String resource)
-
binaryToSimple
public static java.lang.String binaryToSimple(java.lang.String resource)
Java really screwed up in using different names for the binary path and the fqns. This calculates the simple name of a potentially nested class.- Parameters:
resource
- ( segment '/')+ (name '$')* name '.class'- Returns:
- the last name
-
isClassName
public static boolean isClassName(java.lang.String fqn)
Heuristic for a class name. We assume a segment with- Parameters:
fqn
- can be a class name, nested class, or simple name- Returns:
- true if the last segment starts with an upper case
-
determine
public static aQute.bnd.result.Result<java.lang.String[]> determine(java.lang.String fqn)
Return a 2 element array based on the fqn. The first element is the package name, the second is the class name. Each can be absent, but not both. The class name can be a nested class (will contain a '.' then)Because there is an inherent ambiguity between packages and nested classes, this method uses a heuristic that works most of the time: the start of the class name is considered to be the first element that begins with a capital letter. Hence "simple.Sample.Sumple" => ["simple", "Sample.Sumple" ] and not [ "simple.Sample", "Sumple" ].
- Parameters:
fqn
- a Java identifier name, either a simple class name, a qualified class name, or a package name- Returns:
- a Result with 2 element array with [package, class]
-
-