Return-Path: Delivered-To: apmail-xml-cocoon-cvs-archive@xml.apache.org Received: (qmail 34700 invoked by uid 500); 22 Jun 2001 08:32:35 -0000 Mailing-List: contact cocoon-cvs-help@xml.apache.org; run by ezmlm Precedence: bulk Reply-To: cocoon-dev@xml.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list cocoon-cvs@xml.apache.org Received: (qmail 34656 invoked by uid 500); 22 Jun 2001 08:32:34 -0000 Delivered-To: apmail-xml-cocoon2-cvs@apache.org Date: 22 Jun 2001 08:32:33 -0000 Message-ID: <20010622083233.34516.qmail@apache.org> From: cziegeler@apache.org To: xml-cocoon2-cvs@apache.org Subject: cvs commit: xml-cocoon2/bin/src st.java cziegeler 01/06/22 01:32:33 Modified: . build.xml Added: bin st.class bin/src st.java Log: Added sitemap command line tool which can add component declarations during the build process Revision Changes Path 1.19 +21 -2 xml-cocoon2/build.xml Index: build.xml =================================================================== RCS file: /home/cvs/xml-cocoon2/build.xml,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- build.xml 2001/06/21 13:08:56 1.18 +++ build.xml 2001/06/22 08:32:28 1.19 @@ -348,9 +348,9 @@ - + - + @@ -374,7 +374,26 @@ + + + + + + + + + + + + + + + + + + + 1.1 xml-cocoon2/bin/st.class <> 1.1 xml-cocoon2/bin/src/st.java Index: st.java =================================================================== /***************************************************************************** * Copyright (C) The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of which has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ import java.io.*; /** * This is a quick and dirty commandline tool which can add new * component definitions to the sitemap. * * Parameters: * -i input sitemap * -o output sitemap * -a * * Example: * st -i sitemap.xmpa -o sitemap.xmap -a transformers log * org.apache.cocoon.transformation.LogTransformer * * this would add: * * to the transformers section (category). * * ToDo: * Pretty printing * * @author Carsten Ziegeler * @version CVS $Revision: 1.1 $ $Date: 2001/06/22 08:32:31 $ */ public class st { public static String load(String filename) throws IOException { FileInputStream fis; fis = new FileInputStream(filename); int available; byte[] data = null; byte[] tempData; byte[] copyData; do { available = 1024; tempData = new byte[available]; available = fis.read(tempData, 0, available); if (available > 0) { copyData = new byte[(data == null ? 0 : data.length) + available]; if (data != null) { System.arraycopy(data, 0, copyData, 0, data.length); } System.arraycopy(tempData, 0, copyData, (data == null ? 0 : data.length), available); data = copyData; } } while (available > 0); fis.close(); return (data != null ? new String(data) : ""); } public static void save(String filename, String data) throws IOException { FileWriter fw = new FileWriter(filename); fw.write(data); fw.close(); } public static void main(String[] args) { String inputName; String outputName; String arg; int mode = 0; String arg1=null, arg2=null, arg3=null, arg4=null; boolean clError = false; inputName = null; outputName = null; int i; i = 0; while (i < args.length && clError == false) { arg = args[i]; if (arg.equals("-i") == true) { if (i + 1 < args.length) inputName = args[i+1]; else clError = true; i += 2; } else if (arg.equals("-o") == true) { if (i + 1 < args.length) outputName = args[i+1]; else clError = true; i += 2; } else if (arg.equals("-a") == true) { if (i + 3 < args.length && mode == 0) { mode = 1; // add arg1 = args[i+1]; arg2 = args[i+2]; arg3 = args[i+3]; if (i + 4 < args.length && !args[i+4].startsWith("-")) { arg4 = args[i+4]; i++; } else { arg4 = null; } i += 4; } else { clError = true; } } else { clError = true; } } if (inputName == null || outputName == null) { clError = true; } if (mode == 0) { clError = true; } if (clError == true) { System.out.println("Usage: st -i [inputsitemap] -o [outputsitemap] -a [componentcategory]"+ " [componentname] [class] [optionalconfigurationstring]"); } else { try { String data = load(inputName); if (mode == 1) { // add a component // arg1 : category // arg2 : componentname // arg3 : class // arg4 : optional configuration String searchString = ""; int pos = data.indexOf(searchString); System.out.println("Found ("+searchString+") at " +pos); if (pos != -1) { data = data.substring(0, pos) + "\n" : ">\n"+arg4+"\n" + "\n") + data.substring(pos); } } save(outputName, data); } catch (IOException ioe) { System.err.println("Exception: " + ioe); ioe.printStackTrace(); } } } } ---------------------------------------------------------------------- In case of troubles, e-mail: webmaster@xml.apache.org To unsubscribe, e-mail: cocoon-cvs-unsubscribe@xml.apache.org For additional commands, e-mail: cocoon-cvs-help@xml.apache.org