Methods Summary |
---|
public void | addColumnPair(ColumnPairElement pair)Add a new column pair to the holder.
addColumnPairs(new ColumnPairElement[]{pair});
|
public void | addColumnPairs(ColumnPairElement[] pairs)Add some new column pairs to the holder.
MappingTableElementImpl table = (MappingTableElementImpl)getTable();
int i, count = ((pairs != null) ? pairs.length : 0);
for (i = 0; i < count; i++)
{
ColumnPairElement pair = (ColumnPairElement)pairs[i];
if (pair != null)
{
// check if entire pair matches
// OK only add it if it has not been added before.
if (getIndexOfColumnPair(NameUtil.getRelativeMemberName(
pair.getName().getFullName())) == -1)
{
table.addKeyColumnInternal(pair.getReferencedColumn());
addKeyColumn(pair.getLocalColumn());
}
else
{
// this part was blank -- do we want an error or skip here?
}
}
else
{
throw new ModelException(I18NHelper.getMessage(getMessages(),
"mapping.element.null_argument")); // NOI18N
}
}
|
private void | addKeyColumn(ColumnElement column)Adds a column to the list of key columns in this referencing key.
This method is only called privately from addColumnPairs and assumes
that the column is not null .
ArrayList referencingKey = getReferencingKey();
String columnName = NameUtil.getRelativeMemberName(
column.getName().getFullName());
try
{
fireVetoableChange(PROP_KEY_COLUMNS, null, null);
referencingKey.add(columnName);
firePropertyChange(PROP_KEY_COLUMNS, null, null);
}
catch (PropertyVetoException e)
{
throw new ModelVetoException(e);
}
|
public ColumnPairElement | getColumnPair(DBIdentifier name)Find a column pair by name.
ColumnPairElement[] myPairs = getColumnPairs();
int count = ((myPairs != null) ? myPairs.length : 0);
String databaseRoot = getDeclaringClass().getDatabaseRoot();
if (count > 0)
{
String absoluteTableName = NameUtil.getAbsoluteTableName(
databaseRoot, getTable().getName());
ColumnPairElement searchPair = (ColumnPairElement)
TableElement.forName(absoluteTableName).getMember(name);
int i;
for (i = 0; i < count; i++)
{
if (myPairs[i].equals(searchPair))
return searchPair;
}
}
return null;
|
public java.util.ArrayList | getColumnPairNames()Returns the list of relative column pair names in this referencing key.
ArrayList locals = getReferencingKey();
ArrayList foreigns = getTable().getKey();
int i, count = ((locals != null) ? locals.size() : 0);
ArrayList pairs = new ArrayList();
for (i = 0; i < count; i++)
pairs.add(locals.get(i) + ";" + foreigns.get(i)); // NOI18N
return pairs;
|
public ColumnPairElement[] | getColumnPairs()Get all column pairs in this holder.
ArrayList pairNames = getColumnPairNames();
TableElement table = getDeclaringTable();
int i, count = ((pairNames != null) ? pairNames.size() : 0);
ColumnPairElement[] pairs = new ColumnPairElement[count];
String databaseRoot = getDeclaringClass().getDatabaseRoot();
for (i = 0; i < count; i++)
{
String absoluteName = NameUtil.getAbsoluteMemberName(
databaseRoot, (String)pairNames.get(i));
pairs[i] = (ColumnPairElement)table.getMember(
DBIdentifier.create(absoluteName));
}
return pairs;
|
public TableElement | getDeclaringTable()Get the declaring table. This method is provided as part of
the implementation of the ReferenceKey interface but should only
be used when a ReferenceKey object is used or by the runtime.
ArrayList locals = getReferencingKey();
if ((locals != null) && (locals.size() > 0))
{
String absoluteName = NameUtil.getAbsoluteMemberName(
getDeclaringClass().getDatabaseRoot(),
locals.get(0).toString());
return TableElement.forName(NameUtil.getTableName(absoluteName));
}
return null;
|
private int | getIndexOfColumnPair(java.lang.String searchPairName)Convenience method which takes a pair and returns its index.
ArrayList myPairs = getColumnPairNames();
int count = ((myPairs != null) ? myPairs.size() : 0);
if (count > 0)
{
int i;
for (i = 0; i < count; i++)
{
if (myPairs.get(i).equals(searchPairName))
return i;
}
}
return -1;
|
public java.lang.String | getKeyName()Get the name of this element. return getName();
|
public ColumnElement[] | getLocalColumns()Get all local columns in this reference key. This method is
provided as part of the implementation of the ReferenceKey interface
but should only be used when a ReferenceKey object is used or by
the runtime.
ColumnPairElement[] columnPairs = getColumnPairs();
int i, count = ((columnPairs != null) ? columnPairs.length : 0);
ColumnElement[] columns = new ColumnElement[count];
for (i = 0; i < count ; i++)
columns[i] = columnPairs[i].getLocalColumn();
return columns;
|
public ColumnElement[] | getReferencedColumns()Get all referenced columns in this reference key. This method is
provided as part of the implementation of the ReferenceKey interface
but should only be used when a ReferenceKey object is used or by
the runtime.
ColumnPairElement[] columnPairs = getColumnPairs();
int i, count = ((columnPairs != null) ? columnPairs.length : 0);
ColumnElement[] columns = new ColumnElement[count];
for (i = 0; i < count ; i++)
columns[i] = columnPairs[i].getReferencedColumn();
return columns;
|
public TableElement | getReferencedTable()Get the referenced table of the reference key. This method is
provided as part of the implementation of the ReferenceKey interface
but should only be used when a ReferenceKey object is used or by
the runtime.
ColumnPairElement[] columnPairs = getColumnPairs();
if ((columnPairs != null) && (columnPairs.length > 0))
return columnPairs[0].getReferencedColumn().getDeclaringTable();
return null;
|
private java.util.ArrayList | getReferencingKey()Returns the list of key column names in this referencing key.
This method is private since API users should call the
getColumnPairNames method.
if (_referencingKey == null)
_referencingKey = new ArrayList();
return _referencingKey;
|
public com.sun.jdo.api.persistence.model.mapping.MappingTableElement | getTable()Returns the mapping table element for this referencing key. return _table;
|
public void | removeColumnPair(java.lang.String pairName)Remove a column pair from the holder. This method can be used to
remove a pair by name when it cannot be resolved to an actual pair.
ArrayList pairNames = new ArrayList(1);
pairNames.add(pairName);
removeColumnPairs(pairNames);
|
public void | removeColumnPair(ColumnPairElement pair)Remove a column pair from the holder.
removeColumnPairs(new ColumnPairElement[]{pair});
|
public void | removeColumnPairs(java.util.ArrayList pairNames)Remove some column pairs from the holder. This method can be used to
remove pairs by name when they cannot be resolved to actual pairs.
ArrayList refKey = getReferencingKey();
ArrayList key = getTable().getKey();
int i, count = ((pairNames != null) ? pairNames.size() : 0);
for (i = 0; i < count ; i++)
{
String pairName = (String)pairNames.get(i);
int index = getIndexOfColumnPair(pairName);
if (pairName != null)
{
try
{
Object remove1 = null, remove2 = null;
fireVetoableChange(PROP_KEY_COLUMNS, null, null);
remove1 = key.remove(index);
remove2 = refKey.remove(index);
if ((remove1 == null) || (remove2 == null))
{
// if only 1 failed, put the other one back
if (remove1 != null)
key.add(index, remove1);
else if (remove2 != null)
refKey.add(index, remove2);
throw new ModelException(I18NHelper.getMessage(
getMessages(),
"mapping.element.element_not_removed", // NOI18N
pairName));
}
firePropertyChange(PROP_KEY_COLUMNS, null, null);
}
catch (PropertyVetoException e)
{
throw new ModelVetoException(e);
}
}
}
|
public void | removeColumnPairs(ColumnPairElement[] pairs)Remove some column pairs from the holder.
ArrayList pairNames = new ArrayList();
int i, count = ((pairs != null) ? pairs.length : 0);
for (i = 0; i < count ; i++)
{
ColumnPairElement pair = (ColumnPairElement)pairs[i];
pairNames.add(NameUtil.getRelativeMemberName(
pair.getName().getFullName()));
}
removeColumnPairs(pairNames);
|
public void | setColumnPairs(ColumnPairElement[] pairs)Set the column pairs for this holder.
Previous column pairs are removed.
removeColumnPairs(getColumnPairNames()); // remove the old ones
addColumnPairs(pairs); // add the new ones
|
public void | setDeclaringTable(TableElement tableElement)Set the mapping table for this referencing key to the mapping table
based on the name of the supplied table. This method is provided as
part of the implementation of the ReferenceKey interface but should
only be used when a ReferenceKey object is used or by the runtime.
throw new UnsupportedOperationException();
|
public void | setKeyName(java.lang.String name)Set the name of this element.
setName(name.toString());
|
public void | setReferencingKey(java.util.ArrayList referencingKey)Set the list of of key column names in this referencing key. This
method should only be used internally and for cloning and archiving.
_referencingKey = referencingKey;
|
public void | setTable(com.sun.jdo.api.persistence.model.mapping.MappingTableElement table)Set the mapping table for this referencing key to the supplied table.
MappingTableElement old = getTable();
try
{
fireVetoableChange(PROP_TABLE, old, table);
setTableInternal(table);
firePropertyChange(PROP_TABLE, old, table);
}
catch (PropertyVetoException e)
{
throw new ModelVetoException(e);
}
|
private void | setTableInternal(com.sun.jdo.api.persistence.model.mapping.MappingTableElement table)Set the mapping table for this referencing key to the supplied table
without firing any property change events.
if (table == null)
{
throw new ModelException(I18NHelper.getMessage(getMessages(),
"mapping.element.null_argument")); // NOI18N
}
_table = table;
if (null == getDeclaringClass())
_declaringClass = table.getDeclaringClass();
if (null == getName())
_name = table.getName();
|
protected void | stripSchemaName()Boston to Pilsen conversion.
This method converts the name of this MappingReferenceKeyElement and
the absolute column names stored in _referencingKey to relative names.
// handle _name (use getRelativeTableName since the name is derived
// from the name of the participating table)
_name = NameUtil.getRelativeTableName(_name);
// handle _referencingKey
if (_referencingKey != null)
{
// Use ListIterator here, because I want to replace the value
// stored in the ArrayList. The ListIterator returned by
// ArrayList.listIterator() supports the set method.
ListIterator i = _referencingKey.listIterator();
while (i.hasNext())
i.set(NameUtil.getRelativeMemberName((String)i.next()));
}
|