blob: c1a1fe2657696fe7a25121d83b50a593267a76e4 [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.uima.collection.impl.cpm.utils;
import java.util.ArrayList;
public class ConfigurableFeature {
private ValuePair value;
private ArrayList attributeList = new ArrayList();
public ConfigurableFeature(String oldV, String newV) {
value = new ValuePair(oldV, newV);
}
public String getOldFeatureName() {
return value.getOldV();
}
public String getNewFeatureName() {
return value.getNewV();
}
public void addAttribute(ValuePair value) {
attributeList.add(value);
}
public void addAttributes(ArrayList attList) {
attributeList = attList;
}
public String getOldAttributeValue(int index) {
if (index < 0 || attributeList.size() == 0 || attributeList.size() < index) {
return null;
}
return ((ValuePair) attributeList.get(index)).getOldV();
}
public String getOldAttributeValue(String key) {
for (int i = 0; i < attributeList.size(); i++) {
if (((ValuePair) attributeList.get(i)).getOldV().equals(key)) {
return ((ValuePair) attributeList.get(i)).getOldV();
}
}
return null;
}
public String getNewAttributeValue(int index) {
if (index < 0 || attributeList.size() == 0 || attributeList.size() < index) {
return null;
}
return ((ValuePair) attributeList.get(index)).getNewV();
}
public String getNewAttributeValue(String key) {
for (int i = 0; i < attributeList.size(); i++) {
if (((ValuePair) attributeList.get(i)).getOldV().equals(key)) {
return ((ValuePair) attributeList.get(i)).getNewV();
}
}
return null;
}
public int attributeListSize() {
if (attributeList == null) {
return 0;
}
return attributeList.size();
}
}