blob: 684f4c328a27a479fc8487dca6abdc90f86848ad [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2006, 2013 Oracle and/or its affiliates. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Oracle - initial API and implementation
*
******************************************************************************/
package org.eclipse.persistence.tools.mapping.orm.dom;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.persistence.tools.mapping.AbstractExternalForm;
import org.eclipse.persistence.tools.mapping.orm.ExternalSequenceGenerator;
import org.eclipse.persistence.tools.utility.TextRange;
/**
* The external form of a sequence generator.
*
* @see BasicMapping
* @see Entity
* @see IdMapping
* @see ORMConfiguration
*
* @version 2.6
*/
final class SequenceGenerator extends PrimaryKeyGenerator
implements ExternalSequenceGenerator {
/**
* Creates a new <code>SequenceGenerator</code>.
*
* @param parent The parent of this external form
* @param index The position of the element within the list of children with the same type owned by the parent
*/
SequenceGenerator(AbstractExternalForm parent, int index) {
super(parent, index);
}
/**
* {@inheritDoc}
*/
@Override
protected List<String> buildAttributeNamesOrder() {
List<String> names = new ArrayList<String>();
names.add(CATALOG);
names.add(SCHEMA);
names.add(NAME);
names.add(SEQUENCE_NAME);
names.add(INITIAL_VALUE);
names.add(ALLOCATION_SIZE);
return names;
}
/**
* {@inheritDoc}
*/
@Override
protected String getElementName() {
return SEQUENCE_GENERATOR;
}
/**
* {@inheritDoc}
*/
@Override
public String getSequenceName() {
return getAttribute(SEQUENCE_NAME);
}
/**
* {@inheritDoc}
*/
@Override
public TextRange getSequenceNameTextRange() {
return getAttributeTextRange(SEQUENCE_NAME);
}
/**
* {@inheritDoc}
*/
@Override
public void setSequenceName(String name) {
setAttribute(SEQUENCE_NAME, name);
if (shouldBeRemoved()) {
removeSelf();
}
}
}