Class KeyRef

All Implemented Interfaces:
ComponentReference, SerializableSchemaComponent, UserSchemaComponent, SourceLocator, Location, SchemaComponent, Locator

public class KeyRef extends IdentityConstraint implements ComponentReference
This class represents an xs:keyRef identity constraint in a schema
  • Constructor Details

    • KeyRef

      public KeyRef()
      Create a KeyRef object representing an xs:keyref constraints
    • KeyRef

      public KeyRef(EnterpriseConfiguration config, StructuredQName refer)
      Create a new KeyRef Identity-Constraint.
      Parameters:
      config - the configuration
      refer - the name of the referenced key.
  • Method Details

    • getConstraintCategory

      public String getConstraintCategory()
      Description copied from class: IdentityConstraint
      The type of constraint: one of "key", "unique", or "keyref"
      Specified by:
      getConstraintCategory in class IdentityConstraint
      Returns:
      one of "key", "unique", or "keyref" (note the spelling)
    • getTargetComponentName

      public StructuredQName getTargetComponentName()
      Get the name of the target of this reference
      Specified by:
      getTargetComponentName in interface ComponentReference
      Returns:
      the component name
    • setTargetComponentName

      public void setTargetComponentName(StructuredQName target)
      Sets the name of the key being referenced.
      Parameters:
      target - the fingerprint of the name of the key to reference.
    • setTargetKey

      public void setTargetKey(IdentityConstraint key)
      Set the target key or unique constraint
      Parameters:
      key - the target key definition or unique constraint
    • tryToResolve

      public void tryToResolve(SchemaCompiler compiler, boolean fatal)
      Try to resolve the reference if possible, relative to components present in a given schema. No error occurs if the reference cannot yet be resolved.
      Specified by:
      tryToResolve in interface ComponentReference
      Parameters:
      compiler - The schema containing the candidate target components for the reference. If null, the schema containing the reference is used.
      fatal - true if a failure to resolve is to be treated as fatal
    • isResolved

      public boolean isResolved()
      Determine whether this reference has been resolved
      Specified by:
      isResolved in interface ComponentReference
      Returns:
      true if the reference has been resolved to a schema component
    • isDangling

      public boolean isDangling()
      Ask whether this is known to be a dangling reference
      Specified by:
      isDangling in interface ComponentReference
      Returns:
      true if the target of this component reference is known to be absent, and if a warning has been issued to this effect
    • getTarget

      public SchemaComponent getTarget() throws MissingComponentException
      Get the schema component identified by this reference.
      Specified by:
      getTarget in interface ComponentReference
      Returns:
      the schema component if the reference has been resolved.
      Throws:
      MissingComponentException - if the reference has not been resolved. Note that this is an unchecked exception.
    • getSymbolSpace

      public int getSymbolSpace()
      Get the symbol space of the target of this reference
      Specified by:
      getSymbolSpace in interface ComponentReference
      Returns:
      an integer code identifying the symbol space
    • fixup

      public boolean fixup(SchemaCompiler compiler) throws SchemaException
      Check references from this component to other components
      Specified by:
      fixup in interface UserSchemaComponent
      Overrides:
      fixup in class IdentityConstraint
      Parameters:
      compiler - used for reporting error messages
      Returns:
      true if all is well, false if errors found
      Throws:
      SchemaException
    • validate

      public boolean validate(SchemaCompiler compiler) throws SchemaException
      Checks the validity of this Schema defintion.
      Specified by:
      validate in interface UserSchemaComponent
      Overrides:
      validate in class IdentityConstraint
      Parameters:
      compiler - the schema compiler
      Returns:
      true when this Schema definition is valid, otherwise false.
      Throws:
      SchemaException - when this Schema definition is invalid.