* @param bReplace True to replace an already existing attribute with the same name,
* false to throw an exception instead.
*/
public void addAttribute(AttributeObject attribute, boolean bReplace)
{
Symbol symbol = attribute.getSymbol();
int nOrdinal = findAttributeOrdinal(symbol);
if (nOrdinal >= 0)
{
if (!bReplace)
{
throw new DeclarationException("err.scripting.attributeDup",
new Object[]{symbol.getName(), getName()});
}
}
else
{
for (int i = 0; i <= 1; ++i)
{
if (findMethod(symbol, i) != null)
{
throw new DeclarationException("err.scripting.methodDup",
new Object[]{symbol.getName(), Primitive.createInteger(i), getName()});
}
}
}
if (attribute.getHolder() != null && attribute.getHolder() != this)
{
throw new DeclarationException("err.scripting.attributeReuse",
new Object[]{symbol.getName(),
attribute.getHolder().getName(),
getName()});
}
getMetaclass().validateAttribute(this, attribute);