--- /dev/null
+// SegmentArrayAttribute.java\r
+// $Id: SegmentArrayAttribute.java,v 1.1 2010/06/15 12:26:37 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.jigsaw.ssi ;\r
+\r
+import org.w3c.tools.resources.ArrayAttribute;\r
+import org.w3c.tools.resources.Attribute;\r
+\r
+import org.w3c.util.CountOutputStream;\r
+\r
+/**\r
+ * Attribute used to make the document segment information persistent.\r
+ * @author Antonio Ramirez <anto@mit.edu>\r
+ */ \r
+public class SegmentArrayAttribute extends ArrayAttribute {\r
+\r
+ public boolean checkValue(Object value)\r
+ {\r
+ return (value instanceof Segment[] || value == null);\r
+ }\r
+\r
+ /**\r
+ * Unpickle an attribute array from a string array.\r
+ * @param array the String array\r
+ * @return a Object array\r
+ */\r
+ public Object unpickle(String array[]) {\r
+ Segment segs[] = new Segment [array.length] ;\r
+ for (int i = 0 ; i < array.length ; i++) \r
+ segs[i] = Segment.unpickle(array[i]) ;\r
+ return segs;\r
+ }\r
+\r
+ /**\r
+ * Pickle an attribute array into a String array.\r
+ * @param array the attribute array\r
+ * @return a String array\r
+ */\r
+ public String[] pickle(Object obj) {\r
+ Segment[] segs = (Segment[]) obj ;\r
+ String strings[] = new String[segs.length];\r
+ for (int i = 0 ; i < segs.length ; i++) {\r
+ strings[i] = segs[i].pickle();\r
+ }\r
+ return strings;\r
+ }\r
+\r
+ public SegmentArrayAttribute(String name, Segment[] def, int flags)\r
+ {\r
+ super(name,def,flags) ;\r
+ this.type = "[Lorg.w3c.jigsaw.ssi.Segment;";\r
+ }\r
+\r
+ public SegmentArrayAttribute() {\r
+ super();\r
+ this.type = "[Lorg.w3c.jigsaw.ssi.Segment;";\r
+ }\r
+\r
+ public String stringify(Object value)\r
+ {\r
+ Segment[] segs = (Segment[]) value ;\r
+ StringBuffer buf = new StringBuffer(160) ;\r
+ buf.append('[') ;\r
+ for(int i=0;i<segs.length;i++) {\r
+ buf.append(segs[i].toString()) ;\r
+ buf.append(' ') ;\r
+ }\r
+ buf.append(']') ;\r
+ return buf.toString() ;\r
+ }\r
+}\r