--- /dev/null
+// HttpWarningList.java\r
+// $Id: HttpWarningList.java,v 1.1 2010/06/15 12:19:44 smhuang Exp $\r
+// (c) COPYRIGHT MIT and INRIA, 1996.\r
+// Please first read the full copyright statement in file COPYRIGHT.html\r
+\r
+package org.w3c.www.http;\r
+\r
+import java.util.Vector;\r
+\r
+public class HttpWarningList extends BasicValue {\r
+ HttpWarning warnings[] = null;\r
+\r
+ protected void parse() {\r
+ Vector ws = new Vector(4);\r
+ ParseState ps = new ParseState(roff, rlen);\r
+ ps.spaceIsSep = false;\r
+ while (HttpParser.nextItem(raw, ps) >= 0) {\r
+ ws.addElement(new HttpWarning(this, raw, ps.start, ps.end));\r
+ ps.prepare();\r
+ }\r
+ warnings = new HttpWarning[ws.size()];\r
+ ws.copyInto(warnings);\r
+ }\r
+\r
+ protected void updateByteValue() {\r
+ HttpBuffer buf = new HttpBuffer();\r
+ for (int i = 0 ; i < warnings.length ; i++) {\r
+ if ( i > 0 )\r
+ buf.append(',');\r
+ warnings[i].appendValue(buf);\r
+ }\r
+ raw = buf.getByteCopy();\r
+ roff = 0;\r
+ rlen = raw.length;\r
+ }\r
+\r
+ public Object getValue() {\r
+ validate();\r
+ return warnings;\r
+ }\r
+\r
+ /**\r
+ * Add a warning to that list.\r
+ * @param w The warning to add.\r
+ */\r
+\r
+ public void addWarning(HttpWarning w) {\r
+ if ( warnings == null ) {\r
+ warnings = new HttpWarning[1];\r
+ warnings[0] = w;\r
+ } else {\r
+ int len = warnings.length;\r
+ HttpWarning newwarn[] = new HttpWarning[len+1];\r
+ System.arraycopy(warnings, 0, newwarn, 0, len);\r
+ newwarn[len] = w;\r
+ warnings = newwarn;\r
+ }\r
+ }\r
+\r
+ HttpWarningList() {\r
+ this.isValid = false;\r
+ }\r
+\r
+ HttpWarningList(HttpWarning warnings[]) {\r
+ this.isValid = true;\r
+ this.warnings = warnings;\r
+ }\r
+\r
+ HttpWarningList(HttpWarning warning) {\r
+ this.isValid = true;\r
+ this.warnings = new HttpWarning[1];\r
+ this.warnings[0] = warning;\r
+ }\r
+}\r