jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edgarp...@apache.org
Subject svn commit: r312896 [4/6] - in /incubator/jackrabbit/trunk/contrib/jcr-commands: ./ src/java/org/apache/jackrabbit/command/ src/java/org/apache/jackrabbit/command/cli/ src/java/org/apache/jackrabbit/command/collect/ src/java/org/apache/jackrabbit/comma...
Date Tue, 11 Oct 2005 14:41:03 GMT
Modified: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/fs/ExportPropertyToFile.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/fs/ExportPropertyToFile.java?rev=312896&r1=312895&r2=312896&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/fs/ExportPropertyToFile.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/fs/ExportPropertyToFile.java Tue Oct 11 07:38:54 2005
@@ -40,173 +40,167 @@
 import org.apache.jackrabbit.command.CommandHelper;
 
 /**
- * Exports a property value of the current working node to the file system.
+ * Exports a <code>Property</code> <code>Value</code> of the current working
+ * <code>Node<code> to the file system.
  */
-public class ExportPropertyToFile implements Command
-{
-	/** logger */
-	private static Log log = LogFactory.getLog(ExportPropertyToFile.class);
-
-	// ---------------------------- < keys >
-
-	/** property name */
-	private String nameKey = "name";
-
-	/** value index */
-	private String indexKey = "index";
-
-	/** target file */
-	private String destFsPathKey = "destFsPath";
-
-	/** overwrite the target file if necessary */
-	private String overwriteKey = "overwrite";
-
-	/**
-	 * @inheritDoc
-	 */
-	public boolean execute(Context ctx) throws Exception
-	{
-		String name = (String) ctx.get(this.nameKey);
-		Integer index = (Integer) ctx.get(this.indexKey);
-		String to = (String) ctx.get(this.destFsPathKey);
-
-		Node n = CommandHelper.getCurrentNode(ctx);
-
-		if (log.isDebugEnabled())
-		{
-			log.debug("exporting property value from " + n.getPath() + "/"
-					+ name + " to the filesystem: " + to);
-		}
-
-		Property p = n.getProperty(name);
-		if (p.getDefinition().isMultiple())
-		{
-			exportValue(ctx, p.getValues()[index.intValue()], to);
-		} else
-		{
-			exportValue(ctx, p.getValue(), to);
-		}
-		return false;
-	}
-
-	/**
-	 * Export th given value to a File
-	 * 
-	 * @param ctx
-	 * @param value
-	 * @throws CommandException
-	 * @throws IOException
-	 * @throws RepositoryException
-	 * @throws IllegalStateException
-	 */
-	private void exportValue(Context ctx, Value value, String to)
-			throws CommandException, IOException, IllegalStateException,
-			RepositoryException
-	{
-		boolean overwrite = Boolean
-				.valueOf((String) ctx.get(this.overwriteKey)).booleanValue();
-
-		File file = new File(to);
-
-		// Check if there's a file at the given target path
-		if (file.exists() && !overwrite)
-		{
-			throw new CommandException("exception.file.exists", new String[]
-			{ to });
-		}
-
-		// If it doesn't exists create the file
-		if (!file.exists())
-		{
-			file.createNewFile();
-		}
-
-		if (value.getType() == PropertyType.BINARY)
-		{
-			InputStream in = value.getStream();
-			BufferedOutputStream out = new BufferedOutputStream(
-					new FileOutputStream(file));
-			int c;
-			while ((c = in.read()) != -1)
-			{
-				out.write(c);
-			}
-			in.close();
-			out.flush();
-			out.close();
-		} else
-		{
-			Reader in = new StringReader(value.getString());
-			BufferedWriter out = new BufferedWriter(new FileWriter(file));
-			int c;
-			while ((c = in.read()) != -1)
-			{
-				out.write(c);
-			}
-			in.close();
-			out.flush();
-			out.close();
-		}
-	}
-
-	/**
-	 * @return Returns the indexKey.
-	 */
-	public String getIndexKey()
-	{
-		return indexKey;
-	}
-
-	/**
-	 * @param indexKey
-	 *            Set the context attribute key for the index attribute.
-	 */
-	public void setIndexKey(String indexKey)
-	{
-		this.indexKey = indexKey;
-	}
-
-	/**
-	 * @return Returns the nameKey.
-	 */
-	public String getNameKey()
-	{
-		return nameKey;
-	}
-
-	/**
-	 * @param nameKey
-	 *            Set the context attribute key for the name attribute.
-	 */
-	public void setNameKey(String nameKey)
-	{
-		this.nameKey = nameKey;
-	}
-
-	/**
-	 * @return Returns the overwriteKey.
-	 */
-	public String getOverwriteKey()
-	{
-		return overwriteKey;
-	}
-
-	/**
-	 * @param overwriteKey
-	 *            Set the context attribute key for the overwrite attribute.
-	 */
-	public void setOverwriteKey(String overwriteKey)
-	{
-		this.overwriteKey = overwriteKey;
-	}
-
-	public String getDestFsPathKey()
-	{
-		return destFsPathKey;
-	}
-
-	public void setDestFsPathKey(String destFsPathKey)
-	{
-		this.destFsPathKey = destFsPathKey;
-	}
+public class ExportPropertyToFile implements Command {
+    /** logger */
+    private static Log log = LogFactory.getLog(ExportPropertyToFile.class);
+
+    // ---------------------------- < keys >
+
+    /** property name */
+    private String nameKey = "name";
+
+    /** value index */
+    private String indexKey = "index";
+
+    /** target file */
+    private String destFsPathKey = "destFsPath";
+
+    /** overwrite the target file if necessary */
+    private String overwriteKey = "overwrite";
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean execute(Context ctx) throws Exception {
+        String name = (String) ctx.get(this.nameKey);
+        Integer index = (Integer) ctx.get(this.indexKey);
+        String to = (String) ctx.get(this.destFsPathKey);
+
+        Node n = CommandHelper.getCurrentNode(ctx);
+
+        if (log.isDebugEnabled()) {
+            log.debug("exporting property value from " + n.getPath() + "/"
+                    + name + " to the filesystem: " + to);
+        }
+
+        Property p = n.getProperty(name);
+        if (p.getDefinition().isMultiple()) {
+            exportValue(ctx, p.getValues()[index.intValue()], to);
+        } else {
+            exportValue(ctx, p.getValue(), to);
+        }
+        return false;
+    }
+
+    /**
+     * Export th given value to a File
+     * @param ctx
+     *        the <code>Context</code>
+     * @param value
+     *        the <code>Value</code>
+     * @param to
+     *        the target file system path
+     * @throws CommandException
+     *         if the <code>File</code> already exists
+     * @throws IOException
+     *         if an <code>IOException</code> occurs
+     * @throws RepositoryException
+     *         if the current working <code>Repository</code> throws an
+     *         <code>Exception</code>
+     */
+    private void exportValue(Context ctx, Value value, String to)
+            throws CommandException, IOException, RepositoryException {
+        boolean overwrite = Boolean
+            .valueOf((String) ctx.get(this.overwriteKey)).booleanValue();
+
+        File file = new File(to);
+
+        // Check if there's a file at the given target path
+        if (file.exists() && !overwrite) {
+            throw new CommandException("exception.file.exists", new String[] {
+                to
+            });
+        }
+
+        // If it doesn't exists create the file
+        if (!file.exists()) {
+            file.createNewFile();
+        }
+
+        if (value.getType() == PropertyType.BINARY) {
+            InputStream in = value.getStream();
+            BufferedOutputStream out = new BufferedOutputStream(
+                new FileOutputStream(file));
+            int c;
+            while ((c = in.read()) != -1) {
+                out.write(c);
+            }
+            in.close();
+            out.flush();
+            out.close();
+        } else {
+            Reader in = new StringReader(value.getString());
+            BufferedWriter out = new BufferedWriter(new FileWriter(file));
+            int c;
+            while ((c = in.read()) != -1) {
+                out.write(c);
+            }
+            in.close();
+            out.flush();
+            out.close();
+        }
+    }
+
+    /**
+     * @return the index key
+     */
+    public String getIndexKey() {
+        return indexKey;
+    }
+
+    /**
+     * @param indexKey
+     *        the index key to set
+     */
+    public void setIndexKey(String indexKey) {
+        this.indexKey = indexKey;
+    }
+
+    /**
+     * @return the name key
+     */
+    public String getNameKey() {
+        return nameKey;
+    }
+
+    /**
+     * @param nameKey
+     *        the name key to set
+     */
+    public void setNameKey(String nameKey) {
+        this.nameKey = nameKey;
+    }
+
+    /**
+     * @return the overwrite key
+     */
+    public String getOverwriteKey() {
+        return overwriteKey;
+    }
+
+    /**
+     * @param overwriteKey
+     *        the overwrite key to set
+     */
+    public void setOverwriteKey(String overwriteKey) {
+        this.overwriteKey = overwriteKey;
+    }
+
+    /**
+     * @return the destination file system path key
+     */
+    public String getDestFsPathKey() {
+        return destFsPathKey;
+    }
+
+    /**
+     * @param destFsPathKey
+     *        the destination file system path key to set
+     */
+    public void setDestFsPathKey(String destFsPathKey) {
+        this.destFsPathKey = destFsPathKey;
+    }
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/fs/ImportFileSystem.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/fs/ImportFileSystem.java?rev=312896&r1=312895&r2=312896&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/fs/ImportFileSystem.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/fs/ImportFileSystem.java Tue Oct 11 07:38:54 2005
@@ -33,163 +33,153 @@
 import org.apache.jackrabbit.command.CommandException;
 
 /**
- * This command imports data from the file system. <br>
- * If the given path refers to a file it's imported to a node of type nt:file
- * under the current working node. <br>
+ * Import data from the file system. <br>
+ * If the given path refers to a file it's imported to a <code>Node</code> of
+ * type nt:file under the current working <code>Node<code>.<br>
  * If the given path refers to a folder, the given folder and all the subtree is
- * imported
+ * imported.
  */
-public class ImportFileSystem implements Command
-{
-	/** logger */
-	private static Log log = LogFactory.getLog(ImportFileSystem.class);
-
-	/** extension to mime type mapping */
-	private static Properties mimeTypes;
-
-	static
-	{
-		try
-		{
-			mimeTypes = new Properties();
-			mimeTypes.load(ImportFileSystem.class
-					.getResourceAsStream("mimetypes.properties"));
-		} catch (Exception e)
-		{
-			log.error("unable to load mime types", e);
-		}
-	}
-
-	// ---------------------------- < keys >
-
-	/** File system path key */
-	private String srcFsPathKey = "srcFsPath";
-
-	public boolean execute(Context ctx) throws Exception
-	{
-		String file = (String) ctx.get(this.srcFsPathKey);
-		Node parent = CommandHelper.getCurrentNode(ctx);
-
-		if (log.isDebugEnabled())
-		{
-			log.debug("importing filesystem from " + file + " to node "
-					+ parent);
-		}
-
-		if (file == null)
-		{
-			throw new CommandException("exception.fspath.is.null");
-		}
-
-		File f = new File(file);
-
-		if (!f.exists())
-		{
-			throw new CommandException("exception.file.not.found", new String[]
-			{ file });
-		}
-
-		if (f.isFile())
-		{
-			this.importFile(parent, f);
-		} else
-		{
-			Node folder = parent.addNode(f.getName(), "nt:folder");
-			this.importFolder(folder, f);
-		}
-
-		return false;
-	}
-
-	/**
-	 * Imports a File.
-	 * 
-	 * @param parentnode
-	 *            Parent Repository Node
-	 * @param file
-	 *            File to be imported
-	 * @throws RepositoryException
-	 *             on repository errors, IOException on io errors
-	 */
-
-	private void importFile(Node parentnode, File file)
-			throws RepositoryException, IOException
-	{
-		String mimeType = null;
-		String extension = getExtension(file.getName());
-		if (extension != null)
-		{
-			mimeType = mimeTypes.getProperty(extension);
-		}
-		if (mimeType == null)
-		{
-			mimeType = "application/octet-stream";
-		}
-
-		Node fileNode = parentnode.addNode(file.getName(), "nt:file");
-		Node resNode = fileNode.addNode("jcr:content", "nt:resource");
-		resNode.setProperty("jcr:mimeType", mimeType);
-		resNode.setProperty("jcr:encoding", "");
-		resNode.setProperty("jcr:data", new FileInputStream(file));
-		Calendar lastModified = Calendar.getInstance();
-		lastModified.setTimeInMillis(file.lastModified());
-		resNode.setProperty("jcr:lastModified", lastModified);
-	}
-
-	/**
-	 * Import a Folder.
-	 * 
-	 * @param parentnode
-	 *            Parent Repository Node
-	 * @param directory
-	 *            Directory to be traversed
-	 * @throws RepositoryException
-	 *             on repository errors, IOException on io errors
-	 */
-
-	private void importFolder(Node parentnode, File directory)
-			throws RepositoryException, IOException
-	{
-		File[] direntries = directory.listFiles();
-		for (int i = 0; i < direntries.length; i++)
-		{
-			File direntry = direntries[i];
-			if (direntry.isDirectory())
-			{
-				Node childnode = parentnode.addNode(direntry.getName(),
-						"nt:folder");
-				importFolder(childnode, direntry);
-			} else
-			{
-				importFile(parentnode, direntry);
-			}
-		}
-	}
-
-	private String getExtension(String name)
-	{
-		String ext = null;
-		if (name.lastIndexOf('.') != -1)
-		{
-			ext = name.substring(name.lastIndexOf('.') + 1);
-		}
-		return ext;
-	}
-
-	/**
-	 * @return Returns the fromKey.
-	 */
-	public String getSrcFsPathKey()
-	{
-		return srcFsPathKey;
-	}
-
-	/**
-	 * @param fromKey
-	 *            Set the context attribute key for the from attribute.
-	 */
-	public void setSrcFsPathKey(String fromKey)
-	{
-		this.srcFsPathKey = fromKey;
-	}
+public class ImportFileSystem implements Command {
+    /** logger */
+    private static Log log = LogFactory.getLog(ImportFileSystem.class);
+
+    /** extension to mime type mapping */
+    private static Properties mimeTypes;
+
+    static {
+        try {
+            mimeTypes = new Properties();
+            mimeTypes.load(ImportFileSystem.class
+                .getResourceAsStream("mimetypes.properties"));
+        } catch (Exception e) {
+            log.error("unable to load mime types", e);
+        }
+    }
+
+    // ---------------------------- < keys >
+
+    /** File system path key */
+    private String srcFsPathKey = "srcFsPath";
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean execute(Context ctx) throws Exception {
+        String file = (String) ctx.get(this.srcFsPathKey);
+        Node parent = CommandHelper.getCurrentNode(ctx);
+
+        if (log.isDebugEnabled()) {
+            log.debug("importing filesystem from " + file + " to node "
+                    + parent);
+        }
+
+        if (file == null) {
+            throw new CommandException("exception.fspath.is.null");
+        }
+
+        File f = new File(file);
+
+        if (!f.exists()) {
+            throw new CommandException("exception.file.not.found",
+                new String[] {
+                    file
+                });
+        }
+
+        if (f.isFile()) {
+            this.importFile(parent, f);
+        } else {
+            Node folder = parent.addNode(f.getName(), "nt:folder");
+            this.importFolder(folder, f);
+        }
+
+        return false;
+    }
+
+    /**
+     * Imports a File.
+     * @param parentnode
+     *        Parent <code>Node</code>
+     * @param file
+     *        <code>File</code> to be imported
+     * @throws RepositoryException
+     *         on <code>Repository</code> errors
+     * @throws IOException
+     *         on io errors
+     */
+
+    private void importFile(Node parentnode, File file)
+            throws RepositoryException, IOException {
+        String mimeType = null;
+        String extension = getExtension(file.getName());
+        if (extension != null) {
+            mimeType = mimeTypes.getProperty(extension);
+        }
+        if (mimeType == null) {
+            mimeType = "application/octet-stream";
+        }
+
+        Node fileNode = parentnode.addNode(file.getName(), "nt:file");
+        Node resNode = fileNode.addNode("jcr:content", "nt:resource");
+        resNode.setProperty("jcr:mimeType", mimeType);
+        resNode.setProperty("jcr:encoding", "");
+        resNode.setProperty("jcr:data", new FileInputStream(file));
+        Calendar lastModified = Calendar.getInstance();
+        lastModified.setTimeInMillis(file.lastModified());
+        resNode.setProperty("jcr:lastModified", lastModified);
+    }
+
+    /**
+     * Import a Folder.
+     * @param parentnode
+     *        Parent <code>Node</code>
+     * @param directory
+     *        File system directory to traverse
+     * @throws RepositoryException
+     *         on repository errors
+     * @throws IOException
+     *         on io errors
+     */
+    private void importFolder(Node parentnode, File directory)
+            throws RepositoryException, IOException {
+        File[] direntries = directory.listFiles();
+        for (int i = 0; i < direntries.length; i++) {
+            File direntry = direntries[i];
+            if (direntry.isDirectory()) {
+                Node childnode = parentnode.addNode(direntry.getName(),
+                    "nt:folder");
+                importFolder(childnode, direntry);
+            } else {
+                importFile(parentnode, direntry);
+            }
+        }
+    }
+
+    /**
+     * @param name
+     *        the file name
+     * @return the extension for the given file name
+     */
+    private String getExtension(String name) {
+        String ext = null;
+        if (name.lastIndexOf('.') != -1) {
+            ext = name.substring(name.lastIndexOf('.') + 1);
+        }
+        return ext;
+    }
+
+    /**
+     * @return the from key
+     */
+    public String getSrcFsPathKey() {
+        return srcFsPathKey;
+    }
+
+    /**
+     * @param fromKey
+     *        the from key to set
+     */
+    public void setSrcFsPathKey(String fromKey) {
+        this.srcFsPathKey = fromKey;
+    }
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/fs/SetPropertyFromFile.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/fs/SetPropertyFromFile.java?rev=312896&r1=312895&r2=312896&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/fs/SetPropertyFromFile.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/fs/SetPropertyFromFile.java Tue Oct 11 07:38:54 2005
@@ -34,55 +34,50 @@
 import org.apache.jackrabbit.command.core.AbstractSetProperty;
 
 /**
- * Set a property value with the content of the given files. The PropertyType
- * may be specified.
+ * Set a <code>Property</code> <code>Value</code> with the content of the
+ * given file.
  */
-public class SetPropertyFromFile extends AbstractSetProperty
-{
-	/** logger */
-	private static Log log = LogFactory.getLog(SetPropertyFromFile.class);
+public class SetPropertyFromFile extends AbstractSetProperty {
+    /** logger */
+    private static Log log = LogFactory.getLog(SetPropertyFromFile.class);
 
-	/**
-	 * @inheritDoc
-	 */
-	public boolean execute(Context ctx) throws Exception
-	{
-		String value = (String) ctx.get(this.valueKey);
-		String name = (String) ctx.get(this.nameKey);
-		String propertyType = (String) ctx.get(this.typeKey);
-		String parent = (String) ctx.get(this.parentPathKey);
+    /**
+     * {@inheritDoc}
+     */
+    public boolean execute(Context ctx) throws Exception {
+        String value = (String) ctx.get(this.valueKey);
+        String name = (String) ctx.get(this.nameKey);
+        String propertyType = (String) ctx.get(this.typeKey);
+        String parent = (String) ctx.get(this.parentPathKey);
 
-		Node node = CommandHelper.getNode(ctx, parent);
+        Node node = CommandHelper.getNode(ctx, parent);
 
-		if (log.isDebugEnabled())
-		{
-			log.debug("setting property " + node.getPath() + "/" + name
-					+ " with content of file " + value);
-		}
+        if (log.isDebugEnabled()) {
+            log.debug("setting property " + node.getPath() + "/" + name
+                    + " with content of file " + value);
+        }
 
-		File f = new File(value);
-		if (!f.exists())
-		{
-			throw new CommandException("exception.file.not.found", new String[]
-			{ value });
-		}
-		if (propertyType.equals(PropertyType.TYPENAME_BINARY))
-		{
-			node.setProperty(name, new FileInputStream(f));
-		} else
-		{
-			CharArrayWriter cw = new CharArrayWriter();
-			PrintWriter out = new PrintWriter(cw);
-			BufferedReader in = new BufferedReader(new FileReader(f));
-			String str;
-			while ((str = in.readLine()) != null)
-			{
-				out.println(str);
-			}
-			in.close();
-			node.setProperty(name, cw.toString(), PropertyType
-					.valueFromName(propertyType));
-		}
-		return false;
-	}
+        File f = new File(value);
+        if (!f.exists()) {
+            throw new CommandException("exception.file.not.found",
+                new String[] {
+                    value
+                });
+        }
+        if (propertyType.equals(PropertyType.TYPENAME_BINARY)) {
+            node.setProperty(name, new FileInputStream(f));
+        } else {
+            CharArrayWriter cw = new CharArrayWriter();
+            PrintWriter out = new PrintWriter(cw);
+            BufferedReader in = new BufferedReader(new FileReader(f));
+            String str;
+            while ((str = in.readLine()) != null) {
+                out.println(str);
+            }
+            in.close();
+            node.setProperty(name, cw.toString(), PropertyType
+                .valueFromName(propertyType));
+        }
+        return false;
+    }
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/AbstractLs.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/AbstractLs.java?rev=312896&r1=312895&r2=312896&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/AbstractLs.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/AbstractLs.java Tue Oct 11 07:38:54 2005
@@ -29,13 +29,12 @@
 /**
  * Ls superclass
  */
-public abstract class AbstractLs implements Command
-{
+public abstract class AbstractLs implements Command {
     /** bundle */
     private static ResourceBundle bundle = CommandHelper.getBundle();
 
     /** long width */
-    protected int longWidth = 10;
+    protected int longWidth = 9;
 
     /** max items to list */
     private int defaultMaxItems = 100;
@@ -46,84 +45,100 @@
     /** show path flag */
     private boolean path;
 
-    protected void printFooter(Context ctx, Iterator iter)
-    {
+    /**
+     * Print the footer
+     * @param ctx
+     *        the <code>Context</code>
+     * @param iter
+     *        the <code>Iterator</code>
+     */
+    protected void printFooter(Context ctx, Iterator iter) {
         CommandHelper.getOutput(ctx).println();
         CommandHelper.getOutput(ctx).println(bundle.getString("word.total"));
-        if (iter instanceof NodeIterator)
-        {
+        if (iter instanceof NodeIterator) {
             printFooter(ctx, (NodeIterator) iter);
-        } else if (iter instanceof PropertyIterator)
-        {
+        } else if (iter instanceof PropertyIterator) {
             printFooter(ctx, (PropertyIterator) iter);
         }
     }
 
-    private void printFooter(Context ctx, NodeIterator iter)
-    {
+    /**
+     * Print footer
+     * @param ctx
+     *        the <code>Context</code>
+     * @param iter
+     *        the <code>Iterator</code>
+     */
+    private void printFooter(Context ctx, NodeIterator iter) {
         CommandHelper.getOutput(ctx).println(
             iter.getSize() + " " + bundle.getString("word.nodes"));
     }
 
-    private void printFooter(Context ctx, PropertyIterator iter)
-    {
+    /**
+     * Print footer
+     * @param ctx
+     *        the <code>Context</code>
+     * @param iter
+     *        the <code>Iterator</code>
+     */
+    private void printFooter(Context ctx, PropertyIterator iter) {
         CommandHelper.getOutput(ctx).println(
             iter.getSize() + " " + bundle.getString("word.properties"));
     }
 
-    public int getDefaultMaxItems()
-    {
+    /**
+     * @return the default max number of <code>Items</code> s to show
+     */
+    public int getDefaultMaxItems() {
         return defaultMaxItems;
     }
 
-    public void setDefaultMaxItems(int maxItems)
-    {
+    /**
+     * @param maxItems
+     *        the default max number of <code>Items</code> s to set
+     */
+    public void setDefaultMaxItems(int maxItems) {
         this.defaultMaxItems = maxItems;
     }
 
     /**
-     * @return Returns the path.
+     * @return the path
      */
-    public boolean isPath()
-    {
+    public boolean isPath() {
         return path;
     }
 
     /**
      * @param path
-     *            The path to set.
+     *        the path to set
      */
-    public void setPath(boolean path)
-    {
+    public void setPath(boolean path) {
         this.path = path;
     }
 
     /**
-     * @return Returns the maxItemsKey.
+     * @return the max number of items key
      */
-    public String getMaxItemsKey()
-    {
+    public String getMaxItemsKey() {
         return maxItemsKey;
     }
 
     /**
      * @param maxItemsKey
-     *            The maxItemsKey to set.
+     *        the max number of items key to set
      */
-    public void setMaxItemsKey(String maxItemsKey)
-    {
+    public void setMaxItemsKey(String maxItemsKey) {
         this.maxItemsKey = maxItemsKey;
     }
 
     /**
      * @param ctx
-     * @return max number of items to show
+     *        the <code>Context</code>
+     * @return the max number of <code>Item</code> s to show
      */
-    protected int getMaxItems(Context ctx)
-    {
+    protected int getMaxItems(Context ctx) {
         String maxItems = (String) ctx.get(this.maxItemsKey);
-        if (maxItems == null)
-        {
+        if (maxItems == null) {
             maxItems = new Integer(this.defaultMaxItems).toString();
         }
         return Integer.valueOf(maxItems).intValue();

Modified: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/AbstractLsItems.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/AbstractLsItems.java?rev=312896&r1=312895&r2=312896&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/AbstractLsItems.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/AbstractLsItems.java Tue Oct 11 07:38:54 2005
@@ -32,12 +32,11 @@
 /**
  * List items superclass
  */
-public abstract class AbstractLsItems extends AbstractLs
-{
-	/** bundle */
-	private static ResourceBundle bundle = CommandHelper.getBundle() ; 
-	
-	/** name width */
+public abstract class AbstractLsItems extends AbstractLs {
+    /** bundle */
+    private static ResourceBundle bundle = CommandHelper.getBundle();
+
+    /** name width */
     private int nameWidth = 30;
 
     /** node type width */
@@ -45,28 +44,29 @@
 
     /**
      * @param ctx
+     *        the <code>Context</code>
      * @return Iterator containing the Items to list
      * @throws CommandException
+     *         if an errors occurs
      * @throws RepositoryException
+     *         if the current <code>Repository</code> throws a
+     *         <code>RepositoryException<code>
      */
-    protected abstract Iterator getItems(Context ctx)
-            throws CommandException, RepositoryException;
+    protected abstract Iterator getItems(Context ctx) throws CommandException,
+            RepositoryException;
 
     /**
-     * @inheritDoc
+     * {@inheritDoc}
      */
-    public final boolean execute(Context ctx) throws Exception
-    {
+    public final boolean execute(Context ctx) throws Exception {
         int nodes = 0;
         int properties = 0;
 
         // header
-        int[] width = new int[]
-        {
+        int[] width = new int[] {
                 nameWidth, typeWidth, longWidth, longWidth, longWidth
         };
-        String[] header = new String[]
-        {
+        String[] header = new String[] {
                 bundle.getString("word.name"), bundle.getString("word.type"),
                 bundle.getString("word.node"), bundle.getString("word.new"),
                 bundle.getString("word.modified")
@@ -86,41 +86,34 @@
         int maxItems = getMaxItems(ctx);
 
         // Print nodes
-        while (iter.hasNext() && index < maxItems)
-        {
+        while (iter.hasNext() && index < maxItems) {
             Item i = (Item) iter.next();
 
             String type = null;
 
             // Show name or path
             String name = null;
-            if (this.isPath())
-            {
+            if (this.isPath()) {
                 name = i.getPath();
-            } else
-            {
+            } else {
                 name = i.getName();
             }
 
-            if (i.isNode())
-            {
+            if (i.isNode()) {
                 nodes++;
                 // name
                 Node n = (Node) i;
-                if (!isPath() && n.getIndex() > 1)
-                {
+                if (!isPath() && n.getIndex() > 1) {
                     name = n.getName() + "[" + n.getIndex() + "]";
                 }
                 // type
                 type = n.getPrimaryNodeType().getName();
-            } else
-            {
+            } else {
                 properties++;
                 type = PropertyType.nameFromValue(((Property) i).getType());
             }
 
-            PrintHelper.printRow(ctx, width, new String[]
-            {
+            PrintHelper.printRow(ctx, width, new String[] {
                     name, type, Boolean.toString(i.isNode()),
                     Boolean.valueOf(i.isNew()).toString(),
                     Boolean.valueOf(i.isModified()).toString()

Modified: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/AbstractLsNodes.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/AbstractLsNodes.java?rev=312896&r1=312895&r2=312896&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/AbstractLsNodes.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/AbstractLsNodes.java Tue Oct 11 07:38:54 2005
@@ -49,808 +49,735 @@
  * <li>modifiedKey</li>
  * </ul>
  */
-public abstract class AbstractLsNodes extends AbstractLs
-{
-	/** bundle */
-	private static ResourceBundle bundle = CommandHelper.getBundle();
-
-	// show path
-	private String pathKey = "path";
-
-	// show uuid
-	private String uuidKey = "uuid";
-
-	// show mixin
-	private String mixinKey = "mixin";
-
-	// show node size
-	private String nodesSizeKey = "nodeSize";
-
-	// show properties size
-	private String propertiesSizeKey = "propertiesSize";
-
-	// show references size
-	private String referencesSizeKey = "referencesSize";
-
-	// show is versionable
-	private String versionableKey = "versionable";
-
-	// show is lockable
-	private String lockableKey = "lockable";
-
-	// show is referenceable
-	private String referenceableKey = "referenceable";
-
-	// show is locked
-	private String lockedKey = "locked";
-
-	// show has lock
-	private String hasLockKey = "hasLock";
-
-	// show is new
-	private String new_Key = "new";
-
-	// show is modified
-	private String modifiedKey = "modified";
-
-	// show lock tocken
-	private String lockTokenKey = "lockToken";
-
-	/** uuid width */
-	private int uuidWidth = 36;
-
-	/** path width */
-	private int nameWidth = 30;
-
-	/** node type width */
-	private int nodeTypeWidth = 20;
-
-	/** node type width */
-	private int pathWidth = 40;
-
-	/** referenceable width */
-	private int mixinWidth = 30;
-
-	/**
-	 * @inheritDoc
-	 */
-	public final boolean execute(Context ctx) throws Exception
-	{
-		OptionHolder oh = new OptionHolder(ctx);
-
-		// Get children
-		Iterator iter = getNodes(ctx);
-
-		// write header
-		writeHeader(ctx, oh);
-
-		int index = 0;
-
-		int maxItems = getMaxItems(ctx);
-
-		// Write item
-		while (iter.hasNext() && index < maxItems)
-		{
-			Node n = (Node) iter.next();
-			writeItem(ctx, n, oh);
-			index++;
-		}
-
-		// Write footer
-		printFooter(ctx, iter);
-
-		return false;
-	}
-
-	/**
-	 * Get nodes to show
-	 * 
-	 * @param ctx
-	 * @return
-	 * @throws RepositoryException
-	 * @throws CommandException
-	 */
-	protected abstract Iterator getNodes(Context ctx) throws CommandException,
-			RepositoryException;
-
-	/**
-	 * Write a node to the current output
-	 * 
-	 * @param ctx
-	 * @param n
-	 * @throws RepositoryException
-	 * @throws CommandException
-	 */
-	void writeItem(Context ctx, Node n, OptionHolder oh)
-			throws RepositoryException, CommandException
-	{
-		// TODO do something with this long piece of code
-		Collection widths = new ArrayList();
-		Collection texts = new ArrayList();
-
-		widths.add(new Integer(this.nameWidth));
-
-		String name = n.getName();
-		if (n.getIndex() > 1)
-		{
-			name += "[" + n.getIndex() + "]";
-		}
-		texts.add(name);
-
-		widths.add(new Integer(this.nodeTypeWidth));
-		texts.add(n.getPrimaryNodeType().getName());
-
-		// uuid
-		if (oh.isUuid())
-		{
-			widths.add(new Integer(this.uuidWidth));
-			if (n.isNodeType(JcrConstants.MIX_REFERENCEABLE))
-			{
-				texts.add(n.getUUID());
-			} else
-			{
-				texts.add("");
-			}
-		}
-
-		// is new
-		if (oh.isNew_())
-		{
-			widths.add(new Integer(this.longWidth));
-			texts.add(Boolean.toString(n.isNew()));
-		}
-
-		// is new
-		if (oh.isModified())
-		{
-			widths.add(new Integer(this.longWidth));
-			texts.add(Boolean.toString(n.isModified()));
-		}
-
-		// mixin
-		if (oh.isMixin())
-		{
-			widths.add(new Integer(this.mixinWidth));
-			Collection mixins = new ArrayList();
-			// Assigned mixin types
-			NodeType[] assigned = n.getMixinNodeTypes();
-			for (int i = 0; i < assigned.length; i++)
-			{
-				mixins.add(assigned[i].getName());
-			}
-
-			// Inherited mixin types
-			NodeType[] nt = n.getPrimaryNodeType().getSupertypes();
-			for (int i = 0; i < nt.length; i++)
-			{
-				if (nt[i].isMixin())
-				{
-					mixins.add(nt[i].getName());
-				}
-			}
-			texts.add(mixins);
-		}
-
-		// node size
-		if (oh.isNodesSize())
-		{
-			widths.add(new Integer(this.longWidth));
-			texts.add(Long.toString(n.getNodes().getSize()));
-		}
-
-		// prop size
-		if (oh.isPropertiesSize())
-		{
-			widths.add(new Integer(this.longWidth));
-			texts.add(Long.toString(n.getProperties().getSize()));
-		}
-
-		// ref size
-		if (oh.isReferencesSize())
-		{
-			widths.add(new Integer(this.longWidth));
-			texts.add(Long.toString(n.getReferences().getSize()));
-		}
-
-		// is versionable
-		if (oh.isVersionable())
-		{
-			widths.add(new Integer(this.longWidth));
-			texts.add(Boolean.toString(n
-					.isNodeType(JcrConstants.MIX_VERSIONABLE)));
-		}
-
-		// is lockable
-		if (oh.isLockable())
-		{
-			widths.add(new Integer(this.longWidth));
-			texts
-					.add(Boolean.toString(n
-							.isNodeType(JcrConstants.MIX_LOCKABLE)));
-		}
-
-		// is referenceable
-		if (oh.isReferenceable())
-		{
-			widths.add(new Integer(this.longWidth));
-			texts.add(Boolean.toString(n
-					.isNodeType(JcrConstants.MIX_REFERENCEABLE)));
-		}
-
-		// is locked
-		if (oh.isLocked())
-		{
-			widths.add(new Integer(this.longWidth));
-			texts.add(Boolean.toString(n.isLocked()));
-		}
-
-		// has lock
-		if (oh.isHasLock())
-		{
-			widths.add(new Integer(this.longWidth));
-			texts.add(Boolean.toString(n.holdsLock()));
-		}
-
-		// path
-		if (oh.isPath())
-		{
-			widths.add(new Integer(this.pathWidth));
-			texts.add(n.getPath());
-		}
-
-		// lock token
-		if (oh.isLockToken())
-		{
-			widths.add(new Integer(this.nameWidth));
-			if (n.isLocked())
-			{
-				texts.add(n.getLock().getLockToken());
-			} else
-			{
-				texts.add("");
-			}
-		}
-
-		PrintHelper.printRow(ctx, widths, texts);
-	}
-
-	/**
-	 * Prints the header
-	 * 
-	 * @param ctx
-	 * @throws CommandException
-	 */
-	void writeHeader(Context ctx, OptionHolder oh) throws CommandException
-	{
-		// TODO do something with this long piece of code
-		Collection widths = new ArrayList();
-		Collection texts = new ArrayList();
-		widths.add(new Integer(this.nameWidth));
-		texts.add(bundle.getString("word.name"));
-		widths.add(new Integer(this.nodeTypeWidth));
-		texts.add(bundle.getString("word.nodetype"));
-
-		// uuid
-		if (oh.isUuid())
-		{
-			widths.add(new Integer(this.uuidWidth));
-			texts.add("uuid");
-		}
-
-		// is new
-		if (oh.isNew_())
-		{
-			widths.add(new Integer(this.longWidth));
-			texts.add(bundle.getString("word.new"));
-		}
-
-		// is new
-		if (oh.isModified())
-		{
-			widths.add(new Integer(this.longWidth));
-			texts.add(bundle.getString("word.modified"));
-		}
-
-		// mixin
-		if (oh.isMixin())
-		{
-			widths.add(new Integer(this.mixinWidth));
-			texts.add("mixin");
-		}
-
-		// node size
-		if (oh.isNodesSize())
-		{
-			widths.add(new Integer(this.longWidth));
-			texts.add(bundle.getString("word.nodes"));
-		}
-
-		// prop size
-		if (oh.isPropertiesSize())
-		{
-			widths.add(new Integer(this.longWidth));
-			texts.add(bundle.getString("word.properties"));
-		}
-
-		// ref size
-		if (oh.isReferencesSize())
-		{
-			widths.add(new Integer(this.longWidth));
-			texts.add(bundle.getString("word.references"));
-		}
-
-		// is versionable
-		if (oh.isVersionable())
-		{
-			widths.add(new Integer(this.longWidth));
-			texts.add(bundle.getString("word.versionable"));
-		}
-
-		// is lockable
-		if (oh.isLockable())
-		{
-			widths.add(new Integer(this.longWidth));
-			texts.add(bundle.getString("word.lockable"));
-		}
-
-		// is referenceable
-		if (oh.isReferenceable())
-		{
-			widths.add(new Integer(this.longWidth));
-			texts.add(bundle.getString("word.referenceable"));
-		}
-
-		// is locked
-		if (oh.isLocked())
-		{
-			widths.add(new Integer(this.longWidth));
-			texts.add(bundle.getString("word.locked"));
-		}
-
-		// has lock
-		if (oh.isHasLock())
-		{
-			widths.add(new Integer(this.longWidth));
-			texts.add(bundle.getString("phrase.haslock"));
-		}
-
-		// path
-		if (oh.isPath())
-		{
-			widths.add(new Integer(this.pathWidth));
-			texts.add(bundle.getString("word.path"));
-		}
-
-		if (oh.isLockToken())
-		{
-			widths.add(new Integer(this.nameWidth));
-			texts.add(bundle.getString("word.locktoken"));
-		}
-
-		PrintHelper.printRow(ctx, widths, texts);
-		PrintHelper.printSeparatorRow(ctx, widths, '-');
-	}
-
-	private class OptionHolder
-	{
-		// show path
-		boolean path = false;
-
-		// show uuid
-		boolean uuid = false;
-
-		// show mixin
-		boolean mixin = false;
-
-		// show node size
-		boolean nodesSize = false;
-
-		// show properties size
-		boolean propertiesSize = false;
-
-		// show references size
-		boolean referencesSize = false;
-
-		// show is versionable
-		boolean versionable = false;
-
-		// show is lockable
-		boolean lockable = false;
-
-		// show is referenceable
-		boolean referenceable = false;
-
-		// show is locked
-		boolean locked = false;
-
-		// show has lock
-		boolean hasLock = false;
-
-		// show is new
-		boolean new_ = false;
-
-		// show is modified
-		boolean modified = false;
-
-		boolean lockToken = false;
-
-		private Context ctx;
-
-		/**
-		 * @param key
-		 * @return the boolean value for the given key
-		 */
-		private boolean getFlag(String key)
-		{
-			boolean flag = false;
-			if (ctx.containsKey(key))
-			{
-				flag = Boolean.valueOf((String) ctx.get(key)).booleanValue();
-			}
-			return flag;
-		}
-
-		/**
-		 * Constructor
-		 */
-		public OptionHolder(Context ctx)
-		{
-			super();
-			this.ctx = ctx;
-			path = getFlag(pathKey);
-			uuid = getFlag(uuidKey);
-			mixin = getFlag(mixinKey);
-			nodesSize = getFlag(nodesSizeKey);
-			propertiesSize = getFlag(propertiesSizeKey);
-			referencesSize = getFlag(referencesSizeKey);
-			versionable = getFlag(versionableKey);
-			lockable = getFlag(lockableKey);
-			referenceable = getFlag(referenceableKey);
-			locked = getFlag(lockedKey);
-			hasLock = getFlag(hasLockKey);
-			new_ = getFlag(new_Key);
-			modified = getFlag(modifiedKey);
-			lockToken = getFlag(lockTokenKey);
-		}
-
-		/**
-		 * @return Returns the hasLock.
-		 */
-		public boolean isHasLock()
-		{
-			return hasLock;
-		}
-
-		/**
-		 * @return Returns the lockable.
-		 */
-		public boolean isLockable()
-		{
-			return lockable;
-		}
-
-		/**
-		 * @return Returns the locked.
-		 */
-		public boolean isLocked()
-		{
-			return locked;
-		}
-
-		/**
-		 * @return Returns the mixin.
-		 */
-		public boolean isMixin()
-		{
-			return mixin;
-		}
-
-		/**
-		 * @return Returns the modified.
-		 */
-		public boolean isModified()
-		{
-			return modified;
-		}
-
-		/**
-		 * @return Returns the new_.
-		 */
-		public boolean isNew_()
-		{
-			return new_;
-		}
-
-		/**
-		 * @return Returns the nodesSize.
-		 */
-		public boolean isNodesSize()
-		{
-			return nodesSize;
-		}
-
-		/**
-		 * @return Returns the propertiesSize.
-		 */
-		public boolean isPropertiesSize()
-		{
-			return propertiesSize;
-		}
-
-		/**
-		 * @return Returns the referenceable.
-		 */
-		public boolean isReferenceable()
-		{
-			return referenceable;
-		}
-
-		/**
-		 * @return Returns the referencesSize.
-		 */
-		public boolean isReferencesSize()
-		{
-			return referencesSize;
-		}
-
-		/**
-		 * @return Returns the uuid.
-		 */
-		public boolean isUuid()
-		{
-			return uuid;
-		}
-
-		/**
-		 * @return Returns the versionable.
-		 */
-		public boolean isVersionable()
-		{
-			return versionable;
-		}
-
-		/**
-		 * @return Returns the path.
-		 */
-		public boolean isPath()
-		{
-			return path;
-		}
-
-		public boolean isLockToken()
-		{
-			return lockToken;
-		}
-	}
-
-	/**
-	 * @return Returns the hasLockKey.
-	 */
-	public String getHasLockKey()
-	{
-		return hasLockKey;
-	}
-
-	/**
-	 * @param hasLockKey
-	 *            The hasLockKey to set.
-	 */
-	public void setHasLockKey(String hasLockKey)
-	{
-		this.hasLockKey = hasLockKey;
-	}
-
-	/**
-	 * @return Returns the lockableKey.
-	 */
-	public String getLockableKey()
-	{
-		return lockableKey;
-	}
-
-	/**
-	 * @param lockableKey
-	 *            The lockableKey to set.
-	 */
-	public void setLockableKey(String lockableKey)
-	{
-		this.lockableKey = lockableKey;
-	}
-
-	/**
-	 * @return Returns the lockedKey.
-	 */
-	public String getLockedKey()
-	{
-		return lockedKey;
-	}
-
-	/**
-	 * @param lockedKey
-	 *            The lockedKey to set.
-	 */
-	public void setLockedKey(String lockedKey)
-	{
-		this.lockedKey = lockedKey;
-	}
-
-	/**
-	 * @return Returns the mixinKey.
-	 */
-	public String getMixinKey()
-	{
-		return mixinKey;
-	}
-
-	/**
-	 * @param mixinKey
-	 *            The mixinKey to set.
-	 */
-	public void setMixinKey(String mixinKey)
-	{
-		this.mixinKey = mixinKey;
-	}
-
-	/**
-	 * @return Returns the modifiedKey.
-	 */
-	public String getModifiedKey()
-	{
-		return modifiedKey;
-	}
-
-	/**
-	 * @param modifiedKey
-	 *            The modifiedKey to set.
-	 */
-	public void setModifiedKey(String modifiedKey)
-	{
-		this.modifiedKey = modifiedKey;
-	}
-
-	/**
-	 * @return Returns the new_Key.
-	 */
-	public String getNew_Key()
-	{
-		return new_Key;
-	}
-
-	/**
-	 * @param new_Key
-	 *            The new_Key to set.
-	 */
-	public void setNew_Key(String new_Key)
-	{
-		this.new_Key = new_Key;
-	}
-
-	/**
-	 * @return Returns the nodesSizeKey.
-	 */
-	public String getNodesSizeKey()
-	{
-		return nodesSizeKey;
-	}
-
-	/**
-	 * @param nodesSizeKey
-	 *            The nodesSizeKey to set.
-	 */
-	public void setNodesSizeKey(String nodesSizeKey)
-	{
-		this.nodesSizeKey = nodesSizeKey;
-	}
-
-	/**
-	 * @return Returns the pathKey.
-	 */
-	public String getPathKey()
-	{
-		return pathKey;
-	}
-
-	/**
-	 * @param pathKey
-	 *            The pathKey to set.
-	 */
-	public void setPathKey(String pathKey)
-	{
-		this.pathKey = pathKey;
-	}
-
-	/**
-	 * @return Returns the propertiesSizeKey.
-	 */
-	public String getPropertiesSizeKey()
-	{
-		return propertiesSizeKey;
-	}
-
-	/**
-	 * @param propertiesSizeKey
-	 *            The propertiesSizeKey to set.
-	 */
-	public void setPropertiesSizeKey(String propertiesSizeKey)
-	{
-		this.propertiesSizeKey = propertiesSizeKey;
-	}
-
-	/**
-	 * @return Returns the referenceableKey.
-	 */
-	public String getReferenceableKey()
-	{
-		return referenceableKey;
-	}
-
-	/**
-	 * @param referenceableKey
-	 *            The referenceableKey to set.
-	 */
-	public void setReferenceableKey(String referenceableKey)
-	{
-		this.referenceableKey = referenceableKey;
-	}
-
-	/**
-	 * @return Returns the referencesSizeKey.
-	 */
-	public String getReferencesSizeKey()
-	{
-		return referencesSizeKey;
-	}
-
-	/**
-	 * @param referencesSizeKey
-	 *            The referencesSizeKey to set.
-	 */
-	public void setReferencesSizeKey(String referencesSizeKey)
-	{
-		this.referencesSizeKey = referencesSizeKey;
-	}
-
-	/**
-	 * @return Returns the uuidKey.
-	 */
-	public String getUuidKey()
-	{
-		return uuidKey;
-	}
-
-	/**
-	 * @param uuidKey
-	 *            The uuidKey to set.
-	 */
-	public void setUuidKey(String uuidKey)
-	{
-		this.uuidKey = uuidKey;
-	}
-
-	/**
-	 * @return Returns the versionableKey.
-	 */
-	public String getVersionableKey()
-	{
-		return versionableKey;
-	}
-
-	/**
-	 * @param versionableKey
-	 *            The versionableKey to set.
-	 */
-	public void setVersionableKey(String versionableKey)
-	{
-		this.versionableKey = versionableKey;
-	}
-
-	public String getLockTokenKey()
-	{
-		return lockTokenKey;
-	}
-
-	public void setLockTokenKey(String lockTokenKey)
-	{
-		this.lockTokenKey = lockTokenKey;
-	}
+public abstract class AbstractLsNodes extends AbstractLs {
+    /** bundle */
+    private static final ResourceBundle bundle = CommandHelper.getBundle();
+
+    /** show path */
+    private String pathKey = "path";
+
+    /** show uuid */
+    private String uuidKey = "uuid";
+
+    /** show mixin */
+    private String mixinKey = "mixin";
+
+    /** show node size */
+    private String nodesSizeKey = "nodeSize";
+
+    /** show properties size */
+    private String propertiesSizeKey = "propertiesSize";
+
+    /** show references size */
+    private String referencesSizeKey = "referencesSize";
+
+    /** show is versionable */
+    private String versionableKey = "versionable";
+
+    /** show is lockable */
+    private String lockableKey = "lockable";
+
+    /** show is referenceable */
+    private String referenceableKey = "referenceable";
+
+    /** show is locked */
+    private String lockedKey = "locked";
+
+    /** show has lock */
+    private String hasLockKey = "hasLock";
+
+    /** show is new */
+    private String new_Key = "new";
+
+    /** show is modified */
+    private String modifiedKey = "modified";
+
+    /** show lock tocken */
+    private String lockTokenKey = "lockToken";
+
+    /** uuid width */
+    private int uuidWidth = 36;
+
+    /** path width */
+    private int nameWidth = 30;
+
+    /** node type width */
+    private int nodeTypeWidth = 20;
+
+    /** node type width */
+    private int pathWidth = 40;
+
+    /** referenceable width */
+    private int mixinWidth = 30;
+
+    /**
+     * {@inheritDoc}
+     */
+    public final boolean execute(Context ctx) throws Exception {
+        OptionHolder oh = new OptionHolder(ctx);
+
+        // Get children
+        Iterator iter = getNodes(ctx);
+
+        // write header
+        writeHeader(ctx, oh);
+
+        int index = 0;
+
+        int maxItems = getMaxItems(ctx);
+
+        // Write item
+        while (iter.hasNext() && index < maxItems) {
+            Node n = (Node) iter.next();
+            writeItem(ctx, n, oh);
+            index++;
+        }
+
+        // Write footer
+        printFooter(ctx, iter);
+
+        return false;
+    }
+
+    /**
+     * @param ctx
+     *        the <code>Context</code>
+     * @return the <code>Node<code>s to show
+     * @throws RepositoryException if the current working <code>Repository</code> throws a <code>RepositoryException</code>
+     * @throws CommandException
+     */
+    protected abstract Iterator getNodes(Context ctx) throws CommandException,
+            RepositoryException;
+
+    /**
+     * Write a node to the current output
+     * @param ctx
+     *        the <code>Context</code>
+     * @param n
+     *        the <code>Node</code>
+     * @throws RepositoryException
+     * @throws CommandException
+     */
+    void writeItem(Context ctx, Node n, OptionHolder oh)
+            throws RepositoryException, CommandException {
+        // TODO do something with this long piece of code
+        Collection widths = new ArrayList();
+        Collection texts = new ArrayList();
+
+        widths.add(new Integer(this.nameWidth));
+
+        String name = n.getName();
+        if (n.getIndex() > 1) {
+            name += "[" + n.getIndex() + "]";
+        }
+        texts.add(name);
+
+        widths.add(new Integer(this.nodeTypeWidth));
+        texts.add(n.getPrimaryNodeType().getName());
+
+        // uuid
+        if (oh.isUuid()) {
+            widths.add(new Integer(this.uuidWidth));
+            if (n.isNodeType(JcrConstants.MIX_REFERENCEABLE)) {
+                texts.add(n.getUUID());
+            } else {
+                texts.add("");
+            }
+        }
+
+        // is new
+        if (oh.isNew_()) {
+            widths.add(new Integer(this.longWidth));
+            texts.add(Boolean.toString(n.isNew()));
+        }
+
+        // is new
+        if (oh.isModified()) {
+            widths.add(new Integer(this.longWidth));
+            texts.add(Boolean.toString(n.isModified()));
+        }
+
+        // mixin
+        if (oh.isMixin()) {
+            widths.add(new Integer(this.mixinWidth));
+            Collection mixins = new ArrayList();
+            // Assigned mixin types
+            NodeType[] assigned = n.getMixinNodeTypes();
+            for (int i = 0; i < assigned.length; i++) {
+                mixins.add(assigned[i].getName());
+            }
+
+            // Inherited mixin types
+            NodeType[] nt = n.getPrimaryNodeType().getSupertypes();
+            for (int i = 0; i < nt.length; i++) {
+                if (nt[i].isMixin()) {
+                    mixins.add(nt[i].getName());
+                }
+            }
+            texts.add(mixins);
+        }
+
+        // node size
+        if (oh.isNodesSize()) {
+            widths.add(new Integer(this.longWidth));
+            texts.add(Long.toString(n.getNodes().getSize()));
+        }
+
+        // prop size
+        if (oh.isPropertiesSize()) {
+            widths.add(new Integer(this.longWidth));
+            texts.add(Long.toString(n.getProperties().getSize()));
+        }
+
+        // ref size
+        if (oh.isReferencesSize()) {
+            widths.add(new Integer(this.longWidth));
+            texts.add(Long.toString(n.getReferences().getSize()));
+        }
+
+        // is versionable
+        if (oh.isVersionable()) {
+            widths.add(new Integer(this.longWidth));
+            texts.add(Boolean.toString(n
+                .isNodeType(JcrConstants.MIX_VERSIONABLE)));
+        }
+
+        // is lockable
+        if (oh.isLockable()) {
+            widths.add(new Integer(this.longWidth));
+            texts
+                .add(Boolean.toString(n.isNodeType(JcrConstants.MIX_LOCKABLE)));
+        }
+
+        // is referenceable
+        if (oh.isReferenceable()) {
+            widths.add(new Integer(this.longWidth));
+            texts.add(Boolean.toString(n
+                .isNodeType(JcrConstants.MIX_REFERENCEABLE)));
+        }
+
+        // is locked
+        if (oh.isLocked()) {
+            widths.add(new Integer(this.longWidth));
+            texts.add(Boolean.toString(n.isLocked()));
+        }
+
+        // has lock
+        if (oh.isHasLock()) {
+            widths.add(new Integer(this.longWidth));
+            texts.add(Boolean.toString(n.holdsLock()));
+        }
+
+        // path
+        if (oh.isPath()) {
+            widths.add(new Integer(this.pathWidth));
+            texts.add(n.getPath());
+        }
+
+        // lock token
+        if (oh.isLockToken()) {
+            widths.add(new Integer(this.nameWidth));
+            if (n.isLocked()) {
+                texts.add(n.getLock().getLockToken());
+            } else {
+                texts.add("");
+            }
+        }
+
+        PrintHelper.printRow(ctx, widths, texts);
+    }
+
+    /**
+     * Prints the header
+     * @param ctx
+     *        the <code>Context</code>
+     * @throws CommandException
+     */
+    void writeHeader(Context ctx, OptionHolder oh) throws CommandException {
+        // TODO do something with this long piece of code
+        Collection widths = new ArrayList();
+        Collection texts = new ArrayList();
+        widths.add(new Integer(this.nameWidth));
+        texts.add(bundle.getString("word.name"));
+        widths.add(new Integer(this.nodeTypeWidth));
+        texts.add(bundle.getString("word.nodetype"));
+
+        // uuid
+        if (oh.isUuid()) {
+            widths.add(new Integer(this.uuidWidth));
+            texts.add("uuid");
+        }
+
+        // is new
+        if (oh.isNew_()) {
+            widths.add(new Integer(this.longWidth));
+            texts.add(bundle.getString("word.new"));
+        }
+
+        // is new
+        if (oh.isModified()) {
+            widths.add(new Integer(this.longWidth));
+            texts.add(bundle.getString("word.modified"));
+        }
+
+        // mixin
+        if (oh.isMixin()) {
+            widths.add(new Integer(this.mixinWidth));
+            texts.add("mixin");
+        }
+
+        // node size
+        if (oh.isNodesSize()) {
+            widths.add(new Integer(this.longWidth));
+            texts.add(bundle.getString("word.nodes"));
+        }
+
+        // prop size
+        if (oh.isPropertiesSize()) {
+            widths.add(new Integer(this.longWidth));
+            texts.add(bundle.getString("word.properties"));
+        }
+
+        // ref size
+        if (oh.isReferencesSize()) {
+            widths.add(new Integer(this.longWidth));
+            texts.add(bundle.getString("word.references"));
+        }
+
+        // is versionable
+        if (oh.isVersionable()) {
+            widths.add(new Integer(this.longWidth));
+            texts.add(bundle.getString("word.versionable"));
+        }
+
+        // is lockable
+        if (oh.isLockable()) {
+            widths.add(new Integer(this.longWidth));
+            texts.add(bundle.getString("word.lockable"));
+        }
+
+        // is referenceable
+        if (oh.isReferenceable()) {
+            widths.add(new Integer(this.longWidth));
+            texts.add(bundle.getString("word.referenceable"));
+        }
+
+        // is locked
+        if (oh.isLocked()) {
+            widths.add(new Integer(this.longWidth));
+            texts.add(bundle.getString("word.locked"));
+        }
+
+        // has lock
+        if (oh.isHasLock()) {
+            widths.add(new Integer(this.longWidth));
+            texts.add(bundle.getString("phrase.haslock"));
+        }
+
+        // path
+        if (oh.isPath()) {
+            widths.add(new Integer(this.pathWidth));
+            texts.add(bundle.getString("word.path"));
+        }
+
+        if (oh.isLockToken()) {
+            widths.add(new Integer(this.nameWidth));
+            texts.add(bundle.getString("word.locktoken"));
+        }
+
+        PrintHelper.printRow(ctx, widths, texts);
+        PrintHelper.printSeparatorRow(ctx, widths, '-');
+    }
+
+    /**
+     * option holder
+     */
+    private class OptionHolder {
+        /** show path */
+        private boolean path = false;
+
+        /** show uuid */
+        private boolean uuid = false;
+
+        /** show mixin */
+        private boolean mixin = false;
+
+        /** show node size */
+        private boolean nodesSize = false;
+
+        /** show properties size */
+        private boolean propertiesSize = false;
+
+        /** show references size */
+        private boolean referencesSize = false;
+
+        /** show is versionable */
+        private boolean versionable = false;
+
+        /** show is lockable */
+        private boolean lockable = false;
+
+        /** show is referenceable */
+        private boolean referenceable = false;
+
+        /** show is locked */
+        private boolean locked = false;
+
+        /** show has lock */
+        private boolean hasLock = false;
+
+        /** show is new */
+        private boolean new_ = false;
+
+        /** show is modified */
+        private boolean modified = false;
+
+        /** lock tokeb */
+        private boolean lockToken = false;
+
+        /** context */
+        private Context ctx;
+
+        /**
+         * @param key
+         *        the key the flag key
+         * @return the boolean value for the given key
+         */
+        private boolean getFlag(String key) {
+            boolean flag = false;
+            if (ctx.containsKey(key)) {
+                flag = Boolean.valueOf((String) ctx.get(key)).booleanValue();
+            }
+            return flag;
+        }
+
+        /**
+         * Constructor
+         * @param ctx
+         *        the <code>Context</code>
+         */
+        public OptionHolder(Context ctx) {
+            super();
+            this.ctx = ctx;
+            path = getFlag(pathKey);
+            uuid = getFlag(uuidKey);
+            mixin = getFlag(mixinKey);
+            nodesSize = getFlag(nodesSizeKey);
+            propertiesSize = getFlag(propertiesSizeKey);
+            referencesSize = getFlag(referencesSizeKey);
+            versionable = getFlag(versionableKey);
+            lockable = getFlag(lockableKey);
+            referenceable = getFlag(referenceableKey);
+            locked = getFlag(lockedKey);
+            hasLock = getFlag(hasLockKey);
+            new_ = getFlag(new_Key);
+            modified = getFlag(modifiedKey);
+            lockToken = getFlag(lockTokenKey);
+        }
+
+        /**
+         * @return the has lock
+         */
+        public boolean isHasLock() {
+            return hasLock;
+        }
+
+        /**
+         * @return Returns the lockable.
+         */
+        public boolean isLockable() {
+            return lockable;
+        }
+
+        /**
+         * @return Returns the locked.
+         */
+        public boolean isLocked() {
+            return locked;
+        }
+
+        /**
+         * @return Returns the mixin.
+         */
+        public boolean isMixin() {
+            return mixin;
+        }
+
+        /**
+         * @return Returns the modified.
+         */
+        public boolean isModified() {
+            return modified;
+        }
+
+        /**
+         * @return Returns the new_.
+         */
+        public boolean isNew_() {
+            return new_;
+        }
+
+        /**
+         * @return Returns the nodesSize.
+         */
+        public boolean isNodesSize() {
+            return nodesSize;
+        }
+
+        /**
+         * @return Returns the propertiesSize.
+         */
+        public boolean isPropertiesSize() {
+            return propertiesSize;
+        }
+
+        /**
+         * @return Returns the referenceable.
+         */
+        public boolean isReferenceable() {
+            return referenceable;
+        }
+
+        /**
+         * @return Returns the referencesSize.
+         */
+        public boolean isReferencesSize() {
+            return referencesSize;
+        }
+
+        /**
+         * @return Returns the uuid.
+         */
+        public boolean isUuid() {
+            return uuid;
+        }
+
+        /**
+         * @return Returns the versionable.
+         */
+        public boolean isVersionable() {
+            return versionable;
+        }
+
+        /**
+         * @return Returns the path.
+         */
+        public boolean isPath() {
+            return path;
+        }
+
+        public boolean isLockToken() {
+            return lockToken;
+        }
+    }
+
+    /**
+     * @return Returns the hasLockKey.
+     */
+    public String getHasLockKey() {
+        return hasLockKey;
+    }
+
+    /**
+     * @param hasLockKey
+     *        The hasLockKey to set.
+     */
+    public void setHasLockKey(String hasLockKey) {
+        this.hasLockKey = hasLockKey;
+    }
+
+    /**
+     * @return Returns the lockableKey.
+     */
+    public String getLockableKey() {
+        return lockableKey;
+    }
+
+    /**
+     * @param lockableKey
+     *        The lockableKey to set.
+     */
+    public void setLockableKey(String lockableKey) {
+        this.lockableKey = lockableKey;
+    }
+
+    /**
+     * @return Returns the lockedKey.
+     */
+    public String getLockedKey() {
+        return lockedKey;
+    }
+
+    /**
+     * @param lockedKey
+     *        The lockedKey to set.
+     */
+    public void setLockedKey(String lockedKey) {
+        this.lockedKey = lockedKey;
+    }
+
+    /**
+     * @return Returns the mixinKey.
+     */
+    public String getMixinKey() {
+        return mixinKey;
+    }
+
+    /**
+     * @param mixinKey
+     *        The mixinKey to set.
+     */
+    public void setMixinKey(String mixinKey) {
+        this.mixinKey = mixinKey;
+    }
+
+    /**
+     * @return Returns the modifiedKey.
+     */
+    public String getModifiedKey() {
+        return modifiedKey;
+    }
+
+    /**
+     * @param modifiedKey
+     *        The modifiedKey to set.
+     */
+    public void setModifiedKey(String modifiedKey) {
+        this.modifiedKey = modifiedKey;
+    }
+
+    /**
+     * @return Returns the new_Key.
+     */
+    public String getNew_Key() {
+        return new_Key;
+    }
+
+    /**
+     * @param new_Key
+     *        The new_Key to set.
+     */
+    public void setNew_Key(String new_Key) {
+        this.new_Key = new_Key;
+    }
+
+    /**
+     * @return Returns the nodesSizeKey.
+     */
+    public String getNodesSizeKey() {
+        return nodesSizeKey;
+    }
+
+    /**
+     * @param nodesSizeKey
+     *        The nodesSizeKey to set.
+     */
+    public void setNodesSizeKey(String nodesSizeKey) {
+        this.nodesSizeKey = nodesSizeKey;
+    }
+
+    /**
+     * @return Returns the pathKey.
+     */
+    public String getPathKey() {
+        return pathKey;
+    }
+
+    /**
+     * @param pathKey
+     *        The pathKey to set.
+     */
+    public void setPathKey(String pathKey) {
+        this.pathKey = pathKey;
+    }
+
+    /**
+     * @return Returns the propertiesSizeKey.
+     */
+    public String getPropertiesSizeKey() {
+        return propertiesSizeKey;
+    }
+
+    /**
+     * @param propertiesSizeKey
+     *        The propertiesSizeKey to set.
+     */
+    public void setPropertiesSizeKey(String propertiesSizeKey) {
+        this.propertiesSizeKey = propertiesSizeKey;
+    }
+
+    /**
+     * @return Returns the referenceableKey.
+     */
+    public String getReferenceableKey() {
+        return referenceableKey;
+    }
+
+    /**
+     * @param referenceableKey
+     *        The referenceableKey to set.
+     */
+    public void setReferenceableKey(String referenceableKey) {
+        this.referenceableKey = referenceableKey;
+    }
+
+    /**
+     * @return Returns the referencesSizeKey.
+     */
+    public String getReferencesSizeKey() {
+        return referencesSizeKey;
+    }
+
+    /**
+     * @param referencesSizeKey
+     *        The referencesSizeKey to set.
+     */
+    public void setReferencesSizeKey(String referencesSizeKey) {
+        this.referencesSizeKey = referencesSizeKey;
+    }
+
+    /**
+     * @return Returns the uuidKey.
+     */
+    public String getUuidKey() {
+        return uuidKey;
+    }
+
+    /**
+     * @param uuidKey
+     *        The uuidKey to set.
+     */
+    public void setUuidKey(String uuidKey) {
+        this.uuidKey = uuidKey;
+    }
+
+    /**
+     * @return Returns the versionableKey.
+     */
+    public String getVersionableKey() {
+        return versionableKey;
+    }
+
+    /**
+     * @param versionableKey
+     *        The versionableKey to set.
+     */
+    public void setVersionableKey(String versionableKey) {
+        this.versionableKey = versionableKey;
+    }
+
+    /**
+     * @return the lock token key
+     */
+    public String getLockTokenKey() {
+        return lockTokenKey;
+    }
+
+    /**
+     * @param lockTokenKey
+     *        the lock token to set
+     */
+    public void setLockTokenKey(String lockTokenKey) {
+        this.lockTokenKey = lockTokenKey;
+    }
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/AbstractLsProperties.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/AbstractLsProperties.java?rev=312896&r1=312895&r2=312896&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/AbstractLsProperties.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/AbstractLsProperties.java Tue Oct 11 07:38:54 2005
@@ -33,25 +33,22 @@
 /**
  * List properties superclass
  */
-public abstract class AbstractLsProperties extends AbstractLs
-{
+public abstract class AbstractLsProperties extends AbstractLs {
 
     /** bundle */
     private static ResourceBundle bundle = CommandHelper.getBundle();
 
     /**
-     * @inheritDoc
+     * {@inheritDoc}
      */
-    public final boolean execute(Context ctx) throws Exception
-    {
-        int[] width = new int[]
-        {
+    public final boolean execute(Context ctx) throws Exception {
+        int[] width = new int[] {
                 30, longWidth, longWidth, longWidth, 20
         };
 
-        String header[] = new String[]
-        {
-                bundle.getString("word.name"), bundle.getString("word.multiple"),
+        String header[] = new String[] {
+                bundle.getString("word.name"),
+                bundle.getString("word.multiple"),
                 bundle.getString("word.type"), bundle.getString("word.length"),
                 bundle.getString("word.preview")
         };
@@ -64,27 +61,22 @@
 
         int maxItems = getMaxItems(ctx);
 
-        while (iter.hasNext() && index < maxItems)
-        {
+        while (iter.hasNext() && index < maxItems) {
             Property p = (Property) iter.next();
 
             long length = 0;
 
-            if (p.getDefinition().isMultiple())
-            {
+            if (p.getDefinition().isMultiple()) {
                 long[] lengths = p.getLengths();
-                for (int i = 0; i < lengths.length; i++)
-                {
+                for (int i = 0; i < lengths.length; i++) {
                     length += lengths[i];
                 }
-            } else
-            {
+            } else {
                 length = p.getLength();
             }
 
             String multiple = Boolean.toString(p.getDefinition().isMultiple());
-            if (p.getDefinition().isMultiple())
-            {
+            if (p.getDefinition().isMultiple()) {
                 multiple += "[" + p.getValues().length + "]";
             }
 
@@ -94,11 +86,9 @@
             row.add(PropertyType.nameFromValue(p.getType()));
             row.add(Long.toString(length));
             // preview
-            if (p.getDefinition().isMultiple())
-            {
+            if (p.getDefinition().isMultiple()) {
                 row.add(this.getMultiplePreview(p));
-            } else
-            {
+            } else {
                 row.add(this.getPreview(p));
             }
 
@@ -115,10 +105,11 @@
     }
 
     /**
-     * Subclasses are responsible of collecting the properties to display
-     * 
      * @param ctx
-     * @return
+     *        the <code>Context</code>
+     * @return collected <code>Property</code> s to display
+     * @throws Exception
+     *         if the <code>Property</code> s can't be retrieved
      */
     protected abstract Iterator getProperties(Context ctx) throws Exception;
 
@@ -127,14 +118,12 @@
      * @return the first 50 characters of single value properties
      * @throws RepositoryException
      */
-    private String getPreview(Property p) throws RepositoryException
-    {
+    private String getPreview(Property p) throws RepositoryException {
         String value = p.getValue().getString();
         return value.substring(0, Math.min(value.length(), 50));
     }
 
     /**
-     * 
      * @param property
      * @return a <code>Collection</code> in which element contains the first
      *         50 characters of the <code>Value</code>'s string
@@ -143,18 +132,14 @@
      * @throws ValueFormatException
      */
     private Collection getMultiplePreview(Property p)
-            throws ValueFormatException, RepositoryException
-    {
+            throws ValueFormatException, RepositoryException {
         Collection c = new ArrayList();
         Value[] values = p.getValues();
-        for (int i = 0; i < values.length; i++)
-        {
-            try
-            {
+        for (int i = 0; i < values.length; i++) {
+            try {
                 String value = values[i].getString();
                 c.add(value.substring(0, Math.min(value.length(), 50)));
-            } catch (ValueFormatException e)
-            {
+            } catch (ValueFormatException e) {
                 c.add(bundle.getString("phrase.notavailable"));
             }
         }

Modified: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/Cat.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/Cat.java?rev=312896&r1=312895&r2=312896&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/Cat.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/Cat.java Tue Oct 11 07:38:54 2005
@@ -35,11 +35,10 @@
 import org.apache.jackrabbit.command.CommandException;
 
 /**
- * Displays the content of a <code>Property</code> or a <code>Node</code> of
+ * Display the content of a <code>Property</code> or a <code>Node</code> of
  * type nt:file or nt:resource.
  */
-public class Cat implements Command
-{
+public class Cat implements Command {
     /** property name */
     private String pathKey = "path";
 
@@ -47,36 +46,39 @@
     private String indexKey = "index";
 
     /**
-     * @inheritDoc
+     * {@inheritDoc}
      */
-    public boolean execute(Context ctx) throws Exception
-    {
+    public boolean execute(Context ctx) throws Exception {
         String path = (String) ctx.get(this.pathKey);
         Item item = CommandHelper.getItem(ctx, path);
-        if (item.isNode())
-        {
+        if (item.isNode()) {
             printNode(ctx, (Node) item);
-        } else
-        {
+        } else {
             printProperty(ctx, (Property) item);
         }
         return false;
     }
 
-    public String getPathKey()
-    {
+    /**
+     * @return the path key
+     */
+    public String getPathKey() {
         return pathKey;
     }
 
-    public void setPathKey(String path)
-    {
+    /**
+     * @param path
+     *        the path key to set
+     */
+    public void setPathKey(String path) {
         this.pathKey = path;
     }
 
     /**
-     * 
      * @param ctx
+     *        the <code>Context</code>
      * @param n
+     *        the <code>Node</code>
      * @throws PathNotFoundException
      * @throws CommandException
      * @throws RepositoryException
@@ -85,28 +87,25 @@
      */
     private void printNode(Context ctx, Node n) throws PathNotFoundException,
             CommandException, RepositoryException, IllegalStateException,
-            IOException
-    {
-        if (n.isNodeType("nt:file"))
-        {
+            IOException {
+        if (n.isNodeType("nt:file")) {
             printValue(ctx, n.getNode("jcr:content").getProperty("jcr:data")
                 .getValue());
-        } else if (n.isNodeType("nt:resource"))
-        {
+        } else if (n.isNodeType("nt:resource")) {
             printValue(ctx, n.getProperty("jcr:data").getValue());
-        } else
-        {
-            throw new CommandException("exception.cat.unsupported.type", new String[]
-            {
-                n.getPrimaryNodeType().getName()
-            });
+        } else {
+            throw new CommandException("exception.cat.unsupported.type",
+                new String[] {
+                    n.getPrimaryNodeType().getName()
+                });
         }
     }
 
     /**
-     * 
      * @param ctx
+     *        the <code>Context</code>
      * @param p
+     *        the <code>Property</code>
      * @throws CommandException
      * @throws ValueFormatException
      * @throws IllegalStateException
@@ -115,28 +114,25 @@
      */
     private void printProperty(Context ctx, Property p)
             throws CommandException, ValueFormatException,
-            IllegalStateException, RepositoryException, IOException
-    {
+            IllegalStateException, RepositoryException, IOException {
         String indexStr = (String) ctx.get(this.indexKey);
         int index = 0;
-        if (indexStr != null)
-        {
+        if (indexStr != null) {
             index = Integer.parseInt(indexStr);
         }
-        if (p.getDefinition().isMultiple())
-        {
+        if (p.getDefinition().isMultiple()) {
             printValue(ctx, p.getValues()[index]);
-        } else
-        {
+        } else {
             printValue(ctx, p.getValue());
         }
     }
 
     /**
      * Read the value
-     * 
      * @param ctx
+     *        the <code>Context</code>
      * @param value
+     *        the <code>Value</code>
      * @throws ValueFormatException
      * @throws IllegalStateException
      * @throws RepositoryException
@@ -144,33 +140,29 @@
      */
     private void printValue(Context ctx, Value value)
             throws ValueFormatException, IllegalStateException,
-            RepositoryException, IOException
-    {
+            RepositoryException, IOException {
         PrintWriter out = CommandHelper.getOutput(ctx);
         out.println();
         BufferedReader in = new BufferedReader(new StringReader(value
             .getString()));
         String str = null;
-        while ((str = in.readLine()) != null)
-        {
+        while ((str = in.readLine()) != null) {
             out.println(str);
         }
     }
 
     /**
-     * @return Returns the indexKey.
+     * @return the index key
      */
-    public String getIndexKey()
-    {
+    public String getIndexKey() {
         return indexKey;
     }
 
     /**
      * @param indexKey
-     *            The indexKey to set.
+     *        the index key to set
      */
-    public void setIndexKey(String indexKey)
-    {
+    public void setIndexKey(String indexKey) {
         this.indexKey = indexKey;
     }
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/Describe.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/Describe.java?rev=312896&r1=312895&r2=312896&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/Describe.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/Describe.java Tue Oct 11 07:38:54 2005
@@ -22,12 +22,13 @@
 /**
  * Describes the given <code>Node</code>.
  */
-public class Describe implements Command
-{
+public class Describe implements Command {
 
-	public boolean execute(Context arg0) throws Exception
-	{
-        throw new UnsupportedOperationException() ;
-	}
+    /**
+     * {@inheritDoc}
+     */
+    public boolean execute(Context arg0) throws Exception {
+        throw new UnsupportedOperationException();
+    }
 
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/Dump.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/Dump.java?rev=312896&r1=312895&r2=312896&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/Dump.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/Dump.java Tue Oct 11 07:38:54 2005
@@ -30,59 +30,67 @@
 import org.apache.jackrabbit.command.CommandHelper;
 
 /**
- * Dumps stored data from the current working node
+ * Dump stored data from the current working <code>Node</code>
  */
-public class Dump implements Command
-{
-	/** root node to dump */
-	private String pathKey = "path";
+public class Dump implements Command {
+    /** root node to dump */
+    private String pathKey = "path";
 
-	public boolean execute(Context ctx) throws Exception
-	{
-		String path = (String) ctx.get(this.pathKey);
-		PrintWriter out = CommandHelper.getOutput(ctx);
-		dump(out, CommandHelper.getNode(ctx, path));
-		return false;
-	}
+    /**
+     * {@inheritDoc}
+     */
+    public boolean execute(Context ctx) throws Exception {
+        String path = (String) ctx.get(this.pathKey);
+        PrintWriter out = CommandHelper.getOutput(ctx);
+        dump(out, CommandHelper.getNode(ctx, path));
+        return false;
+    }
 
-	public void dump(PrintWriter out, Node n) throws RepositoryException
-	{
-		out.println(n.getPath());
-		PropertyIterator pit = n.getProperties();
-		while (pit.hasNext())
-		{
-			Property p = pit.nextProperty();
-			out.print(p.getPath() + "=");
-			if (p.getDefinition().isMultiple())
-			{
-				Value[] values = p.getValues();
-				for (int i = 0; i < values.length; i++)
-				{
-					if (i > 0)
-						out.println(",");
-					out.println(values[i].getString());
-				}
-			} else
-			{
-				out.print(p.getString());
-			}
-			out.println();
-		}
-		NodeIterator nit = n.getNodes();
-		while (nit.hasNext())
-		{
-			Node cn = nit.nextNode();
-			dump(out, cn);
-		}
-	}
+    /**
+     * Dumps the given <code>Node</code> to the given <code>PrintWriter</code>
+     * @param out
+     *        the <code>PrintWriter</code>
+     * @param n
+     *        the <code>Node</code>
+     * @throws RepositoryException
+     */
+    public void dump(PrintWriter out, Node n) throws RepositoryException {
+        out.println(n.getPath());
+        PropertyIterator pit = n.getProperties();
+        while (pit.hasNext()) {
+            Property p = pit.nextProperty();
+            out.print(p.getPath() + "=");
+            if (p.getDefinition().isMultiple()) {
+                Value[] values = p.getValues();
+                for (int i = 0; i < values.length; i++) {
+                    if (i > 0)
+                        out.println(",");
+                    out.println(values[i].getString());
+                }
+            } else {
+                out.print(p.getString());
+            }
+            out.println();
+        }
+        NodeIterator nit = n.getNodes();
+        while (nit.hasNext()) {
+            Node cn = nit.nextNode();
+            dump(out, cn);
+        }
+    }
 
-	public String getPathKey()
-	{
-		return pathKey;
-	}
+    /**
+     * @return the path key
+     */
+    public String getPathKey() {
+        return pathKey;
+    }
 
-	public void setPathKey(String pathKey)
-	{
-		this.pathKey = pathKey;
-	}
+    /**
+     * @param pathKey
+     *        the path key to set
+     */
+    public void setPathKey(String pathKey) {
+        this.pathKey = pathKey;
+    }
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/Help.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/Help.java?rev=312896&r1=312895&r2=312896&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/Help.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/Help.java Tue Oct 11 07:38:54 2005
@@ -34,10 +34,10 @@
 import org.apache.jackrabbit.command.cli.Option;
 
 /**
- * Help on available commands
+ * Show available <code>Command</code>s. If a <code>Command</code> is
+ * specified it will show its description, usage and parameters.
  */
-public class Help implements Command
-{
+public class Help implements Command {
     /** bundle */
     private static ResourceBundle bundle = CommandHelper.getBundle();
 
@@ -50,16 +50,16 @@
     /** command key */
     private String commandKey = "command";
 
-    public boolean execute(Context ctx) throws Exception
-    {
-        String command = (String) ctx.get(this.commandKey) ;
+    /**
+     * {@inheritDoc}
+     */
+    public boolean execute(Context ctx) throws Exception {
+        String command = (String) ctx.get(this.commandKey);
         PrintWriter out = CommandHelper.getOutput(ctx);
         out.println();
-        if (command == null)
-        {
+        if (command == null) {
             helpAll(ctx);
-        } else
-        {
+        } else {
             helpCommand(ctx);
         }
         return false;
@@ -67,53 +67,47 @@
 
     /**
      * Writes help for all the commands
-     * 
      * @param ctx
+     *        the current working <code>Context</code>
      * @throws CommandException
      */
-    private void helpAll(Context ctx) throws CommandException
-    {
+    private void helpAll(Context ctx) throws CommandException {
         PrintWriter out = CommandHelper.getOutput(ctx);
         Collection descriptors = factory.getCommandLines();
         Iterator iter = descriptors.iterator();
 
         // Tab position
         int tabPos = 20;
-        while (iter.hasNext())
-        {
+        while (iter.hasNext()) {
             CommandLine desc = (CommandLine) iter.next();
-            if (desc.getName().length() > tabPos)
-            {
+            if (desc.getName().length() > tabPos) {
                 tabPos = desc.getName().length() + 1;
             }
         }
 
         iter = descriptors.iterator();
-        while (iter.hasNext())
-        {
+        while (iter.hasNext()) {
             CommandLine desc = (CommandLine) iter.next();
             StringBuffer buf = new StringBuffer(desc.getName());
             buf.setLength(tabPos);
-            for (int i = desc.getName().length(); i < buf.length(); i++)
-            {
+            for (int i = desc.getName().length(); i < buf.length(); i++) {
                 buf.setCharAt(i, ' ');
             }
             buf.append(desc.getLocalizedDescription());
-            hf.printWrapped(out, 74, tabPos, buf.toString());
+            hf.printWrapped(out, 70, tabPos, buf.toString());
         }
     }
 
     /**
      * Writes detailed help for the given command
-     * 
      * @param ctx
+     *        the current working <code>Context</code>
      * @throws CommandException
      */
-    private void helpCommand(Context ctx) throws CommandException
-    {
+    private void helpCommand(Context ctx) throws CommandException {
         PrintWriter out = CommandHelper.getOutput(ctx);
-        
-        String cmdName = (String) ctx.get(this.commandKey) ;
+
+        String cmdName = (String) ctx.get(this.commandKey);
 
         CommandLine desc = factory.getCommandLine(cmdName);
 
@@ -127,16 +121,14 @@
 
         // Arguments
         Iterator iter = desc.getArguments().values().iterator();
-        while (iter.hasNext())
-        {
+        while (iter.hasNext()) {
             Argument arg = (Argument) iter.next();
             out.print("<" + arg.getLocalizedArgName() + "> ");
         }
 
         // Options
         iter = desc.getOptions().values().iterator();
-        while (iter.hasNext())
-        {
+        while (iter.hasNext()) {
             Option arg = (Option) iter.next();
             out.print("-" + arg.getName() + " <" + arg.getLocalizedArgName()
                     + "> ");
@@ -144,20 +136,17 @@
 
         // flags
         iter = desc.getFlags().values().iterator();
-        while (iter.hasNext())
-        {
+        while (iter.hasNext()) {
             Flag arg = (Flag) iter.next();
             out.print("-" + arg.getName() + " ");
         }
         out.println();
 
         // Alias
-        if (desc.getAlias().size() > 0)
-        {
+        if (desc.getAlias().size() > 0) {
             out.print(bundle.getString("word.alias") + ":");
             iter = desc.getAlias().iterator();
-            while (iter.hasNext())
-            {
+            while (iter.hasNext()) {
                 out.print((String) iter.next() + " ");
 
             }
@@ -166,23 +155,20 @@
         out.println();
 
         // Arguments details
-        if (desc.getArguments().size() > 0)
-        {
+        if (desc.getArguments().size() > 0) {
             out.println("<" + bundle.getString("word.arguments") + ">");
             printParam(ctx, desc.getArguments().values());
         }
 
         // Options details
-        if (desc.getOptions().values().size() > 0)
-        {
+        if (desc.getOptions().values().size() > 0) {
             out.println();
             out.println("<" + bundle.getString("word.options") + ">");
             printParam(ctx, desc.getOptions().values());
         }
 
         // flag details
-        if (desc.getFlags().values().size() > 0)
-        {
+        if (desc.getFlags().values().size() > 0) {
             out.println();
             out.println("<" + bundle.getString("word.flags") + ">");
             printParam(ctx, desc.getFlags().values());
@@ -190,28 +176,31 @@
 
     }
 
-    private void printParam(Context ctx, Collection params)
-    {
-        int[] width = new int[]
-        {
+    /**
+     * @param ctx
+     *        the current working <code>Context</code>
+     * @param params
+     *        the parameters
+     */
+    private void printParam(Context ctx, Collection params) {
+        int[] width = new int[] {
                 10, 10, 10, 40
         };
 
-        String[] header = new String[]
-        {
-                bundle.getString("word.name"), bundle.getString("word.argument"),
-                bundle.getString("word.required"), bundle.getString("word.description")
+        String[] header = new String[] {
+                bundle.getString("word.name"),
+                bundle.getString("word.argument"),
+                bundle.getString("word.required"),
+                bundle.getString("word.description")
         };
 
         PrintHelper.printRow(ctx, width, header);
         PrintHelper.printSeparatorRow(ctx, width, '-');
 
         Iterator iter = params.iterator();
-        while (iter.hasNext())
-        {
+        while (iter.hasNext()) {
             AbstractParameter p = (AbstractParameter) iter.next();
-            String[] item = new String[]
-            {
+            String[] item = new String[] {
                     p.getName(), p.getLocalizedArgName(),
                     Boolean.toString(p.isRequired()),
                     p.getLocalizedDescription()
@@ -222,19 +211,17 @@
     }
 
     /**
-     * @return Returns the commandKey.
+     * @return the command key
      */
-    public String getCommandKey()
-    {
+    public String getCommandKey() {
         return commandKey;
     }
 
     /**
      * @param commandKey
-     *            The commandKey to set.
+     *        the command key to set
      */
-    public void setCommandKey(String commandKey)
-    {
+    public void setCommandKey(String commandKey) {
         this.commandKey = commandKey;
     }
 }



Mime
View raw message