[Idrs-commit] CVS: Idrs/dev/src/net/sourceforge/idrs/deploy/compile/units Body.java,1.9,1.10
Brought to you by:
bigman921
|
From: Marc B. <big...@us...> - 2003-03-26 21:33:38
|
Update of /cvsroot/idrs/Idrs/dev/src/net/sourceforge/idrs/deploy/compile/units
In directory sc8-pr-cvs1:/tmp/cvs-serv31636/dev/src/net/sourceforge/idrs/deploy/compile/units
Modified Files:
Body.java
Log Message:
refactored navigation tags, also added a <navcur> tag that generates a link that will kepp a page it it's current state, minus any specified parameters.
Index: Body.java
===================================================================
RCS file: /cvsroot/idrs/Idrs/dev/src/net/sourceforge/idrs/deploy/compile/units/Body.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** Body.java 17 Mar 2003 14:05:00 -0000 1.9
--- Body.java 26 Mar 2003 21:33:04 -0000 1.10
***************
*** 27,335 ****
public class Body extends net.sourceforge.idrs.deploy.compile.Compiler {
! /** Creates new Body */
! public Body() {
! }
! /**
! *allows for the compiler to work with the current state of the page compilation
! */
! public void setState(CompilerState state) throws Exception {
! super.setState(state);
! state.pushLines();
! }
! /**
! *allows for a compiler to use the attributes of the calling tag
! */
! public void setAttributes(Attributes atts) throws Exception {
! super.setAttributes(atts);
! String bodyTag;
! if (state.getReport().getBody().isHTML()) {
! Line line = state.getCurrentLine();
! //line.addChunk(new net.sourceforge.idrs.core.report.TextChunk("<BODY "));
! bodyTag="<BODY ";
! for (int i=0,m=atts.getLength();i<m;i++) {
! bodyTag += atts.getLocalName(i) + "=\"" + atts.getValue(i) + "\" ";
! }
! bodyTag += ">";
! System.out.println("Body tag : " + bodyTag);
! line.addChunk(new TextChunk(bodyTag));
! state.sealLine();
! }
! }
! public void useMethod(String val,Attributes atts) throws Exception {
! String objid = atts.getValue("objid");
! String varlistId = atts.getValue("varlist");
! LinkedList varList = (LinkedList) ((HashMap) state.getAttribute("IDRS_VAR_LISTS")).get(varlistId);
! Line curr = state.getCurrentLine();
! curr.addChunk(new ObjectChunk(val,varList.toArray(),varlistId,objid));
! }
! public void field(String val,Attributes atts) throws Exception {
!
!
! if (val.equalsIgnoreCase("<LineNum>") || val.equalsIgnoreCase("<ForeColor>") || val.equalsIgnoreCase("<BackColor>")) {
! Line line = state.getCurrentLine();
! line.addChunk(new net.sourceforge.idrs.core.report.FieldChunk("",val,"",state.getCurrentRepeatLine()));
! return;
! }
!
! if (val.indexOf(".") == -1) {
! state.setErrorWord(val);
! throw new Exception("No Period Found");
! }
! String format = atts.getValue("format");
! String id, field;
! id = val.substring(0,val.indexOf("."));
!
! field = val.substring(val.indexOf(".")+1);
! if (state.getReport().getHead().getAllDBs().get(id) == null) {
! state.setErrorWord(id);
! throw new Exception(id + " is not a valid DB");
! }
! Line line = state.getCurrentLine();
!
! line.addChunk(new net.sourceforge.idrs.core.report.FieldChunk(id,field,format,state.getCurrentRepeatLine()));
! }
!
! public void error(String val, Attributes atts) throws Exception {
! Line line = state.getCurrentLine();
! line.addChunk(new net.sourceforge.idrs.core.report.ErrorChunk());
! }
! public void inputResults(String val,Attributes atts) throws Exception {
! if (state.getReport().getHead().getAllDBs().get(val) == null) {
! state.setErrorWord(val);
! throw new Exception(val + " is not a valid DB");
! }
! Line line = state.getCurrentLine();
! line.addChunk(new net.sourceforge.idrs.core.report.InputResultsChunk(val));
! }
! public void script(String val, Attributes atts) throws Exception {
! state.getCurrentLine().addChunk(new net.sourceforge.idrs.core.report.ShortScriptChunk(val));
! }
! public void echoScript(String val,Attributes atts) throws Exception {
! state.getCurrentLine().addChunk(new net.sourceforge.idrs.core.report.EvalScriptChunk(val));
! }
! public void text(String val,Attributes atts) throws Exception {
! //System.out.println("val = \"" + val + "\"");
! //System.out.println("this is : " + this);
! /*if (val.indexOf('\n') != -1) {
! StringTokenizer tok = new StringTokenizer(val,"\n",false);
! Line line;
! while (tok.hasMoreTokens()) {
! line = state.getCurrentLine();
! line.addChunk(new net.sourceforge.idrs.core.report.TextChunk(tok.nextToken()));
! state.sealLine();
! }
! }
! else {
! state.getCurrentLine().addChunk(new TextChunk(val));
! }*/
! state.getCurrentLine().addChunk(new TextChunk(val));
! }
!
! /**
! * Handles the yesNo tag
! */
! public void yesNo(String val, Attributes atts) throws Exception {
! String name,srcType,single, attribs;
! int isrcType,isingle;
! boolean paramFirst = false;
!
! name = atts.getValue("name");
!
!
!
!
!
! paramFirst = atts.getValue("paramFirst") != null ? atts.getValue("paramFirst").equalsIgnoreCase("true") : false;
!
! single = atts.getValue("single");
! if (single == null || single.equalsIgnoreCase("")) {
! isingle = YesNo.NOT_SINGLE;
! }
! else {
! isingle = single.equalsIgnoreCase("yes") ? YesNo.SINGLE_YES : YesNo.SINGLE_NO;
! }
!
!
! attribs = atts.getValue("atts");
! attribs = (attribs != null) ? attribs : "";
!
! srcType = atts.getValue("srcType");
! if (srcType.equalsIgnoreCase("param")) isrcType = YesNo.SRC_PARAM;
! else if (srcType.equalsIgnoreCase("db")) isrcType = YesNo.SRC_DB;
! else if (srcType.equalsIgnoreCase("db")) isrcType = YesNo.SRC_PROP;
! else {
! state.setErrorWord(srcType);
! throw new Exception(srcType + " is not a valid source type");
! }
!
! if (isrcType == YesNo.SRC_DB && val.indexOf(".") == -1) {
! state.setErrorWord(val);
! throw new Exception("Not A Valid Source Field");
! }
!
! if (isrcType == YesNo.SRC_DB && state.getReport().getHead().getAllDBs().get(val.substring(0,val.indexOf("."))) == null) {
! state.setErrorWord(val);
! throw new Exception(val.substring(0,val.indexOf(".")) + " is not a valid DB");
! }
!
! state.getCurrentLine().addChunk(new YesNo(name,isingle,isrcType,val,attribs,paramFirst));
!
! }
!
! public void navNext(String val, Attributes atts) throws Exception {
! state.getCurrentLine().addChunk(new NavNextChunk(val));
! }
! public void navPrev(String val, Attributes atts) throws Exception {
! state.getCurrentLine().addChunk(new NavPrevChunk(val));
! }
! /**
! * Handles the formInput tag
! */
! public void formInput(String val, Attributes atts) throws Exception {
! String name,srcType,type, attribs,value;
! int isrcType,isingle,itype=-1;
! boolean paramFirst;
!
!
!
!
! paramFirst = atts.getValue("paramFirst") != null ? atts.getValue("paramFirst").equalsIgnoreCase("true") : false;
! // System.out.println("Param First : " + paramFirst);
! value = atts.getValue("value");
! value = value != null ? value : "";
! name = atts.getValue("name");
! type = atts.getValue("type");
!
! itype = type.equalsIgnoreCase("hidden") ? InputChunk.INPUT_HIDDEN : itype;
! itype = type.equalsIgnoreCase("text") ? InputChunk.INPUT_TEXT : itype;
! itype = type.equalsIgnoreCase("password") ? InputChunk.INPUT_PASSWORD : itype;
! itype = type.equalsIgnoreCase("checkbox") ? InputChunk.INPUT_CHECKBOX : itype;
! itype = type.equalsIgnoreCase("radio") ? InputChunk.INPUT_RADIO : itype;
! itype = type.equalsIgnoreCase("textarea") ? InputChunk.INPUT_TEXTAREA : itype;
! itype = type.equalsIgnoreCase("file") ? InputChunk.INPUT_FILE : itype;
!
! if (itype != InputChunk.INPUT_TEXTAREA && itype != InputChunk.INPUT_HIDDEN && itype != InputChunk.INPUT_TEXT && itype != InputChunk.INPUT_PASSWORD && itype != InputChunk.INPUT_CHECKBOX && itype != InputChunk.INPUT_RADIO&& itype != InputChunk.INPUT_FILE) {
! state.setErrorWord(type);
! throw new Exception(type + " is not a valid input type");
! }
!
! attribs = atts.getValue("atts");
! attribs = (attribs != null) ? attribs : "";
! srcType = atts.getValue("srcType");
! if (srcType.equalsIgnoreCase("param")) isrcType = YesNo.SRC_PARAM;
! else if (srcType.equalsIgnoreCase("db")) isrcType = YesNo.SRC_DB;
! else if (srcType.equalsIgnoreCase("prop")) isrcType = YesNo.SRC_PROP;
! else {
! state.setErrorWord(srcType);
! throw new Exception(srcType + " is not a valid source type");
! }
!
! if (isrcType == YesNo.SRC_DB && val.indexOf(".") == -1) {
! state.setErrorWord("");
! throw new Exception("Not A Valid Source Field");
! }
!
! if (isrcType == YesNo.SRC_DB && state.getReport().getHead().getAllDBs().get(val.substring(0,val.indexOf("."))) == null) {
! state.setErrorWord(val);
! throw new Exception(val.substring(0,val.indexOf(".")) + " is not a valid DB");
! }
! state.getCurrentLine().addChunk(new InputChunk(name,itype,isrcType,val,value,attribs,paramFirst));
! }
!
! /**
! * Handles the formInput tag
! */
! public void formSelect(String val, Attributes atts) throws Exception {
! String name,srcType,type, attribs,value,srcDB,lstId,lstVal;
! int isrcType,isingle,itype=-1;
! boolean paramFirst;
! paramFirst = atts.getValue("paramFirst") != null ? atts.getValue("paramFirst").equalsIgnoreCase("true") : false;
! //System.out.println("Param First : " + paramFirst);
! value = atts.getValue("value");
! value = value != null ? value : "";
! name = atts.getValue("name");
! type = atts.getValue("type");
! attribs = atts.getValue("atts");
! attribs = (attribs != null) ? attribs : "";
! srcType = atts.getValue("srcType");
! if (srcType.equalsIgnoreCase("param")) isrcType = YesNo.SRC_PARAM;
! else if (srcType.equalsIgnoreCase("db")) isrcType = YesNo.SRC_DB;
! else if (srcType.equalsIgnoreCase("db")) isrcType = YesNo.SRC_PROP;
! else {
! state.setErrorWord(srcType);
! throw new Exception(srcType + " is not a valid source type");
! }
!
! srcDB = atts.getValue("srcDB");
!
! lstId = atts.getValue("srcID");
! lstVal = atts.getValue("srcVal");
! state.getCurrentLine().addChunk(new SelectChunk(name,itype,isrcType,val,value,attribs,paramFirst,srcDB,lstId,lstVal));
! }
! /**
! * allows for the execution of any wrap-up code at the hitting of the end tag
! */
! public void seal() throws Exception {
! if (state.getCurrentLine() != null)
! state.sealLine();
! if (state.getReport().getBody().isHTML()) {
! Line line = state.getCurrentLine();
! line.addChunk(new TextChunk("</BODY>"));
! state.sealLine();
! }
!
! Vector lines = state.popLines();
! // System.out.println("body lines : " + lines.size());
! state.getReport().getBody().setLines(lines);
! state.getReport().getBody().seal();
! }
!
!
!
!
}
--- 27,416 ----
public class Body extends net.sourceforge.idrs.deploy.compile.Compiler {
! /** Creates new Body */
! public Body() {
! }
! /**
! *allows for the compiler to work with the current state of the page compilation
! */
! public void setState(CompilerState state) throws Exception {
! super.setState(state);
! state.pushLines();
! }
! /**
! *allows for a compiler to use the attributes of the calling tag
! */
! public void setAttributes(Attributes atts) throws Exception {
! super.setAttributes(atts);
! String bodyTag;
! if (state.getReport().getBody().isHTML()) {
! Line line = state.getCurrentLine();
! //line.addChunk(new net.sourceforge.idrs.core.report.TextChunk("<BODY "));
! bodyTag = "<BODY ";
! for (int i = 0, m = atts.getLength(); i < m; i++) {
! bodyTag += atts.getLocalName(i)
! + "=\""
! + atts.getValue(i)
! + "\" ";
! }
! bodyTag += ">";
! System.out.println("Body tag : " + bodyTag);
! line.addChunk(new TextChunk(bodyTag));
! state.sealLine();
! }
+ }
! public void useMethod(String val, Attributes atts) throws Exception {
+ String objid = atts.getValue("objid");
+ String varlistId = atts.getValue("varlist");
+ LinkedList varList =
+ (LinkedList) ((HashMap) state.getAttribute("IDRS_VAR_LISTS")).get(
+ varlistId);
+ Line curr = state.getCurrentLine();
+ curr.addChunk(
+ new ObjectChunk(val, varList.toArray(), varlistId, objid));
! }
! public void field(String val, Attributes atts) throws Exception {
! if (val.equalsIgnoreCase("<LineNum>")
! || val.equalsIgnoreCase("<ForeColor>")
! || val.equalsIgnoreCase("<BackColor>")) {
! Line line = state.getCurrentLine();
! line.addChunk(
! new net.sourceforge.idrs.core.report.FieldChunk(
! "",
! val,
! "",
! state.getCurrentRepeatLine()));
! return;
! }
! if (val.indexOf(".") == -1) {
! state.setErrorWord(val);
! throw new Exception("No Period Found");
! }
! String format = atts.getValue("format");
! String id, field;
! id = val.substring(0, val.indexOf("."));
! field = val.substring(val.indexOf(".") + 1);
! if (state.getReport().getHead().getAllDBs().get(id) == null) {
! state.setErrorWord(id);
! throw new Exception(id + " is not a valid DB");
! }
! Line line = state.getCurrentLine();
! line.addChunk(
! new net.sourceforge.idrs.core.report.FieldChunk(
! id,
! field,
! format,
! state.getCurrentRepeatLine()));
! }
! public void error(String val, Attributes atts) throws Exception {
! Line line = state.getCurrentLine();
! line.addChunk(new net.sourceforge.idrs.core.report.ErrorChunk());
! }
! public void inputResults(String val, Attributes atts) throws Exception {
! if (state.getReport().getHead().getAllDBs().get(val) == null) {
! state.setErrorWord(val);
! throw new Exception(val + " is not a valid DB");
! }
! Line line = state.getCurrentLine();
! line.addChunk(
! new net.sourceforge.idrs.core.report.InputResultsChunk(val));
! }
! public void script(String val, Attributes atts) throws Exception {
! state.getCurrentLine().addChunk(
! new net.sourceforge.idrs.core.report.ShortScriptChunk(val));
! }
! public void echoScript(String val, Attributes atts) throws Exception {
! state.getCurrentLine().addChunk(
! new net.sourceforge.idrs.core.report.EvalScriptChunk(val));
! }
! public void text(String val, Attributes atts) throws Exception {
! //System.out.println("val = \"" + val + "\"");
! //System.out.println("this is : " + this);
! /*if (val.indexOf('\n') != -1) {
! StringTokenizer tok = new StringTokenizer(val,"\n",false);
! Line line;
! while (tok.hasMoreTokens()) {
! line = state.getCurrentLine();
! line.addChunk(new net.sourceforge.idrs.core.report.TextChunk(tok.nextToken()));
! state.sealLine();
! }
! }
! else {
! state.getCurrentLine().addChunk(new TextChunk(val));
! }*/
! state.getCurrentLine().addChunk(new TextChunk(val));
! }
! /**
! * Handles the yesNo tag
! */
! public void yesNo(String val, Attributes atts) throws Exception {
! String name, srcType, single, attribs;
! int isrcType, isingle;
! boolean paramFirst = false;
! name = atts.getValue("name");
! paramFirst =
! atts.getValue("paramFirst") != null
! ? atts.getValue("paramFirst").equalsIgnoreCase("true")
! : false;
! single = atts.getValue("single");
! if (single == null || single.equalsIgnoreCase("")) {
! isingle = YesNo.NOT_SINGLE;
! } else {
! isingle =
! single.equalsIgnoreCase("yes")
! ? YesNo.SINGLE_YES
! : YesNo.SINGLE_NO;
! }
! attribs = atts.getValue("atts");
! attribs = (attribs != null) ? attribs : "";
+ srcType = atts.getValue("srcType");
+ if (srcType.equalsIgnoreCase("param"))
+ isrcType = YesNo.SRC_PARAM;
+ else if (srcType.equalsIgnoreCase("db"))
+ isrcType = YesNo.SRC_DB;
+ else if (srcType.equalsIgnoreCase("db"))
+ isrcType = YesNo.SRC_PROP;
+ else {
+ state.setErrorWord(srcType);
+ throw new Exception(srcType + " is not a valid source type");
+ }
! if (isrcType == YesNo.SRC_DB && val.indexOf(".") == -1) {
! state.setErrorWord(val);
! throw new Exception("Not A Valid Source Field");
! }
+ if (isrcType == YesNo.SRC_DB
+ && state.getReport().getHead().getAllDBs().get(
+ val.substring(0, val.indexOf(".")))
+ == null) {
+ state.setErrorWord(val);
+ throw new Exception(
+ val.substring(0, val.indexOf(".")) + " is not a valid DB");
+ }
! int iboolType;
! if (atts.getValue("boolType") != null
! && atts.getValue("boolType").length() != 0) {
! iboolType =
! atts.getValue("boolType").equals("int")
! ? YesNo.BOOL_INT
! : YesNo.BOOL_TF;
! } else {
! iboolType = YesNo.BOOL_INT;
! }
! state.getCurrentLine().addChunk(
! new YesNo(
! name,
! isingle,
! isrcType,
! val,
! attribs,
! paramFirst,
! iboolType));
! }
! public void navNext(String val, Attributes atts) throws Exception {
! state.getCurrentLine().addChunk(new NavNextChunk(val));
! }
! public void navPrev(String val, Attributes atts) throws Exception {
! state.getCurrentLine().addChunk(new NavPrevChunk(val));
! }
! public void navCur(String val, Attributes atts) throws Exception {
! state.getCurrentLine().addChunk(new NavCurChunk(val));
! }
! /**
! * Handles the formInput tag
! */
! public void formInput(String val, Attributes atts) throws Exception {
! String name, srcType, type, attribs, value;
! int isrcType, isingle, itype = -1;
! boolean paramFirst;
! paramFirst =
! atts.getValue("paramFirst") != null
! ? atts.getValue("paramFirst").equalsIgnoreCase("true")
! : false;
! // System.out.println("Param First : " + paramFirst);
+ value = atts.getValue("value");
+ value = value != null ? value : "";
! name = atts.getValue("name");
! type = atts.getValue("type");
! itype =
! type.equalsIgnoreCase("hidden") ? InputChunk.INPUT_HIDDEN : itype;
! itype = type.equalsIgnoreCase("text") ? InputChunk.INPUT_TEXT : itype;
! itype =
! type.equalsIgnoreCase("password")
! ? InputChunk.INPUT_PASSWORD
! : itype;
! itype =
! type.equalsIgnoreCase("checkbox")
! ? InputChunk.INPUT_CHECKBOX
! : itype;
! itype = type.equalsIgnoreCase("radio") ? InputChunk.INPUT_RADIO : itype;
! itype =
! type.equalsIgnoreCase("textarea")
! ? InputChunk.INPUT_TEXTAREA
! : itype;
! itype = type.equalsIgnoreCase("file") ? InputChunk.INPUT_FILE : itype;
+ if (itype != InputChunk.INPUT_TEXTAREA
+ && itype != InputChunk.INPUT_HIDDEN
+ && itype != InputChunk.INPUT_TEXT
+ && itype != InputChunk.INPUT_PASSWORD
+ && itype != InputChunk.INPUT_CHECKBOX
+ && itype != InputChunk.INPUT_RADIO
+ && itype != InputChunk.INPUT_FILE) {
+ state.setErrorWord(type);
+ throw new Exception(type + " is not a valid input type");
+ }
+ attribs = atts.getValue("atts");
+ attribs = (attribs != null) ? attribs : "";
! srcType = atts.getValue("srcType");
! if (srcType.equalsIgnoreCase("param"))
! isrcType = YesNo.SRC_PARAM;
! else if (srcType.equalsIgnoreCase("db"))
! isrcType = YesNo.SRC_DB;
! else if (srcType.equalsIgnoreCase("prop"))
! isrcType = YesNo.SRC_PROP;
! else {
! state.setErrorWord(srcType);
! throw new Exception(srcType + " is not a valid source type");
! }
! if (isrcType == YesNo.SRC_DB && val.indexOf(".") == -1) {
! state.setErrorWord("");
! throw new Exception("Not A Valid Source Field");
! }
! if (isrcType == YesNo.SRC_DB
! && state.getReport().getHead().getAllDBs().get(
! val.substring(0, val.indexOf(".")))
! == null) {
! state.setErrorWord(val);
! throw new Exception(
! val.substring(0, val.indexOf(".")) + " is not a valid DB");
! }
!
! state.getCurrentLine().addChunk(
! new InputChunk(
! name,
! itype,
! isrcType,
! val,
! value,
! attribs,
! paramFirst));
!
! }
!
! /**
! * Handles the formInput tag
! */
! public void formSelect(String val, Attributes atts) throws Exception {
! String name, srcType, type, attribs, value, srcDB, lstId, lstVal;
! int isrcType, isingle, itype = -1;
! boolean paramFirst;
!
! paramFirst =
! atts.getValue("paramFirst") != null
! ? atts.getValue("paramFirst").equalsIgnoreCase("true")
! : false;
! //System.out.println("Param First : " + paramFirst);
!
! value = atts.getValue("value");
!
! value = value != null ? value : "";
!
! name = atts.getValue("name");
! type = atts.getValue("type");
!
! attribs = atts.getValue("atts");
! attribs = (attribs != null) ? attribs : "";
!
! srcType = atts.getValue("srcType");
! if (srcType.equalsIgnoreCase("param"))
! isrcType = YesNo.SRC_PARAM;
! else if (srcType.equalsIgnoreCase("db"))
! isrcType = YesNo.SRC_DB;
! else if (srcType.equalsIgnoreCase("db"))
! isrcType = YesNo.SRC_PROP;
! else {
! state.setErrorWord(srcType);
! throw new Exception(srcType + " is not a valid source type");
! }
!
! srcDB = atts.getValue("srcDB");
!
! lstId = atts.getValue("srcID");
! lstVal = atts.getValue("srcVal");
!
! state.getCurrentLine().addChunk(
! new SelectChunk(
! name,
! itype,
! isrcType,
! val,
! value,
! attribs,
! paramFirst,
! srcDB,
! lstId,
! lstVal));
!
! }
!
! /**
! * allows for the execution of any wrap-up code at the hitting of the end tag
! */
! public void seal() throws Exception {
! if (state.getCurrentLine() != null)
! state.sealLine();
! if (state.getReport().getBody().isHTML()) {
! Line line = state.getCurrentLine();
! line.addChunk(new TextChunk("</BODY>"));
! state.sealLine();
! }
!
! Vector lines = state.popLines();
! // System.out.println("body lines : " + lines.size());
! state.getReport().getBody().setLines(lines);
! state.getReport().getBody().seal();
! }
}
|