java for xpages development
DESCRIPTION
Java is an important skill to have as an XPages developer. This webinar will provide a foundation of the Java skills you need and explain how to best acquire them. Come see how Java is used with detailed code examples that demonstrate how to use core Java code, Java Beans, Managed Beans, and third party Java libraries in your applications. After this webinar you will know exactly how to add Java as a tool in your development toolbox.TRANSCRIPT
Java for XPages Development
Tweet about this event: #XPages and mention us: @teamstudio @TLCCLTD
@PaulDN @ptcalhoun January 16, 2014
@teamstudio teamstudio.com
@TLCCLTD
Courtney Carter Inbound Marketing Specialist
Who We Are • Our background is in creating tools for collaborative
computing in mid-size and large enterprises, primarily for IBM Notes
• Easy-to-use tools for developers and administrators • 2300+ active customers, 47 countries • Offices in US, UK and Japan • Entered mobile space in 2010 with Unplugged: easy
mobilization of Notes apps to Blackberry, Android and iOS
Teamstudio Unplugged • Your mobile Domino server: take your Notes apps
with you! • End-users access Notes applications from mobile
devices whether online or offline • Leverages existing skills and technology – XPages –
a replication model you already know • Unplugged 3.0 recently released • IBM Collaboration Solutions Award Winner 2013
Unplugged Templates • Continuity – Mobile offline access to
BCM programs
• OneView Approvals – Expense approvals; anywhere, anytime
• CustomerView – lightweight CRM framework for field sales and field service teams
• Contacts – customer information database • Activities – customer activity log • Media – mobile offline file storage and access
• Next Teamstudio/TLCC webinar: February 13, 2014
• Next Wireless Wednesdays webinar: Part 2 on March 5, 2014 o Learn Domino mobile development
• IBM Connect: booth 114; Mobile Made Easy session
• Promotion:
o Get 20% off your order of 25+ licenses of Unplugged
Java in XPages Development
1
#XPages
Your Host Today:
Howard Greenberg TLCC @TLCCLtd
Upcoming and Recorded Webinars
2
Next Webinar – February 13th Creating a Great XPages User Interface with Howard and Paul
www.tlcc.com/xpages-webinar
View Previous Webinars (use url above)
3
Click here for more information and to signup
Session Date
JMP101: Java for XPages Development with Paul Calhoun Sunday at 10:30
JMP102: Creating a Great XPages User Interface with Howard and Paul D.
Sunday at 1:30
SHOW102: XPages: Still No Experience Necessary with Paul Calhoun and Kathy Brown
Wednesday at 10:30
BP202: Rapid XPages Development Using the Application Layout Control with Howard and Paul D.
Thursday at 11:15
TLCC Courses and Services
• The Leader in Notes and Domino Training since 1997
• Self Paced Distance Learning Courses for Notes/Domino
– XPages, Development, and Administration (user too!) • OnSite Private Classes • TLCC Mentoring Services • Free demo courses
– Intro. To XPages Development – Application Development 1
4
5
• Save hundreds and even Thousands of Dollars on the most popular courses and packages
• Through January 31st • No need to attend Connect But if you do, all certification tests are free! TLCC’s courses will help you get ready for the exams
Click here for more information
New TLCC Java Courses and Package
• Java 2 for XPages Development (9.0) • Debugging • Expression Language • JavaBeans and Managed Beans • Third Party Java Libraries
– On Sale for $599, save $300
• Java 1 for XPages Development (9.0) – Covers the Java Language
• Java for XPages Package (Domino 9) – Has both Java courses – On Sale for only $999, save $500 – Until January 31st Only
6
Asking Questions
7
Q & A at the end! Type in your questions as they come up
Your Presenters Today:
#XPages 8
Paul Della-Nebbia TLCC
@PaulDN
Paul Calhoun NetNotes Solutions
@ptcalhoun
Agenda
9
• The Java Language Fundamentals • Domino Designer Settings • Java Beans and Managed Beans • Calling Java Code from an XPage • Using the Expression Language • Accessing Domino Objects • Using Third Party Libraries • Wrap Up
How do you eat an Elephant ?
10
• One Bite at a time !!! • Learning Java™ is a lot like eating an Elephant !!
– It’s a big job !! – And there’s no clear
place where to start !!
Resources …
11
• TLCC Courses – Rapid XPages Development – Java 1 for XPages Development – Java 2 for XPages Development
• http://www.tlcc.com/admin/tlccsite.nsf/DeveloperView.xsp
Resources …
12
• Start with J2SE (Java 2 STANDARD Edition) – This covers core Java functionality
• Syntax • Data Types • Constructs • Core Classes
- java.lang - java.io - java.net - etc.
– Allow 3-6 Months
http://www.oracle.com/technetwork/java/javase/overview/index.html
Resources
13
• Learn XML (not part of Sun Certification) – XML Syntax – DTD/XML Schema – XSL
• XSLT • XSL:FO
• Finally jump on the J2E bandwagon (In this order!) – Servlets – JSPs – JSFs – Allow another 3-6 months
• Then the rest of the J2E specification – Allow another 3-6 months
Roadblocks
14
• Road Blocks on your Journey to Learning Java
– “Linear” thinking instead of thinking in “Objects”
• If you have done any LotusScript Class development you are on your way !
– Starting to learn Java with J2E applications (Servlets, JSPs)
– Trying to start with the Java Enterprise Technologies
– Try to learn Java in conjunction with a
HUGE Mission critical project
– Not applying what you learn EVERYDAY !!
• This is the MOST critical roadblock !!!
Very Wise Saying
15
“If the only tool you have is a hammer, you tend to see every problem as a nail” Abraham Maslow
Your XPages Development Toolbox
16
Formula Language
LotusScript
Java JavaScript
XML
XSLT
dojo
jQuery
CSS
Is the Java Language still relevant ?
17
• The Tiobe index as of December 2013
http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html
Java Version in Notes / Domino
Java Standard Edition (J2SE)
Java 2 Java Development Kit (JDK) Version 6.0 Used in Notes Domino 9.0 and 8.5
Java 2 Java Development Kit (JDK) Version 1.5.0 Used in Notes Domino 8
Java 2 Software Development Kit (SDK) Version 1.4.2 Used in Notes Domino 7
Java 2 Software Development Kit (SDK) Version 1.4.1 (EOL)
Java 2 Software Development Kit (SDK) Version 1.4.0 (EOL)
Java 2 Software Development Kit (SDK) Version 1.3.1 Used in Notes Domino 6
Java 2 Software Development Kit (SDK) Version 1.3.0 (EOL)
Java 2 Software Development Kit (SDK) Version 1.2.2
Java 1 JDK Development Kit (JDK) Version 1.1.8 Used in Notes Domino 5
18
Agenda
19
• The Java Language Fundamentals • Domino Designer Settings • Java Beans and Managed Beans • Calling Java Code from an XPage • Using the Expression Language • Accessing Domino Objects • Using Third Party Libraries • Wrap Up
20
• There are several things that can be configured that will make your Java in XPages development experience easier
• The following are recommendations for setting properties in the Domino Designer BEFORE you start developing
Configure DDE for XPage Development
Configure Memory
21
• Change your memory allocation – Edit the jvm.properties file located in the client
installation directory under • framework/rcp/deploy
Configure Memory
22
• Edit with any text editor – Xmx – Total amount of RAM for
Designer AND Client • Set to at least 512m • Don’t set equal to the amount of
system RAM – Xms – Starting Heap size
• Set to at least 128m • Don’t set equal to Xmx value
– Xmca – Memory block size • Set to at least 512k • That’s a “k” NOT A “m”
• Always set in multiple of “4” • Will not take effect until client is
restarted (if running when edited)
Show Heap
• Monitor Memory Used • In Designer Preferences
– Select General – Check “Show heap status”
• Even though this is a checkbox, it does not “remember” the setting.
– It has to be checked each time you start Designer
• Heap status in the lower left hand corner of Designer
– Monitor the amount of memory being used
– Click the trash can icon to trigger garbage collection
23
Configure XML Editor
• Set XML Editor formatting for viewing XPage source
• In Designer preferences – Select XML | XML Files | Editor – Change Line width – Check “Split multiple attributes each on a
new line” – Check “Clear all blank lines”
• Any new XPages source will adhere to these settings
• Existing XPages can be reformatted” – keyboard shortcut is
<shift><ctrl><f>
24
Formatting Differences
• Before and after XPage Source Formatting
25
Java Editor Margin
26
• In the Designer Preferences dialog, choose: Java > Code Style > Formatter
– Click the “New” button – The included profiles can not be edited
Change Java Editor Margin
• Select the “Line Wrapping” tab – Change the “Maximum line width:” property to at
least 120
27
Change Java Editor Margin
28
• Ensure your profile is the active profile and save preferences
Agenda
29
• The Java Language Fundamentals • Domino Designer Settings • Java Beans and Managed Beans • Calling Java Code from an XPage • Using the Expression Language • Accessing Domino Objects • Using Third Party Libraries • Wrap Up
Java Beans vs Managed Beans
• One of the most confusing issues when coding with Java • A Java Bean is a Plain ‘ol Java Object (POJO) or Java class that
conforms to a specific programming convention – Must have a public no-argument constructor, otherwise the default no
argument constructor is used – Class properties (fields) must be defined as private and accessible using
standard public method calls • Start with get, set, or is (used for boolean properties instead of get) • Commonly referred to as "getter" and "setter" methods
– The class must implement java.io.Serializable to be technically qualified as a JavaBean.
• This is not “necessary” but a best practice
• Up to the developer to follow these conventions when creating a JavaBean
30
Java Beans vs Managed Beans
• So what is a Managed Bean?
• It is important to understand that it makes no difference if a bean is going to be just a Java Bean or a Managed Bean, it is coded the exact same way
– Nothing in the Java source code defines it as a "Managed Bean” – This is all done in the framework, in our case, XPages
• Java Beans are NOT Managed Beans
– But they can be, they just need to be "managed” – A Managed Bean follows all of the same conventions as a regular JavaBean, but is
"Managed" by virtue of being registered with the framework it is incorporated in (like the XPages runtime framework)
– A Managed Bean has scope in the framework and its methods can be called directly without the need to first instantiate an object variable for the Managed Bean
• This is the PRIMARY factor that separates Java Beans from Managed Beans
31
A Java Bean Example
• Lets start with a simple Java Bean Example
32
A Java Bean Example
33
• Public “getter” and “setters”
Calling the Methods from an XPage
• Button Code – The SSJS Code – In order to “use” the Java Bean Code it has to be instantiated (lines 1&2) – The public getter and setter methods have to be called
importPackage(com.nnsu.beans); var jce:MyBean = new MyBean(); jce.setFName("Paul"); jce.setLName("Calhoun"); jce.setAge(50); jce.setHobbies(new java.util.ArrayList(java.util.Arrays.asList(["Riding Motorcycles","Playing with Grandkids"]))); var retOutput = jce.getFName()+ " "+ jce.getLName()+"</br>"; retOutput += "He is: " + jce.getAge()+"</br>"; for (var i=0;i<jce.getHobbies().size();i++) retOutput += jce.getHobbies().get(i) +"</br>"; getComponent("computedField1").setValue(retOutput);
34
Demo: A Java Bean
35
Making a “Managed Bean”from the same code
• Java code becomes a “Managed Bean” when it is registered with the framework it is running in (In our case XPages)
• Managed Beans are “Registered” in the faces-config.xml file in the application they will be used in
36
Faces Config
• The faces-config.xml file is an xml file where managed beans are defined using the following syntax:
• To “Register” the previous bean as a “Managed Bean” the syntax would be:
<managed-bean> <description>description</description> <managed-bean-name>beanName</managed-bean-name> <managed-bean-class>beanClass</managed-bean-class> <managed-bean-scope>beanScope</managed-bean-scope> </managed-bean>
<managed-bean> <description>My Managed Bean</description> <managed-bean-name>myBean</managed-bean-name> <managed-bean-class>com.nnsu.beans.MyBean</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> </managed-bean>
37
Registration components
38
• The description is just that, a short description of what the bean does
• The name will be the programmatic name the bean is instantiated with
• The class is the full class path to the code in the application • The scope is the “life” of the Managed Bean which can be:
– application - The bean is available for as long as the application is in memory and is shared among all users of the application.
– session - The bean is available for the current user session and is unique for each user.
– view - The bean is available for the life of the current "view" or XPage. – request - The bean is available only while the content of the individual XPage is
being submitted. – none - The bean is instantiated each time it is referenced. This is helpful if the
bean is referenced within another bean.
Calling the Methods from an XPage
• Button Code – The SSJS Code – To “use” the Managed Bean Code call the methods using the
defined bean name the code was registered with in the faces-config.xml
39
Calling the Methods from an XPage
40
• Button Code – Notice that the Bean is never instantiated. This is because the
framework (XPages) instantiates it when it is called the first time.
myBean.setFName("Paul"); myBean.setLName("Calhoun"); myBean.setAge(50); myBean.setHobbies(new java.util.ArrayList(java.util.Arrays.asList(["Riding Motorcycles","Playing with Grandkids"]))); var retOutput = myBean.getFName()+ " "+ myBean.getLName()+"</br>"; retOutput += "He is: " + myBean.getAge()+"</br>"; for (var i=0;i<myBean.getHobbies().size();i++) retOutput += myBean.getHobbies().get(i) +"</br>"; getComponent("computedField1").setValue(retOutput);
Benefits of Managed Bean
• Managed Beans have scope – The setter methods can be executed in one event and – The getter methods executed in another event – The methods of the managed bean can be used across multiple pages in
the same application
• So should Java Beans ALWAYS be Managed Beans?? – As a rule, NO !!! – Only use Managed Beans when you need the values in the bean to
“persist” in your application – If persistence is not required then just use POJO’s
41
Demo: Managed Beans
42
Agenda
43
• The Java Language Fundamentals • Domino Designer Settings • Java Beans and Managed Beans • Calling Java Code from an XPage • Using the Expression Language • Accessing Domino Objects • Using Third Party Libraries • Wrap Up
Executing Java Code
44
• The only Java code that can be “called” from an XPage is: – Java Code Elements – Java Source Code in a source folders in the Virtual File System (VFS)
• Primarily prior to 9.0 – Code in .jar files located in the JARs folder – Code in .jar files located in the WebContent/WEB-INF/lib folder – Compiled .class and .jar files located in the jvm/lib/ext folder in the file
system
Java Code Elements
• Create Java source code that will be compiled into individual class files when the project is built
• Java Code elements are automatically added to the classpath
45
Source code in source folders
• Java Source code located in a Java Source folder in the VFS can be seen in the “Package Explorer” view of the XPages perspective
• Java Code in a “source” folder is automatically added to the classpath
46
Code in .jar files in the JARS design folder
• Locally developed or third party Java Archive Files (.jar) can be imported into the Jar design element
• Classed in JAR elements are automatically added to the classpath
47
Compiled .class and .jar in jvm/lib/ext folder
• .class and .jar files located in this folder are available to all applications running locally and on the server
– GOTCHA: Java source files (.java) files in this folder will not compile and execute
• Java Code located in this folder is automatically added to the classpath
48
Calling Methods from SSJS
• Java code is instantiated and called from a SSJS event – Import the Java package (unless the default package was
used)(which is a VERY bad idea) – Instantiate an instance of a class from the imported package – Call a method from the instantiated class – “Do something” with the results or return a status message
49
Demo: Calling Java code from SSJS
50
Agenda
51
• The Java Language Fundamentals • Domino Designer Settings • Java Beans and Managed Beans • Calling Java Code from an XPage • Using the Expression Language • Accessing Domino Objects • Using Third Party Libraries • Wrap Up
Expression Language
52
• begins with a # or $ character and is enclosed in curly brackets $sessionScope.myVar - evaluated once on page load #sessionScope.myVar - evaluated on page load, restore, renderResponse
• must be written on a single line • evaluated from left to right … inner statements within the expression can
be delimited using parenthesis for precedence • can concatenate several EL expressions to return a single string value …
$config.app.path$config.app.custApp
• You can NOT nest an EL expression within another EL expression • An EL expression can return an object or value of any type
A scripting syntax in tag languages (JSP, JSF, XSP) to invoke the properties and methods of back end Java
classes (specifically Java Beans).
Bracket and Dot Notation
53
• Bracket notation: #viewScope[“viewName”] $header[“User-Agent”]
• Dot notation: #viewScope.viewName
$header.User-Agent
• Can combine and chain expressions: $facesContext["externalContext"]["requestServletPath"] $facesContext.externalContext["requestServletPath"] $facesContext.externalContext.requestServletPath $facesContext["externalContext"].requestServletPath
EL Operators
54
Use EL to … Bind Controls to Fields in a Data Source
55
Use EL to … Get and Set Scoped Variables
56
Use EL to … Get and Set Properties in JavaBeans
57
Use EL to … Get and Set Properties in Managed Beans
58
Demo: Domino Objects
59
Agenda
60
• The Java Language Fundamentals • Domino Designer Settings • Java Beans and Managed Beans • Calling Java Code from an XPage • Using the Expression Language • Accessing Domino Objects • Using Third Party Libraries • Wrap Up
Session
61
• The Notes Session object is the top level object in the Domino class hierarchy
• The starting point for calling all other classes (database, view, etc) in the hierarchy
• Two ways to get the session object in Java code executed from an XPage
– Pass it in as a parameter from the SSJS – Get it from the JSF “context”, the underlying
architecture
Session
62
• Pass the global “session” variable in as a parameter – The SSJS Code
– The Java Code
importPackage(com.nnsu.domino); var jce:DomSession1 = new DomSession1(); var retOutput = jce.getOutput(session); getComponent("computedField1").setValue(retOutput);
import lotus.domino.Session; public class DomSession1 private StringBuffer output = new StringBuffer(); // global session object passed as parameter in the method call public String getOutput(Session session) try output.append("The Notes version is: " + session.getNotesVersion() + nl);
Session
• Get it from the JSF “context”, the underlying architecture
import javax.faces.context.FacesContext; import lotus.domino.Session; public class DomSession2 private StringBuffer output = new StringBuffer(); private String nl = "<br />"; // global session object passed as parameter in the method call public String getOutput() FacesContext context = FacesContext.getCurrentInstance(); Session session = (Session) context.getApplication().getVariableResolver().resolveVariable(context, "session"); …
63
Session
• Once there is a “session” object, the rest of the Domino class hierarchy can be traversed
– Database – View – ViewNavigator – Document – Item – DocumentCollection – Etc…
64
Demo: Domino Objects
65
Agenda
66
• The Java Language Fundamentals • Domino Designer Settings • Java Beans and Managed Beans • Calling Java Code from an XPage • Using the Expression Language • Accessing Domino Objects • Using Third Party Libraries • Wrap Up
Development Setup
67
• There are two choices when configuring an application to use third party Java libraries
– Put all the JARS in the NSF – Put the JARS on the Host File System
Put all the JARS in the NSF
68
• Pros – Makes the application more portable. – Can be “deployed” to the test server and production by
replication • Cons
– JARS are only accessible by code in the containing NSF – If many NSF’s use this solution then maintenance can
become difficult • Going from version “x” to version “y” has to be done in every
application
Put the JARS on Host File System
69
• Pros – Easier to maintain code/upgrade code for all
applications that use it • Cons
– Harder to deploy (insert snarky Evil Admin comment here)
Development Setup
70
• I prefer to deploy the JARS to the Host File system – (Insert self referencing Evil Admin Comment here) – If the code that CALLS the classes from the JARS is:
• A Java Agent, Servlet, Java Class or Java Code Element (available in 8.5.3 and above)
- Deploy the JARS to the <installDir>/jvm/lib/ext folder • SSJS Code from an XPage
- Deploy the JARS to the <installDir>/xsp folder
– JARS will have to be deployed to the Notes Designer Client AND the development/production servers !!
– If the Client or Server is running restart in order for your code to recognize that they are there
• This is the step you will forget. Just sayin’
Development Setup
71
• The JARS can also be added to the NSF container when developing XPages.
– This is the option I’m using so you have a self contained demonstration/example system you can play with locally or on a TEST Server.
Development Setup
72
• In 8.5.3 and below – In the Application that will contain the XPage Code
• From the XPages perspective switch to the Package Explorer View • Expand the WebContent/WEB-INF folder
- Create a folder named “lib” • Import (you can also drag and drop)
the JARS to the lib folder
Development Setup
73
• In 9.0 – Import the Jars to the new “JAR” design element – This will automatically add it to the class/build path
• No other configuration is required
Third Party Libraries
• Third party libraries can come from a variety of sources – Open Source – Purchased from vendors
• A “solution” to a particular coding problem not available in the host system API
– “I need to parse a String object at every capitalized letter” – “I need to export all my data to a spreadsheet” – “I need to create a PDF from this data”
• One of the “Go To” solutions for tested, reliable Java
Libraries is the Apache Software Foundation
74
What is APACHE ?
75
• The Apache Software Foundation (www.apache.org)
– Open Source (Yes that means FREE) consortium of companies and developers
– Donates time and resources to developing tools (primarily Java based) that simplify many tasks that developers are faced with everyday
– Like OpenNTF, but for Java developers
What is APACHE ?
76
• IBM is a major contributor/supporter • If you develop using Java code (and you should be)
review the projects on this site • Some I use all the time:
– Xerces – Xalan – XML Graphics (FOP) – POI – Commons
Apache Commons
77
• http://commons.apache.org • Focused on all aspects of reusable Java components
Commons Proper
78
• Commons Proper – Goal of creating and maintaining reusable java
Components
• Individual downloadable components – Not one GIANT utility library – Just get what you need
Commons Proper
79
• Each of the following components can be downloaded individually Component
Attributes Runtime API to metadata attributes such as doclet tags. BCEL Byte Code Engineering Library - analyze, create, and manipulate Java class
files BeanUtils Easy-to-use wrappers around the Java reflection and introspection APIs. Betwixt Services for mapping JavaBeans to XML documents, and vice versa. BSF Bean Scripting Framework - interface to scripting languages, including
JSR-223 Chain Chain of Responsibility pattern implemention. CLI Command Line arguments parser. Codec General encoding/decoding algorithms (for example phonetic, base64,
URL). Collections Extends or augments the Java Collections Framework. Compress Defines an API for working with tar, zip and bzip2 files. Configuration Reading of configuration/preferences files in various formats. CSV Component for reading and writing comma separated value files. Daemon Alternative invocation mechanism for unix-daemon-like java code. DBCP Database connection pooling services. DbUtils JDBC helper library. Digester XML-to-Java-object mapping utility.
Commons Proper
80
Component Discovery Tools for locating resources by mapping service/reference names to resource names.
EL Interpreter for the Expression Language defined by the JSP 2.0 specification.
Email Library for sending e-mail from Java.
Exec API for dealing with external process execution and environment management in Java.
FileUpload File upload capability for your servlets and web applications.
Functor A functor is a function that can be manipulated as an object, or an object representing a single, generic function.
Imaging (previously called Sanselan)
A pure-Java image library.
IO Collection of I/O utilities.
JCI Java Compiler Interface JCS Java Caching System Jelly XML based scripting and processing engine.
Jexl Expression language which extends the Expression Language of the JSTL.
JXPath Utilities for manipulating Java Beans using the XPath syntax.
Lang Provides extra functionality for classes in java.lang.
Commons Proper
81
Component Launcher Cross platform Java application launcher.
Logging Wrapper around a variety of logging API implementations.
Math Lightweight, self-contained mathematics and statistics components.
Modeler Mechanisms to create Model MBeans compatible with JMX specification.
Net Collection of network utilities and protocol implementations.
OGNL An Object-Graph Navigation Language
Pool Generic object pooling component.
Primitives Smaller, faster and easier to work with types supporting Java primitive types. Proxy Library for creating dynamic proxies. SCXML An implementation of the State Chart XML specification aimed at creating and maintaining a Java
SCXML engine. It is capable of executing a state machine defined using a SCXML document, and abstracts out the environment interfaces.
Transaction Implementations for multi level locks, transactional collections and transactional file access.
Validator Framework to define validators and validation rules in an xml file. VFS Virtual File System component for treating files, FTP, SMB, ZIP and such like as a single logical file
system.
Commons Lang
82
• Provides a host of helper utilities for the java.lang API
– String manipulation methods – Basic numerical methods – Object reflection – Additionally it contains basic enhancements to
java.util.Date
Commons Lang - Versions
83
• Latest Version is 3.3.1 – For Java 1.5 and higher – For Notes/Domino 8.x and 9.x
• Version 2.6 is still available – For Java 1.2 and higher – For Notes Domino 7.x and below
http://commons.apache.org/proper/commons-lang/download_lang.cgi
Commons Lang API
84
Packages
org.apache.commons.lang3 Provides highly reusable static utility methods, chiefly concerned with adding value to the java.lang classes.
org.apache.commons.lang3.builder Assists in creating consistent equals(Object), toString(), hashCode(), and compareTo(Object) methods.
org.apache.commons.lang3.concurrent Provides support classes for multi-threaded programming.
org.apache.commons.lang3.event Provides some useful event-based utilities.
org.apache.commons.lang3.exception Provides functionality for Exceptions.
org.apache.commons.lang3.math Extends java.math for business mathematical classes.
org.apache.commons.lang3.mutable Provides typed mutable wrappers to primitive values and Object.
org.apache.commons.lang3.reflect Accumulates common high-level uses of the java.lang.reflect APIs.
org.apache.commons.lang3.text Provides classes for handling and manipulating text, partly as an extension to java.text.
org.apache.commons.lang3.text.translate An API for creating text translation routines from a set of smaller building blocks.
org.apache.commons.lang3.time Provides classes and methods to work with dates and durations.
org.apache.commons.lang3.tuple Tuple classes, starting with a Pair class in version 3.0.
org.apache.commons.lang3.StringUtils
85
• IsEmpty/IsBlank - checks if a String contains text • Trim/Strip - removes leading and trailing whitespace • Equals - compares two strings null-safe • startsWith - check if a String starts with a prefix null-safe • endsWith - check if a String ends with a suffix null-safe • IndexOf/LastIndexOf/Contains - null-safe index-of checks • IndexOfAny/LastIndexOfAny/IndexOfAnyBut/LastIndexOfAnyBut
- index-of any of a set of Strings
org.apache.commons.lang3.StringUtils
86
• ContainsOnly/ContainsNone/ContainsAny - does String contains only/none/any of these characters
• Substring/Left/Right/Mid - null-safe substring extractions • SubstringBefore/SubstringAfter/SubstringBetween - substring
extraction relative to other strings • Split/Join - splits a String into an array of substrings and vice
versa • Remove/Delete - removes part of a String • Replace/Overlay - Searches a String and replaces one String with
another
org.apache.commons.lang3.StringUtils
87
• Chomp/Chop - removes the last part of a String • LeftPad/RightPad/Center/Repeat - pads a String • UpperCase/LowerCase/SwapCase/Capitalize/Uncapitalize -
changes the case of a String • CountMatches - counts the number of occurrences of one String
in another
org.apache.commons.lang3.StringUtils
88
• IsAlpha/IsNumeric/IsWhitespace/IsAsciiPrintable - checks the characters in a String
• DefaultString - protects against a null input String • Reverse/ReverseDelimited - reverses a String • Abbreviate - abbreviates a string using ellipsis • Difference - compares Strings and reports on their differences • LevenshteinDistance - the number of changes needed to
change one String into another
Demo: Commons StringUtils
89
Resources
90
• IBM XPages Forum – Moderated by the community – http://www-10.lotus.com/ldd/xpagesforum.nsf/
• TLCC – Self paced Courses on XPages and Java – http://www.tlcc.com
NetNotes Solutions Unlimited - My Web Site http://www.nnsu.com
• Apache Software Foundation – http://www.apache.org
• OpenNTF – http://www.openntf.org
• XPages Tips – http://xpagetips.blogspot.com
Questions????
91
Use the Q&A pane in WebEx to ask questions We will answer your questions verbally
Download the demo - http://www.tlcc.com/java-webinar Upcoming Events:
TLCC Connect Sale
IBM Connect 2014 Registration is still open
Be sure to attend our sessions!
Visit Teamstudio in booth 114
Question and Answer Time!
92
Teamstudio Questions? [email protected] 877-228-6178
TLCC Questions?
[email protected] [email protected] 888-241-8522 or 561-953-0095
Howard Greenberg Courtney Carter
#XPages
@ptcalhoun
@TLCCLtd
@Teamstudio
@PaulDN
Paul Della-Nebbia Paul Calhoun