All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.siwenyan.dish_parser.SupplyLine Maven / Gradle / Ivy

There is a newer version: 1.25
Show newest version
package com.github.siwenyan.dish_parser;

import java.util.ArrayList;
import java.util.List;

public class SupplyLine {

	public static List getStringLines(List supplyLines) {
		List stringLines = new ArrayList(supplyLines.size());
		for (SupplyLine supplyLine : supplyLines) {
			stringLines.add(supplyLine.getLine());
		}

		return stringLines;
	}

	public static List getSupplyLines(List stringLines) throws BadSmellException {
		List supplyLines = new ArrayList(stringLines.size());
		for (String stringLine : stringLines) {
			supplyLines.add(new SupplyLine(stringLine));
		}

		return supplyLines;
	}

	private String line = null;

	private List traceStack = new ArrayList();

	private Flavor flavor = null;

	public SupplyLine(String line) throws BadSmellException {
		this.setLine(line);
	}

	public String getLine() {
		return this.line;
	}

	public void setLine(String line) throws BadSmellException {
		this.line = line == null ? "" : line.trim();
		this.flavor = new Flavor(SyntaxSimple.slideFlavor(line)[0]);
	}

	public List getStack() {
		return new ArrayList(this.traceStack);
	}

	public void addTrace(Trace trace) {
		this.traceStack.add(trace);
	}

	public void addStack(List stack) {
		this.traceStack.addAll(stack);
	}

	public Flavor getFlavor() {
		return flavor;
	}

	public void replaceFlavor(Flavor.FlavorPart flavorPart, String replacement) throws BadSmellException {
		line = SyntaxSimple.replaceFlavor(line, flavorPart, replacement);
	}

	@Override
	public String toString() {
		String s = "";
		s += traceStack == null ? "[]" : traceStack.toString();
		s += this.getLine();
		return s;
	}

	@Override
	public Object clone() {
		try {
			SupplyLine supplyLine = new SupplyLine(this.getLine());
			supplyLine.addStack(this.traceStack);
			return supplyLine;
		} catch (BadSmellException e) {
			return null;
		}
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy