package com.ricebridge.xmlman.in.test;
import com.ricebridge.xmlman.in.OutPath;
import com.ricebridge.xmlman.in.OutData;
import org.jostraca.util.ListUtil;
import java.util.*;
public class TestOutPath extends OutPath {
private List iPartList = null;
private int iPartIndex = 0;
private Part iPart = null;
private boolean iIsRecord = false;
private boolean iIsAbsolute = false;
private OutData iOutData = null;
public TestOutPath( OutData pOutData, boolean pIsAbsolute ) {
this( pOutData, pIsAbsolute, ListUtil.make() );
}
public TestOutPath( OutData pOutData, boolean pIsAbsolute, String pName0, int pType0 ) {
this( pOutData, pIsAbsolute, ListUtil.make( new Part(pName0,pType0,1) ) );
}
public TestOutPath( OutData pOutData, boolean pIsAbsolute,
String pName0, int pType0,
String pName1, int pType1 ) {
this( pOutData, pIsAbsolute, ListUtil.make( new Part(pName0,pType0,1),
new Part(pName1,pType1,1) ) );
}
public TestOutPath( OutData pOutData, boolean pIsAbsolute,
String pName0, int pType0,
String pName1, int pType1,
String pName2, int pType2 ) {
this( pOutData, pIsAbsolute, ListUtil.make( new Part(pName0,pType0,1),
new Part(pName1,pType1,1),
new Part(pName2,pType2,1) ) );
}
public TestOutPath( OutData pOutData, boolean pIsAbsolute,
String pName0, int pType0,
String pName1, int pType1,
String pName2, int pType2,
String pName3, int pType3 ) {
this( pOutData, pIsAbsolute, ListUtil.make( new Part(pName0,pType0,1),
new Part(pName1,pType1,1),
new Part(pName2,pType2,1),
new Part(pName3,pType3,1) ) );
}
public TestOutPath( OutData pOutData, boolean pIsAbsolute, List pPartList ) {
iOutData = pOutData;
iIsAbsolute = pIsAbsolute;
iPartList = pPartList;
}
public boolean nextPart() {
if( iPartIndex >= iPartList.size() ) {
iPartIndex = 0;
return false;
}
else {
iPart = (Part) iPartList.get( iPartIndex );
iPartIndex++;
return true;
}
}
public String getPartName() {
return iPart.iName;
}
public int getPartType() {
return iPart.iType;
}
public int getPartPosition() {
return iPart.iPostion;
}
public String getPartName(int pPartIndex) {
return ((Part)iPartList.get(pPartIndex)).iName;
}
public int getPartType(int pPartIndex) {
return ((Part)iPartList.get(pPartIndex)).iType;
}
public int getPartPosition(int pPartIndex) {
return ((Part)iPartList.get(pPartIndex)).iPostion;
}
public int getNumParts() {
return iPartList.size();
}
public boolean isRecord() {
return iIsRecord;
}
public boolean isAbsolute() {
return iIsAbsolute;
}
public OutData getOutData() {
return iOutData;
}
public void setIsRecord( boolean pIsRecord ) {
iIsRecord = pIsRecord;
}
public void setIsAbsolute( boolean pIsAbsolute ) {
iIsAbsolute = pIsAbsolute;
}
public String toString() {
StringBuffer sb = new StringBuffer();
if( !iIsAbsolute ) {
sb.append(".");
}
for( Iterator pI = iPartList.iterator(); pI.hasNext(); ) {
Part p = (Part) pI.next();
sb.append( p );
}
sb.append( iOutData );
return sb.toString();
}
public static class Part {
String iName;
int iType;
int iPostion;
public Part( String pName, int pType, int pPosition ) {
iName = pName;
iType = pType;
iPostion = pPosition;
}
public String toString() {
return (OutPath.CHILD == iType ? "/" : "//" ) + iName;
}
}
}