Class JavaExternalObjectType

All Implemented Interfaces:
ItemType

public class JavaExternalObjectType extends ExternalObjectType
This class represents the type of an external Java object returned by an extension function, or supplied as an external variable/parameter.
  • Field Details

    • javaClass

      protected Class<?> javaClass
  • Method Details

    • of

      public static JavaExternalObjectType of(Class<?> javaClass)
      Allocate an external object type. for a given Java class. Reuses a known JavaExternalObjectType if found in a static cache
      Parameters:
      javaClass - the Java class to which this type corresponds
      Returns:
      the corresponding JavaExternalObjectType
    • getName

      public String getName()
      Get the local name of this type.
      Specified by:
      getName in class ExternalObjectType
      Returns:
      the fully qualified name of the Java class.
    • getTargetNamespace

      public String getTargetNamespace()
      Get the target namespace of this type. The is always NamespaceConstant.JAVA_TYPE.
      Specified by:
      getTargetNamespace in class ExternalObjectType
      Returns:
      the target namespace of this type definition.
    • getTypeName

      public StructuredQName getTypeName()
      Get the name of this type as a StructuredQName, unless the type is anonymous, in which case return null
      Specified by:
      getTypeName in class ExternalObjectType
      Returns:
      the name of the atomic type, or null if the type is anonymous.
    • getPrimitiveItemType

      public ItemType getPrimitiveItemType()
      Get the primitive item type corresponding to this item type.
      Specified by:
      getPrimitiveItemType in interface ItemType
      Overrides:
      getPrimitiveItemType in class AnyExternalObjectType
      Returns:
      EXTERNAL_OBJECT_TYPE, the ExternalObjectType that encapsulates the Java type Object.class.
    • getRelationship

      public Affinity getRelationship(JavaExternalObjectType other)
      Get the relationship of this external object type to another external object type
      Parameters:
      other - the other external object type
      Returns:
      the relationship of this external object type to another external object type, as one of the constants in class Affinity, for example Affinity.SUBSUMES
    • getJavaClass

      public Class<?> getJavaClass()
      Get the Java class to which this external object type corresponds
      Returns:
      the corresponding Java class
    • matches

      public boolean matches(Item item, TypeHierarchy th)
      Test whether a given item conforms to this type
      Specified by:
      matches in interface ItemType
      Overrides:
      matches in class AnyExternalObjectType
      Parameters:
      item - The item to be tested
      th - The type hierarchy cache
      Returns:
      true if the item is an instance of this type; false otherwise
    • toString

      public String toString()
      Overrides:
      toString in class ExternalObjectType
    • getDisplayName

      public String getDisplayName()
    • hashCode

      public int hashCode()
      Returns a hash code value for the object.
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Test whether two ExternalObjectType objects represent the same type
      Overrides:
      equals in class Object
      Parameters:
      obj - the other ExternalObjectType
      Returns:
      true if the two objects represent the same type
    • classNameToLocalName

      public static String classNameToLocalName(String className)
      Static method to convert a Java class name to an XPath local name. This involves the following substitutions: "$" is replaced by "-", and "[" is replaced by "_-".
    • localNameToClassName

      public static String localNameToClassName(String className)
      Static method to convert an XPath local name to a Java class name. This involves the following substitutions: "-" is replaced by "$", and leading "_-" pairs are replaced by "[".
    • classNameToQName

      public static StructuredQName classNameToQName(String className)
      Static method to get the QName corresponding to a Java class name