incubator-kato-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From monte...@apache.org
Subject svn commit: r779977 - in /incubator/kato/trunk/org.apache.kato.tools.katoview: .classpath depends/ depends/commons-jxpath-1.3.jar src/org/apache/kato/katoview/commands/RootCommand.java src/org/apache/kato/katoview/commands/XPathCommand.java
Date Fri, 29 May 2009 13:56:48 GMT
Author: monteith
Date: Fri May 29 13:56:47 2009
New Revision: 779977

URL: http://svn.apache.org/viewvc?rev=779977&view=rev
Log:
Addjxpath command to katoview.

Added:
    incubator/kato/trunk/org.apache.kato.tools.katoview/depends/
    incubator/kato/trunk/org.apache.kato.tools.katoview/depends/commons-jxpath-1.3.jar   (with
props)
    incubator/kato/trunk/org.apache.kato.tools.katoview/src/org/apache/kato/katoview/commands/XPathCommand.java
  (with props)
Modified:
    incubator/kato/trunk/org.apache.kato.tools.katoview/.classpath
    incubator/kato/trunk/org.apache.kato.tools.katoview/src/org/apache/kato/katoview/commands/RootCommand.java

Modified: incubator/kato/trunk/org.apache.kato.tools.katoview/.classpath
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato.tools.katoview/.classpath?rev=779977&r1=779976&r2=779977&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato.tools.katoview/.classpath (original)
+++ incubator/kato/trunk/org.apache.kato.tools.katoview/.classpath Fri May 29 13:56:47 2009
@@ -5,6 +5,6 @@
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
 	<classpathentry combineaccessrules="false" kind="src" path="/HprofBinaryReaderPOC"/>
 	<classpathentry combineaccessrules="false" kind="src" path="/KatoHProfAdapterPOC"/>
-	<classpathentry kind="lib" path="C:/Projects/DTFJ/depends/commons-jxpath-1.3/commons-jxpath-1.3.jar"/>
+	<classpathentry kind="lib" path="depends/commons-jxpath-1.3.jar"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>

Added: incubator/kato/trunk/org.apache.kato.tools.katoview/depends/commons-jxpath-1.3.jar
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato.tools.katoview/depends/commons-jxpath-1.3.jar?rev=779977&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/kato/trunk/org.apache.kato.tools.katoview/depends/commons-jxpath-1.3.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: incubator/kato/trunk/org.apache.kato.tools.katoview/src/org/apache/kato/katoview/commands/RootCommand.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato.tools.katoview/src/org/apache/kato/katoview/commands/RootCommand.java?rev=779977&r1=779976&r2=779977&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato.tools.katoview/src/org/apache/kato/katoview/commands/RootCommand.java
(original)
+++ incubator/kato/trunk/org.apache.kato.tools.katoview/src/org/apache/kato/katoview/commands/RootCommand.java
Fri May 29 13:56:47 2009
@@ -36,6 +36,7 @@
 		child_commands.add(new FindCommand(o));
 		child_commands.add(new DeadlockCommand(o));
 		child_commands.add(new TomcatCommand(o));
+		child_commands.add(new XPathCommand(o));
 		child_commands.add(new SetCommand(o));
 		child_commands.add(new ShowCommand(o));		
 		child_commands.add(new WhatisCommand(o));

Added: incubator/kato/trunk/org.apache.kato.tools.katoview/src/org/apache/kato/katoview/commands/XPathCommand.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato.tools.katoview/src/org/apache/kato/katoview/commands/XPathCommand.java?rev=779977&view=auto
==============================================================================
--- incubator/kato/trunk/org.apache.kato.tools.katoview/src/org/apache/kato/katoview/commands/XPathCommand.java
(added)
+++ incubator/kato/trunk/org.apache.kato.tools.katoview/src/org/apache/kato/katoview/commands/XPathCommand.java
Fri May 29 13:56:47 2009
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.kato.katoview.commands;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Stack;
+
+import org.apache.commons.jxpath.JXPathContext;
+import org.apache.kato.image.Image;
+import org.apache.kato.katoview.Output;
+
+/**
+ * Provides access to Kato API using JXPath
+ * 
+ *
+ */
+public class XPathCommand extends Command {
+	private static final String COMMAND_NAME="xpath";
+	private static final String DESCRIPTION="JXPath API support";
+	private static final String LONG_DESCRIPTION="xpath <Xpath query>";
+	
+	protected XPathCommand(Output o) {
+		super(o, COMMAND_NAME, DESCRIPTION, LONG_DESCRIPTION);
+		child_commands = null;
+
+	}
+	
+	public void doCommand(Stack args, Image loadedImage, HashMap properties) {
+		if (args.size() == 0) {
+			out.println(LONG_DESCRIPTION);
+			return;
+		}
+		String path = (String) args.get(0);
+		
+		JXPathContext context = JXPathContext.newContext(loadedImage);
+		
+		Iterator values = context.iterate(path);
+
+		while (values.hasNext()) {
+			Object value = values.next();
+			
+			if (value instanceof String) {
+				out.println("\""+((String) value)+"\"");		
+			} else if (value instanceof Number) {
+				out.println(value.toString());
+			} else if (value instanceof Character) {
+				out.println("'"+((Character)value).charValue()+"'");
+			} else {
+				out.println(value.toString());
+			}
+		}
+	}
+
+}

Propchange: incubator/kato/trunk/org.apache.kato.tools.katoview/src/org/apache/kato/katoview/commands/XPathCommand.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message