public boolean equals(Object o) { if (!(o instanceof AttributeList)) return false; AttributeList a = (AttributeList) o; if (size() != a.size()) return false; for (int i = 0; i < size(); i++) if (!attr.get(i).equals(a.attr.get(i))) return false; return true; }
/** This method returns new AttributeList by replacing an element with a new element. */ public AttributeList rename(String from, String to) { AttributeList rval = new AttributeList(); for (int i = 0; i < size(); i++) { String s = getString(i); if (from.equals(s)) rval.add(to); else rval.add(s); } return rval; }
/** This method returns new AttributeList by replacing all source names with a new source name. */ public AttributeList renameAllSourceNames(String to) { AttributeList rval = copy(); for (int i = 0; i < rval.attr.size(); i++) { if (rval.isAttribute(i)) { Attribute a = rval.getAttribute(i); rval.attr.set(i, new Attribute(to, a.getColumnName())); } else if (rval.isFunction(i)) { FunctionParameter f = rval.getFunction(i); AttributeList args = f.getArguments().renameAllSourceNames(to); rval.attr.set(i, new FunctionParameter(f.getFunctionName(), args)); } } return rval; }
/** This method returns new AttributeList by replaceing given column name with new column name. */ public AttributeList renameColumnName(String from, String to) { AttributeList rval = copy(); if (from == null || to == null || from.equals(to)) return rval; for (int i = 0; i < rval.attr.size(); i++) { if (rval.isAttribute(i)) { Attribute a = rval.getAttribute(i); if (a.getColumnName().equals(from)) rval.attr.set(i, new Attribute(a.getSourceName(), to)); } else if (rval.isFunction(i)) { FunctionParameter f = rval.getFunction(i); AttributeList args = f.getArguments().renameColumnName(from, to); rval.attr.set(i, new FunctionParameter(f.getFunctionName(), args)); } } return rval; }
public static AttributeList parse(String str) throws StreamSpinnerException { AttributeList rval = new AttributeList(); String[] tokens = str.split("\\s*,\\s*"); String buf = ""; for (int i = 0; tokens != null && i < tokens.length; i++) { buf = buf + tokens[i]; if (buf.indexOf("(") >= 0 && (!FunctionParameter.isFunction(buf))) { buf = buf + ","; continue; } rval.add(buf); buf = ""; } if (!buf.equals("")) throw new StreamSpinnerException("Cannot parse string : " + str); return rval; }
public AttributeList concat(AttributeList target) { AttributeList rval = copy(); for (int i = 0; i < target.size(); i++) rval.attr.add(target.attr.get(i)); return rval; }
public AttributeList concat(String newattr) { AttributeList rval = copy(); rval.add(newattr); return rval; }