com.sage.accpac.sm
Class ViewKey

java.lang.Object
  extended by com.sage.accpac.sm.ViewKey

@ThreadSafe
public final class ViewKey
extends java.lang.Object

Represents a key defined in an Accpac view

An instance of this class cannot be created directly by applications. It must be obtained from an instance of the ViewKeys class via the View.getKeys() method.

Since not all required information is currently available from the underlying views the caller may use setIsUnique(boolean) and setHeaderFieldCount(int) to set these properties.

If the View.refreshSchema() method is called then any instance of this class will be invalidated.

Thread safety
Thread-safe

Method Summary
 ViewField getField(int index)
          Gets the ViewField object of the given key field.
 int getFieldCount()
          Gets the number of key fields in the key
 int getHeaderFieldCount()
          gets the number of leading fields that are a reference to the header view.
 int getID()
          Gets the ID of the key.
 java.lang.String getName()
          Gets the name of the Key.
 ViewKeys getParent()
          Gets the ViewKeys collection object from which this object was obtained.
 void setHeaderFieldCount(int count)
          allows the caller to inform the key of how many of the leading fields are a reference to its header or parent view.
 void setIsUnique(boolean isUnique)
          allows the caller to inform the key of whether or not it is a uniqueness key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getField

public ViewField getField(int index)
Gets the ViewField object of the given key field. The field is identified by the zero-based index in the key.

Parameters:
index - the zero-based index of the field to get. This is the zero-based index within this key, not within the View's fields.
Throws:
java.lang.IndexOutOfBoundsException - if the index is not valid
See Also:
getFieldCount()

getFieldCount

public int getFieldCount()
Gets the number of key fields in the key


getHeaderFieldCount

public int getHeaderFieldCount()
gets the number of leading fields that are a reference to the header view.

A view can have a header view, a view that is a parent to this view. For example the header of a batch entry is the batch itself, and the header of an order detail line is the order itself. When putting data to the key fields there is generally no need to put to those fields that are references to the parent and indeed for some protocols doing so might result in an error. Use this function to find out how many of the leading fields of the current key will be set by the parent.

Normally this only makes sense on the primary key, but by allowing this to be a measure of any key we allow for different headers depending on how the view is being viewed.

Returns:
the number of leading fields that are a reference to the header view.

getID

public int getID()
Gets the ID of the key. This key ID corresponds to the key index defined in the view. Key ID always starts from 0 for the first key of the view.


getName

public java.lang.String getName()
Gets the name of the Key.


getParent

public ViewKeys getParent()
Gets the ViewKeys collection object from which this object was obtained.


setHeaderFieldCount

public void setHeaderFieldCount(int count)
allows the caller to inform the key of how many of the leading fields are a reference to its header or parent view.

Note how a view may have a different header view, depending upon which key is being used to refer to it.

Parameters:
count - the number of leading fields that are a reference to the header or parent view.

setIsUnique

public void setIsUnique(boolean isUnique)
allows the caller to inform the key of whether or not it is a uniqueness key.

Parameters:
isUnique - true if the key is known to be a uniqueness key and false if it is known to be not a uniqueness key.
Throws:
java.lang.IllegalStateException - if this is a primary key or if the key has already been informed (even if the values agree)


Copyright © 2010 Sage Software, Inc. All rights reserved.