/* SortedHeader822.java * * Copyright (c) 2002, Benja Fallenstein * * You may use and distribute under the terms of either the GNU Lesser * General Public License, either version 2 of the license or, * at your choice, any later version. Alternatively, you may use and * distribute under the terms of the XPL. * * See the LICENSE.lgpl and LICENSE.xpl files for the specific terms of * the licenses. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the README * file for more details. * */ /* * Written by Benja Fallenstein */ package gzz.util.headers; import gzz.util.*; import java.io.*; import java.util.*; public class SortedHeader822 extends ModularHeader822 { public SortedHeader822() { super(null, new SortedHeaderMap822()); } public SortedHeader822(Header822 initializeWith) { super(null, new SortedHeaderMap822(initializeWith)); } public List getLines() { ArrayList lines = new ArrayList(); for(Iterator i=map.keySet().iterator(); i.hasNext();) { String fieldName = (String)i.next(); Collection values = map.getAll(fieldName); for(Iterator j = values.iterator(); i.hasNext();) { String fieldValue = (String)i.next(); fieldValue = HeaderUtil.canonicalizeFieldName(fieldName); lines.add(fieldName + ": " + fieldValue); // no folding } } return lines; } public void writeTo(OutputStream out) throws IOException { HeaderUtil.writeHeader(out, getLines()); } }