com.sage.accpac.sm
Class ViewKey

java.lang.Object
  extended by com.sage.accpac.sm.ViewKey
All Implemented Interfaces:
IViewKey

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

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.


Method Summary
 ViewField getField(int index)
          Deprecated. 
 int getFieldCount()
          Gets the number of 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.
 boolean getIsUnique()
          returns whether or not the key is known to be a uniqueness key.
 java.lang.String getName()
          Gets the name of the Key.
 ViewKeys getParent()
          Deprecated. 
 IViewField getViewField(int index)
          Gets the IViewField of the given key field.
 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

@Deprecated
public ViewField getField(int index)
Deprecated. 

Gets the ViewField object of the given key field. The field is identified by the zero-based index in the key.

This method is deprecated; use getViewField(int) instead

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.
Returns:
the corresponding field, as a ViewField
Throws:
java.lang.IndexOutOfBoundsException - if the index is not valid
See Also:
getFieldCount()

getFieldCount

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

Specified by:
getFieldCount in interface IViewKey
Returns:
the number of fields in the key
See Also:
IViewKey.getViewField(int)

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.

Specified by:
getHeaderFieldCount in interface IViewKey
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.

Specified by:
getID in interface IViewKey
Returns:
the ID of the key

getIsUnique

public boolean getIsUnique()
returns whether or not the key is known to be a uniqueness key.

Specified by:
getIsUnique in interface IViewKey
Returns:
true if the key is known to be a uniqueness key, false if the key is known to be not a uniqueness key, or if it is unclear whether or not it is
See Also:
IViewKey.setIsUnique(boolean)

getName

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

Specified by:
getName in interface IViewKey
Returns:
the name of the Key.

getParent

@Deprecated
public ViewKeys getParent()
Deprecated. 

Gets the ViewKeys collection object from which this object was obtained.

This is deprecated; backward navigation should not be necessary

Returns:
the parent ViewKeys provided at construction time

getViewField

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

Specified by:
getViewField in interface IViewKey
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.
Returns:
the IViewField corresponding to the index
See Also:
IViewKey.getFieldCount()

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.

Specified by:
setHeaderFieldCount in interface IViewKey
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.

This must not be called on the primary key (the first in the collection) and may be called at most once on any other key.

Specified by:
setIsUnique in interface IViewKey
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.


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