juneau-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] jamesbognar closed pull request #15: Add SvlExample for juneau-svl demo
Date Mon, 12 Nov 2018 17:05:07 GMT
jamesbognar closed pull request #15: Add SvlExample for juneau-svl demo
URL: https://github.com/apache/juneau/pull/15
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/juneau-examples/juneau-examples-core/src/main/java/org/apache/juneau/examples/core/svl/SvlExample.java
b/juneau-examples/juneau-examples-core/src/main/java/org/apache/juneau/examples/core/svl/SvlExample.java
new file mode 100644
index 000000000..3c08fb579
--- /dev/null
+++ b/juneau-examples/juneau-examples-core/src/main/java/org/apache/juneau/examples/core/svl/SvlExample.java
@@ -0,0 +1,58 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
agreements.  See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership.
 The ASF licenses this file        *
+// * to you 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.juneau.examples.core.svl;
+
+import org.apache.juneau.svl.*;
+
+/**
+ * TODO
+ * 
+ */
+public class SvlExample {
+
+	/**
+	 * TODO
+	 * 
+	 * @param args
+	 */
+	public static void main(String[] args) {
+		
+		VarResolver vr = VarResolver.DEFAULT;
+		
+		// $E{key[,default]} for getting environment variables
+		System.out.println(vr.resolve("JAVA_HOME=$E{JAVA_HOME, not defined}"));
+		
+		// $S{key[,default]} for getting system properties (uses System.getProperty() )
+		System.out.println(vr.resolve("os.name=$S{os.name, not defined}"));
+		
+		// $IF{key[,default]} general if or if-else condition
+		// $NE{arg} will return true if not empty
+		System.out.println(vr.resolve("TEST_VAR is $IF{$NE{$E{TEST_VAR}}, not empty, empty}"));

+		
+		// $SW{arg,pattern1:then1[,pattern2:then2...]} switch-case
+		System.out.println(vr.resolve("$SW{Carrot, *Ap*:Fruit, *Car*:Veg, *:N/A}"));
+		
+		// $PR{arg,pattern,replace} pattern replace
+		System.out.println(vr.resolve("Java version=$PR{$S{java.version}, (_([0-9]+)), \\ build=\\$2}"));
+
+		// $UC{arg} uppercase $LC{arg} lowecase
+		System.out.println(vr.resolve("$LC{JAVA_HOME} $UC{$E{JAVA_HOME}}"));
+		
+		/*
+		 *  See all supported variable types at,
+		 *  http://juneau.apache.org/site/apidocs-7.2.1/overview-summary.html#juneau-svl
+		 *  NOTE - juneau-svl supports nested variables well
+		 * */
+	}
+
+}


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message