@Override /* HttpServletRequest */ public String getPathInfo() { if (pathInfo == null) { pathInfo = getRequestURI(); if (isNotEmpty(contextPath)) pathInfo = pathInfo.substring(contextPath.length()); if (isNotEmpty(servletPath)) pathInfo = pathInfo.substring(servletPath.length()); } return nullIfEmpty(urlDecode(pathInfo)); }
@Override /* HttpServletRequest */ public String getPathInfo() { if (pathInfo == null) { pathInfo = getRequestURI(); if (isNotEmpty(contextPath)) pathInfo = pathInfo.substring(contextPath.length()); if (isNotEmpty(servletPath)) pathInfo = pathInfo.substring(servletPath.length()); } return nullIfEmpty(urlDecode(pathInfo)); }
/** * Constructor. * * <p> * Leading and trailing slashes are trimmed of all parameters. * * <p> * Any parameter can be <jk>null</jk>. Blanks and nulls are equivalent. * * @param authority * The authority portion of URL (e.g. <js>"http://hostname:port"</js>) * @param contextRoot * The context root of the application (e.g. <js>"/context-root"</js>, or <js>"context-root"</js>) * @param servletPath * The servlet path (e.g. <js>"/servlet-path"</js>, or <js>"servlet-path"</js>) * @param pathInfo * The path info (e.g. <js>"/path-info"</js>, or <js>"path-info"</js>) */ @BeanConstructor(properties="authority,contextRoot,servletPath,pathInfo") public UriContext(String authority, String contextRoot, String servletPath, String pathInfo) { this.authority = nullIfEmpty(trimSlashes(authority)); this.contextRoot = nullIfEmpty(trimSlashes(contextRoot)); this.servletPath = nullIfEmpty(trimSlashes(servletPath)); this.pathInfo = nullIfEmpty(trimSlashes(pathInfo)); this.parentPath = this.pathInfo == null || this.pathInfo.indexOf('/') == -1 ? null : this.pathInfo.substring(0, this.pathInfo.lastIndexOf('/')); }
/** * Constructor. * * <p> * Leading and trailing slashes are trimmed of all parameters. * * <p> * Any parameter can be <jk>null</jk>. Blanks and nulls are equivalent. * * @param authority * The authority portion of URL (e.g. <js>"http://hostname:port"</js>) * @param contextRoot * The context root of the application (e.g. <js>"/context-root"</js>, or <js>"context-root"</js>) * @param servletPath * The servlet path (e.g. <js>"/servlet-path"</js>, or <js>"servlet-path"</js>) * @param pathInfo * The path info (e.g. <js>"/path-info"</js>, or <js>"path-info"</js>) */ @BeanConstructor(properties="authority,contextRoot,servletPath,pathInfo") public UriContext(String authority, String contextRoot, String servletPath, String pathInfo) { this.authority = nullIfEmpty(trimSlashes(authority)); this.contextRoot = nullIfEmpty(trimSlashes(contextRoot)); this.servletPath = nullIfEmpty(trimSlashes(servletPath)); this.pathInfo = nullIfEmpty(trimSlashes(pathInfo)); this.parentPath = this.pathInfo == null || this.pathInfo.indexOf('/') == -1 ? null : this.pathInfo.substring(0, this.pathInfo.lastIndexOf('/')); }
@Override /* HttpServletRequest */ public String getPathInfo() { if (pathInfo == null) { pathInfo = getRequestURI(); if (isNotEmpty(contextPath)) pathInfo = pathInfo.substring(contextPath.length()); if (isNotEmpty(servletPath)) pathInfo = pathInfo.substring(servletPath.length()); } return nullIfEmpty(urlDecode(pathInfo)); }
/** * Constructor. * * <p> * Leading and trailing slashes are trimmed of all parameters. * * <p> * Any parameter can be <jk>null</jk>. Blanks and nulls are equivalent. * * @param authority * The authority portion of URL (e.g. <js>"http://hostname:port"</js>) * @param contextRoot * The context root of the application (e.g. <js>"/context-root"</js>, or <js>"context-root"</js>) * @param servletPath * The servlet path (e.g. <js>"/servlet-path"</js>, or <js>"servlet-path"</js>) * @param pathInfo * The path info (e.g. <js>"/path-info"</js>, or <js>"path-info"</js>) */ @BeanConstructor(properties="authority,contextRoot,servletPath,pathInfo") public UriContext(String authority, String contextRoot, String servletPath, String pathInfo) { this.authority = nullIfEmpty(trimSlashes(authority)); this.contextRoot = nullIfEmpty(trimSlashes(contextRoot)); this.servletPath = nullIfEmpty(trimSlashes(servletPath)); this.pathInfo = nullIfEmpty(trimSlashes(pathInfo)); this.parentPath = this.pathInfo == null || this.pathInfo.indexOf('/') == -1 ? null : this.pathInfo.substring(0, this.pathInfo.lastIndexOf('/')); }
/** * String constructor. * * <p> * Input string is a JSON object with the following format: * <js>{authority:'xxx',contextRoot:'xxx',servletPath:'xxx',pathInfo:'xxx'}</js> * * @param s * The input string. * <br>Example: <js>{authority:'http://localhost:10000',contextRoot:'/myContext',servletPath:'/myServlet',pathInfo:'/foo'}</js> * @throws ParseException * If input string is not a valid JSON object. */ public UriContext(String s) throws ParseException { ObjectMap m = new ObjectMap(s); this.authority = nullIfEmpty(trimSlashes(m.getString("authority"))); this.contextRoot = nullIfEmpty(trimSlashes(m.getString("contextRoot"))); this.servletPath = nullIfEmpty(trimSlashes(m.getString("servletPath"))); this.pathInfo = nullIfEmpty(trimSlashes(m.getString("pathInfo"))); this.parentPath = this.pathInfo == null || this.pathInfo.indexOf('/') == -1 ? null : this.pathInfo.substring(0, this.pathInfo.lastIndexOf('/')); }
/** * String constructor. * * <p> * Input string is a JSON object with the following format: * <js>{authority:'xxx',contextRoot:'xxx',servletPath:'xxx',pathInfo:'xxx'}</js> * * @param s * The input string. * <br>Example: <js>{authority:'http://localhost:10000',contextRoot:'/myContext',servletPath:'/myServlet',pathInfo:'/foo'}</js> * @throws ParseException * If input string is not a valid JSON object. */ public UriContext(String s) throws ParseException { ObjectMap m = new ObjectMap(s); this.authority = nullIfEmpty(trimSlashes(m.getString("authority"))); this.contextRoot = nullIfEmpty(trimSlashes(m.getString("contextRoot"))); this.servletPath = nullIfEmpty(trimSlashes(m.getString("servletPath"))); this.pathInfo = nullIfEmpty(trimSlashes(m.getString("pathInfo"))); this.parentPath = this.pathInfo == null || this.pathInfo.indexOf('/') == -1 ? null : this.pathInfo.substring(0, this.pathInfo.lastIndexOf('/')); }
/** * String constructor. * * <p> * Input string is a JSON object with the following format: * <js>{authority:'xxx',contextRoot:'xxx',servletPath:'xxx',pathInfo:'xxx'}</js> * * @param s * The input string. * <br>Example: <js>{authority:'http://localhost:10000',contextRoot:'/myContext',servletPath:'/myServlet',pathInfo:'/foo'}</js> * @throws ParseException * If input string is not a valid JSON object. */ public UriContext(String s) throws ParseException { ObjectMap m = new ObjectMap(s); this.authority = nullIfEmpty(trimSlashes(m.getString("authority"))); this.contextRoot = nullIfEmpty(trimSlashes(m.getString("contextRoot"))); this.servletPath = nullIfEmpty(trimSlashes(m.getString("servletPath"))); this.pathInfo = nullIfEmpty(trimSlashes(m.getString("pathInfo"))); this.parentPath = this.pathInfo == null || this.pathInfo.indexOf('/') == -1 ? null : this.pathInfo.substring(0, this.pathInfo.lastIndexOf('/')); }
/** * Constructor. * * @param cm The class that this annotation is defined on. */ public JsonClassMeta(ClassMeta<?> cm) { super(cm); this.json = ClassUtils.getAnnotation(Json.class, getInnerClass()); if (json != null) { wrapperAttr = nullIfEmpty(json.wrapperAttr()); } else { wrapperAttr = null; } }
/** * Constructor. * * @param cm The class that this annotation is defined on. */ public JsonClassMeta(ClassMeta<?> cm) { super(cm); this.json = ClassUtils.getAnnotation(Json.class, getInnerClass()); if (json != null) { wrapperAttr = nullIfEmpty(json.wrapperAttr()); } else { wrapperAttr = null; } }
/** * Constructor. * * @param cm The class that this annotation is defined on. */ public JsonClassMeta(ClassMeta<?> cm) { super(cm); this.json = ClassUtils.getAnnotation(Json.class, getInnerClass()); if (json != null) { wrapperAttr = nullIfEmpty(json.wrapperAttr()); } else { wrapperAttr = null; } }
@Test public void testNullIfEmpty() throws Exception { assertNull(nullIfEmpty(null)); assertNull(nullIfEmpty("")); assertNotNull(nullIfEmpty("x")); }
String pre = nullIfEmpty(getBeforeShowScript(req)), post = nullIfEmpty(getAfterShowScript(req));
String pre = nullIfEmpty(getBeforeShowScript(req)), post = nullIfEmpty(getAfterShowScript(req));
String pre = nullIfEmpty(getBeforeShowScript(req)), post = nullIfEmpty(getAfterShowScript(req));
/** * Constructor. * * @param cm The class that this annotation is defined on. */ public XmlClassMeta(ClassMeta<?> cm) { super(cm); Class<?> c = getInnerClass(); this.namespace = findNamespace(c); this.xml = ClassUtils.getAnnotation(Xml.class, c); if (xml != null) { this.format = xml.format(); this.childName = nullIfEmpty(xml.childName()); } else { this.format = XmlFormat.DEFAULT; this.childName = null; } }
/** * Constructor. * * @param cm The class that this annotation is defined on. */ public XmlClassMeta(ClassMeta<?> cm) { super(cm); Class<?> c = getInnerClass(); this.namespace = findNamespace(c); this.xml = ClassUtils.getAnnotation(Xml.class, c); if (xml != null) { this.format = xml.format(); this.childName = nullIfEmpty(xml.childName()); } else { this.format = XmlFormat.DEFAULT; this.childName = null; } }
/** * Constructor. * * @param cm The class that this annotation is defined on. */ public XmlClassMeta(ClassMeta<?> cm) { super(cm); Class<?> c = getInnerClass(); this.namespace = findNamespace(c); this.xml = ClassUtils.getAnnotation(Xml.class, c); if (xml != null) { this.format = xml.format(); this.childName = nullIfEmpty(xml.childName()); } else { this.format = XmlFormat.DEFAULT; this.childName = null; } }
this.debug = getBooleanProperty(RESTCLIENT_debug, false); this.executorServiceShutdownOnClose = getBooleanProperty(RESTCLIENT_executorServiceShutdownOnClose, false); this.rootUrl = StringUtils.nullIfEmpty(getStringProperty(RESTCLIENT_rootUri, "").replaceAll("\\/$", ""));