You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juneau.apache.org by ja...@apache.org on 2017/06/10 20:19:54 UTC
[2/4] incubator-juneau git commit: Add branding capability to
HtmlDocSerializer and REST servlet.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/6dccf603/juneau-core/src/main/java/org/apache/juneau/BeanPropertyMeta.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/BeanPropertyMeta.java b/juneau-core/src/main/java/org/apache/juneau/BeanPropertyMeta.java
index c8af40e..fd0f8b9 100644
--- a/juneau-core/src/main/java/org/apache/juneau/BeanPropertyMeta.java
+++ b/juneau-core/src/main/java/org/apache/juneau/BeanPropertyMeta.java
@@ -521,7 +521,7 @@ public class BeanPropertyMeta {
Map valueMap = (Map)value;
Map propMap = (Map)r;
- ClassMeta<?> valueType = rawTypeMeta.getValueType();
+ ClassMeta<?> valueType = rawTypeMeta.getValueType();
// If the property type is abstract, then we either need to reuse the existing
// map (if it's not null), or try to assign the value directly.
@@ -546,7 +546,6 @@ public class BeanPropertyMeta {
} else {
if (propMap == null) {
propMap = newInstance(Map.class, propertyClass);
- invokeSetter(bean, pName, propMap);
} else {
propMap.clear();
}
@@ -560,6 +559,8 @@ public class BeanPropertyMeta {
v = session.convertToType(v, valueType);
propMap.put(k, v);
}
+ if (setter != null || field != null)
+ invokeSetter(bean, pName, propMap);
} else if (isCollection) {
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/6dccf603/juneau-core/src/main/java/org/apache/juneau/dto/atom/AtomBuilder.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/atom/AtomBuilder.java b/juneau-core/src/main/java/org/apache/juneau/dto/atom/AtomBuilder.java
index d1bccc3..512f64b 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/atom/AtomBuilder.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/atom/AtomBuilder.java
@@ -15,6 +15,8 @@ package org.apache.juneau.dto.atom;
import java.net.*;
import java.util.*;
+import org.apache.juneau.*;
+
/**
* Various useful static methods for creating ATOM elements.
* <p>
@@ -130,22 +132,17 @@ public class AtomBuilder {
}
/**
- * Creates an {@link Icon} element with the specified {@link Icon#uri(URI)} attribute.
- *
- * @param uri The {@link Icon#uri(URI)} attribute.
- * @return The new element.
- */
- public static final Icon icon(String uri) {
- return new Icon(uri);
- }
-
- /**
- * Creates an {@link Icon} element with the specified {@link Icon#uri(URI)} attribute.
+ * Creates an {@link Icon} element with the specified {@link Icon#uri(Object)} attribute.
+ * <p>
+ * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}.
+ * Strings must be valid URIs.
+ * <p>
+ * URIs defined by {@link UriResolver} can be used for values.
*
- * @param uri The {@link Icon#uri(URI)} attribute.
+ * @param uri The {@link Icon#uri(Object)} attribute.
* @return The new element.
*/
- public static final Icon icon(URI uri) {
+ public static final Icon icon(Object uri) {
return new Icon(uri);
}
@@ -172,22 +169,17 @@ public class AtomBuilder {
}
/**
- * Creates a {@link Logo} element with the specified {@link Logo#uri(URI)} attribute.
- *
- * @param uri The {@link Logo#uri(URI)} attribute.
- * @return The new element.
- */
- public static final Logo logo(String uri) {
- return new Logo(uri);
- }
-
- /**
- * Creates a {@link Logo} element with the specified {@link Logo#uri(URI)} attribute.
+ * Creates a {@link Logo} element with the specified {@link Logo#uri(Object)} attribute.
+ * <p>
+ * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}.
+ * Strings must be valid URIs.
+ * <p>
+ * URIs defined by {@link UriResolver} can be used for values.
*
- * @param uri The {@link Logo#uri(URI)} attribute.
+ * @param uri The {@link Logo#uri(Object)} attribute.
* @return The new element.
*/
- public static final Logo logo(URI uri) {
+ public static final Logo logo(Object uri) {
return new Logo(uri);
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/6dccf603/juneau-core/src/main/java/org/apache/juneau/dto/atom/Category.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/atom/Category.java b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Category.java
index 58a77f2..4fd9b3c 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/atom/Category.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Category.java
@@ -12,10 +12,13 @@
// ***************************************************************************************************************************
package org.apache.juneau.dto.atom;
+import static org.apache.juneau.internal.StringUtils.*;
import static org.apache.juneau.xml.annotation.XmlFormat.*;
+import java.net.*;
import java.net.URI;
+import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
import org.apache.juneau.xml.annotation.*;
@@ -99,13 +102,18 @@ public class Category extends Common {
/**
* Sets the category scheme.
+ * <p>
+ * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}.
+ * Strings must be valid URIs.
+ * <p>
+ * URIs defined by {@link UriResolver} can be used for values.
*
* @param scheme The category scheme.
* @return This object (for method chaining).
*/
@BeanProperty("scheme")
- public Category scheme(URI scheme) {
- this.scheme = scheme;
+ public Category scheme(Object scheme) {
+ this.scheme = toURI(scheme);
return this;
}
@@ -137,7 +145,7 @@ public class Category extends Common {
//--------------------------------------------------------------------------------
@Override /* Common */
- public Category base(URI base) {
+ public Category base(Object base) {
super.base(base);
return this;
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/6dccf603/juneau-core/src/main/java/org/apache/juneau/dto/atom/Common.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/atom/Common.java b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Common.java
index b9eea2b..08b510b 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/atom/Common.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Common.java
@@ -12,11 +12,13 @@
// ***************************************************************************************************************************
package org.apache.juneau.dto.atom;
-import static org.apache.juneau.dto.atom.Utils.*;
+import static org.apache.juneau.internal.StringUtils.*;
import static org.apache.juneau.xml.annotation.XmlFormat.*;
+import java.net.*;
import java.net.URI;
+import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
import org.apache.juneau.xml.annotation.*;
@@ -63,23 +65,17 @@ public abstract class Common {
/**
* Sets the URI base of this object.
+ * <p>
+ * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}.
+ * Strings must be valid URIs.
+ * <p>
+ * URIs defined by {@link UriResolver} can be used for values.
*
* @param base The URI base of this object.
* @return This object (for method chaining).
*/
@BeanProperty("base")
- public Common base(URI base) {
- this.base = base;
- return this;
- }
-
- /**
- * Sets the URI base of this object.
- *
- * @param base The URI base of this object.
- * @return This object (for method chaining).
- */
- public Common base(String base) {
+ public Common base(Object base) {
this.base = toURI(base);
return this;
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/6dccf603/juneau-core/src/main/java/org/apache/juneau/dto/atom/Content.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/atom/Content.java b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Content.java
index 4801b03..c8cd0f2 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/atom/Content.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Content.java
@@ -12,10 +12,13 @@
// ***************************************************************************************************************************
package org.apache.juneau.dto.atom;
+import static org.apache.juneau.internal.StringUtils.*;
import static org.apache.juneau.xml.annotation.XmlFormat.*;
+import java.net.*;
import java.net.URI;
+import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
import org.apache.juneau.xml.annotation.*;
@@ -108,13 +111,18 @@ public class Content extends Text {
/**
* Sets the source URI.
+ * <p>
+ * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}.
+ * Strings must be valid URIs.
+ * <p>
+ * URIs defined by {@link UriResolver} can be used for values.
*
* @param src The source URI.
* @return This object (for method chaining).
*/
@BeanProperty("src")
- public Content src(URI src) {
- this.src = src;
+ public Content src(Object src) {
+ this.src = toURI(src);
return this;
}
@@ -136,17 +144,10 @@ public class Content extends Text {
}
@Override /* Common */
- public Content base(URI base) {
+ public Content base(Object base) {
super.base(base);
return this;
}
-
- @Override /* Common */
- public Content base(String base) {
- super.base(base);
- return this;
- }
-
@Override /* Common */
public Content lang(String lang) {
super.lang(lang);
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/6dccf603/juneau-core/src/main/java/org/apache/juneau/dto/atom/Entry.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/atom/Entry.java b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Entry.java
index 211fa99..251a3d6 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/atom/Entry.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Entry.java
@@ -14,7 +14,6 @@ package org.apache.juneau.dto.atom;
import static org.apache.juneau.dto.atom.Utils.*;
-import java.net.URI;
import java.util.*;
import org.apache.juneau.annotation.*;
@@ -273,7 +272,7 @@ public class Entry extends CommonEntry {
}
@Override /* Common */
- public Entry base(URI base) {
+ public Entry base(Object base) {
super.base(base);
return this;
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/6dccf603/juneau-core/src/main/java/org/apache/juneau/dto/atom/Feed.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/atom/Feed.java b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Feed.java
index 9c8614e..0adc465 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/atom/Feed.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Feed.java
@@ -14,7 +14,6 @@ package org.apache.juneau.dto.atom;
import static org.apache.juneau.xml.annotation.XmlFormat.*;
-import java.net.URI;
import java.util.*;
import org.apache.juneau.annotation.*;
@@ -286,7 +285,7 @@ public class Feed extends CommonEntry {
}
@Override /* Common */
- public Feed base(URI base) {
+ public Feed base(Object base) {
super.base(base);
return this;
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/6dccf603/juneau-core/src/main/java/org/apache/juneau/dto/atom/Generator.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/atom/Generator.java b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Generator.java
index be879f3..0d16ff6 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/atom/Generator.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Generator.java
@@ -12,11 +12,13 @@
// ***************************************************************************************************************************
package org.apache.juneau.dto.atom;
-import static org.apache.juneau.dto.atom.Utils.*;
+import static org.apache.juneau.internal.StringUtils.*;
import static org.apache.juneau.xml.annotation.XmlFormat.*;
+import java.net.*;
import java.net.URI;
+import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
import org.apache.juneau.xml.annotation.*;
@@ -80,24 +82,17 @@ public class Generator extends Common {
/**
* Sets the URI of this generator statement.
+ * <p>
+ * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}.
+ * Strings must be valid URIs.
+ * <p>
+ * URIs defined by {@link UriResolver} can be used for values.
*
* @param uri The URI of this generator statement.
* @return This object (for method chaining).
*/
@BeanProperty("uri")
- public Generator uri(URI uri) {
- this.uri = uri;
- return this;
- }
-
- /**
- * Sets the URI of this generator statement.
- *
- * @param uri The URI of this generator statement.
- * @return This object (for method chaining).
- */
- @BeanProperty("uri")
- public Generator uri(String uri) {
+ public Generator uri(Object uri) {
this.uri = toURI(uri);
return this;
}
@@ -152,7 +147,7 @@ public class Generator extends Common {
//--------------------------------------------------------------------------------
@Override /* Common */
- public Generator base(URI base) {
+ public Generator base(Object base) {
super.base(base);
return this;
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/6dccf603/juneau-core/src/main/java/org/apache/juneau/dto/atom/Icon.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/atom/Icon.java b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Icon.java
index a537163..37f0f03 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/atom/Icon.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Icon.java
@@ -12,11 +12,13 @@
// ***************************************************************************************************************************
package org.apache.juneau.dto.atom;
-import static org.apache.juneau.dto.atom.Utils.*;
+import static org.apache.juneau.internal.StringUtils.*;
import static org.apache.juneau.xml.annotation.XmlFormat.*;
+import java.net.*;
import java.net.URI;
+import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
import org.apache.juneau.xml.annotation.*;
@@ -49,19 +51,15 @@ public class Icon extends Common {
/**
* Normal constructor.
+ * <p>
+ * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}.
+ * Strings must be valid URIs.
+ * <p>
+ * URIs defined by {@link UriResolver} can be used for values.
*
* @param uri The URI of the icon.
*/
- public Icon(URI uri) {
- uri(uri);
- }
-
- /**
- * Normal constructor.
- *
- * @param uri The URI of the icon.
- */
- public Icon(String uri) {
+ public Icon(Object uri) {
uri(uri);
}
@@ -85,24 +83,17 @@ public class Icon extends Common {
/**
* Sets the URI of this icon.
+ * <p>
+ * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}.
+ * Strings must be valid URIs.
+ * <p>
+ * URIs defined by {@link UriResolver} can be used for values.
*
* @param uri The URI of this icon.
* @return This object (for method chaining).
*/
@BeanProperty("uri")
- public Icon uri(URI uri) {
- this.uri = uri;
- return this;
- }
-
- /**
- * Sets the URI of this icon.
- *
- * @param uri The URI of this icon.
- * @return This object (for method chaining).
- */
- @BeanProperty("uri")
- public Icon uri(String uri) {
+ public Icon uri(Object uri) {
this.uri = toURI(uri);
return this;
}
@@ -113,7 +104,7 @@ public class Icon extends Common {
//--------------------------------------------------------------------------------
@Override /* Common */
- public Icon base(URI base) {
+ public Icon base(Object base) {
super.base(base);
return this;
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/6dccf603/juneau-core/src/main/java/org/apache/juneau/dto/atom/Id.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/atom/Id.java b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Id.java
index 5cf4f30..ca64b85 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/atom/Id.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Id.java
@@ -14,8 +14,6 @@ package org.apache.juneau.dto.atom;
import static org.apache.juneau.xml.annotation.XmlFormat.*;
-import java.net.URI;
-
import org.apache.juneau.annotation.*;
import org.apache.juneau.xml.annotation.*;
@@ -90,7 +88,7 @@ public class Id extends Common {
//--------------------------------------------------------------------------------
@Override /* Common */
- public Id base(URI base) {
+ public Id base(Object base) {
super.base(base);
return this;
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/6dccf603/juneau-core/src/main/java/org/apache/juneau/dto/atom/Link.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/atom/Link.java b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Link.java
index df93a9c..6d80912 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/atom/Link.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Link.java
@@ -14,8 +14,6 @@ package org.apache.juneau.dto.atom;
import static org.apache.juneau.xml.annotation.XmlFormat.*;
-import java.net.URI;
-
import org.apache.juneau.annotation.*;
import org.apache.juneau.xml.annotation.*;
@@ -223,7 +221,7 @@ public class Link extends Common {
//--------------------------------------------------------------------------------
@Override /* Common */
- public Link base(URI base) {
+ public Link base(Object base) {
super.base(base);
return this;
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/6dccf603/juneau-core/src/main/java/org/apache/juneau/dto/atom/Logo.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/atom/Logo.java b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Logo.java
index fe61a62..8f648cc 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/atom/Logo.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Logo.java
@@ -12,11 +12,13 @@
// ***************************************************************************************************************************
package org.apache.juneau.dto.atom;
-import static org.apache.juneau.dto.atom.Utils.*;
+import static org.apache.juneau.internal.StringUtils.*;
import static org.apache.juneau.xml.annotation.XmlFormat.*;
+import java.net.*;
import java.net.URI;
+import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
import org.apache.juneau.xml.annotation.*;
@@ -49,19 +51,15 @@ public class Logo extends Common {
/**
* Normal constructor.
+ * <p>
+ * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}.
+ * Strings must be valid URIs.
+ * <p>
+ * URIs defined by {@link UriResolver} can be used for values.
*
* @param uri The URI of the logo.
*/
- public Logo(URI uri) {
- uri(uri);
- }
-
- /**
- * Normal constructor.
- *
- * @param uri The URI of the logo.
- */
- public Logo(String uri) {
+ public Logo(Object uri) {
uri(uri);
}
@@ -85,24 +83,17 @@ public class Logo extends Common {
/**
* Sets the URI of the logo.
+ * <p>
+ * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}.
+ * Strings must be valid URIs.
+ * <p>
+ * URIs defined by {@link UriResolver} can be used for values.
*
* @param uri The URI of the logo.
* @return This object (for method chaining).
*/
@BeanProperty("uri")
- public Logo uri(URI uri) {
- this.uri = uri;
- return this;
- }
-
- /**
- * Sets the URI of the logo.
- *
- * @param uri The URI of the logo.
- * @return This object (for method chaining).
- */
- @BeanProperty("uri")
- public Logo uri(String uri) {
+ public Logo uri(Object uri) {
this.uri = toURI(uri);
return this;
}
@@ -113,7 +104,7 @@ public class Logo extends Common {
//--------------------------------------------------------------------------------
@Override /* Common */
- public Logo base(URI base) {
+ public Logo base(Object base) {
super.base(base);
return this;
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/6dccf603/juneau-core/src/main/java/org/apache/juneau/dto/atom/Person.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/atom/Person.java b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Person.java
index 34d28e3..aa5c336 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/atom/Person.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Person.java
@@ -12,10 +12,13 @@
// ***************************************************************************************************************************
package org.apache.juneau.dto.atom;
-import static org.apache.juneau.dto.atom.Utils.*;
+import static org.apache.juneau.internal.StringUtils.*;
+import java.net.*;
import java.net.URI;
+import org.apache.juneau.*;
+
import org.apache.juneau.annotation.*;
/**
@@ -97,24 +100,17 @@ public class Person extends Common {
/**
* Sets the URI of the person.
+ * <p>
+ * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}.
+ * Strings must be valid URIs.
+ * <p>
+ * URIs defined by {@link UriResolver} can be used for values.
*
* @param uri The URI of the person.
* @return This object (for method chaining).
*/
@BeanProperty("uri")
- public Person uri(URI uri) {
- this.uri = uri;
- return this;
- }
-
- /**
- * Sets the URI of the person.
- *
- * @param uri The URI of the person.
- * @return This object (for method chaining).
- */
- @BeanProperty("uri")
- public Person uri(String uri) {
+ public Person uri(Object uri) {
this.uri = toURI(uri);
return this;
}
@@ -146,7 +142,7 @@ public class Person extends Common {
//--------------------------------------------------------------------------------
@Override /* Common */
- public Person base(URI base) {
+ public Person base(Object base) {
super.base(base);
return this;
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/6dccf603/juneau-core/src/main/java/org/apache/juneau/dto/atom/Source.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/atom/Source.java b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Source.java
index 187f0b0..901be93 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/atom/Source.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Source.java
@@ -12,7 +12,6 @@
// ***************************************************************************************************************************
package org.apache.juneau.dto.atom;
-import java.net.URI;
import java.util.*;
import org.apache.juneau.annotation.*;
@@ -231,7 +230,7 @@ public class Source extends CommonEntry {
}
@Override /* Common */
- public Source base(URI base) {
+ public Source base(Object base) {
super.base(base);
return this;
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/6dccf603/juneau-core/src/main/java/org/apache/juneau/dto/atom/Text.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/atom/Text.java b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Text.java
index 40957e0..d38c823 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/atom/Text.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Text.java
@@ -14,8 +14,6 @@ package org.apache.juneau.dto.atom;
import static org.apache.juneau.xml.annotation.XmlFormat.*;
-import java.net.URI;
-
import org.apache.juneau.annotation.*;
import org.apache.juneau.xml.annotation.*;
@@ -133,13 +131,7 @@ public class Text extends Common {
//--------------------------------------------------------------------------------
@Override /* Common */
- public Text base(URI base) {
- super.base(base);
- return this;
- }
-
- @Override /* Common */
- public Text base(String base) {
+ public Text base(Object base) {
super.base(base);
return this;
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/6dccf603/juneau-core/src/main/java/org/apache/juneau/dto/atom/Utils.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/atom/Utils.java b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Utils.java
index 80f80a6..6bedd91 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/atom/Utils.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Utils.java
@@ -12,7 +12,6 @@
// ***************************************************************************************************************************
package org.apache.juneau.dto.atom;
-import java.net.*;
import java.util.*;
import javax.xml.bind.*;
@@ -32,20 +31,6 @@ import javax.xml.bind.*;
class Utils {
/**
- * Converts a string to a URI without a {@link URISyntaxException}
- *
- * @param uri The URI string to convert.
- * @return A new URI object.
- */
- static final URI toURI(String uri) {
- try {
- return new URI(uri);
- } catch (URISyntaxException e) {
- throw new RuntimeException(e);
- }
- }
-
- /**
* Converts an ISO8601 date-time string to a {@link Calendar}.
*
* @param lexicalXSDDateTime The ISO8601 date-time string.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/6dccf603/juneau-core/src/main/java/org/apache/juneau/dto/html5/A.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/A.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/A.java
index 795f256..07a4a00 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/A.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/A.java
@@ -14,7 +14,9 @@ package org.apache.juneau.dto.html5;
import java.net.*;
+import java.net.URI;
+import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
/**
@@ -46,12 +48,18 @@ public class A extends HtmlElementMixed {
/**
* <a class="doclink" href="https://www.w3.org/TR/html5/links.html#attr-hyperlink-href">href</a> attribute.
* Address of the hyperlink.
+ * <p>
+ * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}.
+ * Strings must be valid URIs.
+ * <p>
+ * URIs defined by {@link UriResolver} can be used for values.
+ *
* @param href The new value for this attribute.
* Typically a {@link URL} or {@link String}.
* @return This object (for method chaining).
*/
public final A href(Object href) {
- attr("href", href);
+ attrUri("href", href);
return this;
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/6dccf603/juneau-core/src/main/java/org/apache/juneau/dto/html5/Area.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Area.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Area.java
index 2ab1eef..ad6f335 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Area.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Area.java
@@ -13,7 +13,9 @@
package org.apache.juneau.dto.html5;
import java.net.*;
+import java.net.URI;
+import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
/**
@@ -68,12 +70,18 @@ public class Area extends HtmlElementVoid {
/**
* <a class="doclink" href="https://www.w3.org/TR/html5/links.html#attr-hyperlink-href">href</a> attribute.
* Address of the hyperlink.
+ * <p>
+ * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}.
+ * Strings must be valid URIs.
+ * <p>
+ * URIs defined by {@link UriResolver} can be used for values.
+ *
* @param href The new value for this attribute.
* Typically a {@link URL} or {@link String}.
* @return This object (for method chaining).
*/
public final Area href(Object href) {
- attr("href", href);
+ attrUri("href", href);
return this;
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/6dccf603/juneau-core/src/main/java/org/apache/juneau/dto/html5/Audio.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Audio.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Audio.java
index 3caa1b7..b5fef05 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Audio.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Audio.java
@@ -13,7 +13,9 @@
package org.apache.juneau.dto.html5;
import java.net.*;
+import java.net.URI;
+import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
/**
@@ -115,12 +117,18 @@ public class Audio extends HtmlElementContainer {
/**
* <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-media-src">src</a> attribute.
* Address of the resource.
+ * <p>
+ * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}.
+ * Strings must be valid URIs.
+ * <p>
+ * URIs defined by {@link UriResolver} can be used for values.
+ *
* @param src The new value for this attribute.
* Typically a {@link URL} or {@link String}.
* @return This object (for method chaining).
*/
public final Audio src(Object src) {
- attr("src", src);
+ attrUri("src", src);
return this;
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/6dccf603/juneau-core/src/main/java/org/apache/juneau/dto/html5/Base.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Base.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Base.java
index 2dc1314..1618c86 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Base.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Base.java
@@ -13,7 +13,9 @@
package org.apache.juneau.dto.html5;
import java.net.*;
+import java.net.URI;
+import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
/**
@@ -34,12 +36,18 @@ public class Base extends HtmlElementVoid {
/**
* <a class="doclink" href="https://www.w3.org/TR/html5/document-metadata.html#attr-base-href">href</a> attribute.
* Document base URL.
+ * <p>
+ * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}.
+ * Strings must be valid URIs.
+ * <p>
+ * URIs defined by {@link UriResolver} can be used for values.
+ *
* @param href The new value for this attribute.
* Typically a {@link URL} or {@link String}.
* @return This object (for method chaining).
*/
public final Base href(Object href) {
- attr("href", href);
+ attrUri("href", href);
return this;
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/6dccf603/juneau-core/src/main/java/org/apache/juneau/dto/html5/Button.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Button.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Button.java
index b122243..11fa930 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Button.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Button.java
@@ -12,6 +12,10 @@
// ***************************************************************************************************************************
package org.apache.juneau.dto.html5;
+import java.net.*;
+import java.net.URI;
+
+import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
/**
@@ -67,11 +71,17 @@ public class Button extends HtmlElementMixed {
/**
* <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-fs-formaction">formaction</a> attribute.
* URL to use for form submission.
+ * <p>
+ * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}.
+ * Strings must be valid URIs.
+ * <p>
+ * URIs defined by {@link UriResolver} can be used for values.
+ *
* @param formaction The new value for this attribute.
* @return This object (for method chaining).
*/
public final Button formaction(String formaction) {
- attr("formaction", formaction);
+ attrUri("formaction", formaction);
return this;
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/6dccf603/juneau-core/src/main/java/org/apache/juneau/dto/html5/Embed.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Embed.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Embed.java
index 18a1e26..1e1e6fa 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Embed.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Embed.java
@@ -13,7 +13,9 @@
package org.apache.juneau.dto.html5;
import java.net.*;
+import java.net.URI;
+import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
/**
@@ -46,12 +48,18 @@ public class Embed extends HtmlElementVoid {
/**
* <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-embed-src">src</a> attribute.
* Address of the resource.
+ * <p>
+ * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}.
+ * Strings must be valid URIs.
+ * <p>
+ * URIs defined by {@link UriResolver} can be used for values.
+ *
* @param src The new value for this attribute.
* Typically a {@link URL} or {@link String}.
* @return This object (for method chaining).
*/
public final Embed src(Object src) {
- attr("src", src);
+ attrUri("src", src);
return this;
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/6dccf603/juneau-core/src/main/java/org/apache/juneau/dto/html5/Form.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Form.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Form.java
index dddd0e9..e8b517a 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Form.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Form.java
@@ -12,6 +12,10 @@
// ***************************************************************************************************************************
package org.apache.juneau.dto.html5;
+import java.net.*;
+import java.net.URI;
+
+import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
/**
@@ -43,11 +47,17 @@ public class Form extends HtmlElementMixed {
/**
* <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-fs-action">action</a> attribute.
* URL to use for form submission.
+ * <p>
+ * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}.
+ * Strings must be valid URIs.
+ * <p>
+ * URIs defined by {@link UriResolver} can be used for values.
+ *
* @param action The new value for this attribute.
* @return This object (for method chaining).
*/
public final Form action(String action) {
- attr("action", action);
+ attrUri("action", action);
return this;
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/6dccf603/juneau-core/src/main/java/org/apache/juneau/dto/html5/HtmlElement.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/HtmlElement.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/HtmlElement.java
index 8c21a03..831db27 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/HtmlElement.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/HtmlElement.java
@@ -14,11 +14,16 @@ package org.apache.juneau.dto.html5;
import static org.apache.juneau.xml.annotation.XmlFormat.*;
+import java.net.*;
+import java.net.URI;
import java.util.*;
+import java.util.Map.*;
+import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
import org.apache.juneau.html.*;
-import org.apache.juneau.utils.*;
+import org.apache.juneau.internal.*;
+import org.apache.juneau.utils.ObjectUtils;
import org.apache.juneau.xml.annotation.*;
/**
@@ -56,6 +61,11 @@ public abstract class HtmlElement {
*/
@BeanProperty("a")
public HtmlElement setAttrs(LinkedHashMap<String,Object> attrs) {
+ for (Entry<String,Object> e : attrs.entrySet()) {
+ String key = e.getKey();
+ if ("url".equals(key) || "href".equals(key) || key.endsWith("action"))
+ e.setValue(StringUtils.toURI(e.getValue()));
+ }
this.attrs = attrs;
return this;
}
@@ -70,11 +80,35 @@ public abstract class HtmlElement {
public HtmlElement attr(String key, Object val) {
if (this.attrs == null)
this.attrs = new LinkedHashMap<String,Object>();
+ if ("url".equals(key) || "href".equals(key) || key.endsWith("action"))
+ val = StringUtils.toURI(val);
this.attrs.put(key, val);
return this;
}
/**
+ * Adds an arbitrary URI attribute to this element.
+ * <p>
+ * Same as {@link #attr(String, Object)}, except if the value is
+ * a string that appears to be a URI (e.g. <js>"servlet:/xxx"</js>).
+ * <p>
+ * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}.
+ * Strings must be valid URIs.
+ * <p>
+ * URIs defined by {@link UriResolver} can be used for values.
+ *
+ * @param key The attribute name.
+ * @param val The attribute value.
+ * @return This object (for method chaining).
+ */
+ public HtmlElement attrUri(String key, Object val) {
+ if (this.attrs == null)
+ this.attrs = new LinkedHashMap<String,Object>();
+ this.attrs.put(key, StringUtils.toURI(val));
+ return this;
+ }
+
+ /**
* Returns the attribute with the specified name.
*
* @param key The attribute name.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/6dccf603/juneau-core/src/main/java/org/apache/juneau/dto/html5/Iframe.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Iframe.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Iframe.java
index 0ebf8d3..70757a4 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Iframe.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Iframe.java
@@ -13,7 +13,9 @@
package org.apache.juneau.dto.html5;
import java.net.*;
+import java.net.URI;
+import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
/**
@@ -68,12 +70,18 @@ public class Iframe extends HtmlElementMixed {
/**
* <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-iframe-src">src</a> attribute.
* Address of the resource.
+ * <p>
+ * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}.
+ * Strings must be valid URIs.
+ * <p>
+ * URIs defined by {@link UriResolver} can be used for values.
+ *
* @param src The new value for this attribute.
* Typically a {@link URL} or {@link String}.
* @return This object (for method chaining).
*/
public final Iframe src(Object src) {
- attr("src", src);
+ attrUri("src", src);
return this;
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/6dccf603/juneau-core/src/main/java/org/apache/juneau/dto/html5/Img.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Img.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Img.java
index b9a8a8c..ab8ea60 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Img.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Img.java
@@ -13,7 +13,9 @@
package org.apache.juneau.dto.html5;
import java.net.*;
+import java.net.URI;
+import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
/**
@@ -79,12 +81,18 @@ public class Img extends HtmlElementVoid {
/**
* <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-img-src">src</a> attribute.
* Address of the resource.
+ * <p>
+ * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}.
+ * Strings must be valid URIs.
+ * <p>
+ * URIs defined by {@link UriResolver} can be used for values.
+ *
* @param src The new value for this attribute.
* Typically a {@link URL} or {@link String}.
* @return This object (for method chaining).
*/
public final Img src(Object src) {
- attr("src", src);
+ attrUri("src", src);
return this;
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/6dccf603/juneau-core/src/main/java/org/apache/juneau/dto/html5/Link.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Link.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Link.java
index 2d1f223..c06c501 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Link.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Link.java
@@ -13,7 +13,9 @@
package org.apache.juneau.dto.html5;
import java.net.*;
+import java.net.URI;
+import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
/**
@@ -45,12 +47,18 @@ public class Link extends HtmlElementVoid {
/**
* <a class="doclink" href="https://www.w3.org/TR/html5/document-metadata.html#attr-link-href">href</a> attribute.
* Address of the hyperlink.
+ * <p>
+ * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}.
+ * Strings must be valid URIs.
+ * <p>
+ * URIs defined by {@link UriResolver} can be used for values.
+ *
* @param href The new value for this attribute.
* Typically a {@link URL} or {@link String}.
* @return This object (for method chaining).
*/
public final Link href(Object href) {
- attr("href", href);
+ attrUri("href", href);
return this;
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/6dccf603/juneau-core/src/main/java/org/apache/juneau/dto/html5/Script.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Script.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Script.java
index aa51cd0..872545b 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Script.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Script.java
@@ -13,7 +13,9 @@
package org.apache.juneau.dto.html5;
import java.net.*;
+import java.net.URI;
+import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
/**
@@ -80,12 +82,18 @@ public class Script extends HtmlElementRawText {
/**
* <a class="doclink" href="https://www.w3.org/TR/html5/scripting-1.html#attr-script-src">src</a> attribute.
* Address of the resource.
+ * <p>
+ * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}.
+ * Strings must be valid URIs.
+ * <p>
+ * URIs defined by {@link UriResolver} can be used for values.
+ *
* @param src The new value for this attribute.
* Typically a {@link URL} or {@link String}.
* @return This object (for method chaining).
*/
public final Script src(Object src) {
- attr("src", src);
+ attrUri("src", src);
return this;
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/6dccf603/juneau-core/src/main/java/org/apache/juneau/dto/html5/Source.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Source.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Source.java
index 9286729..c820690 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Source.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Source.java
@@ -13,7 +13,9 @@
package org.apache.juneau.dto.html5;
import java.net.*;
+import java.net.URI;
+import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
/**
@@ -34,12 +36,18 @@ public class Source extends HtmlElementVoid {
/**
* <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-source-src">src</a> attribute.
* Address of the resource.
+ * <p>
+ * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}.
+ * Strings must be valid URIs.
+ * <p>
+ * URIs defined by {@link UriResolver} can be used for values.
+ *
* @param src The new value for this attribute.
* Typically a {@link URL} or {@link String}.
* @return This object (for method chaining).
*/
public final Source src(Object src) {
- attr("src", src);
+ attrUri("src", src);
return this;
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/6dccf603/juneau-core/src/main/java/org/apache/juneau/dto/html5/Track.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Track.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Track.java
index 3ae27f7..09c7d57 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Track.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Track.java
@@ -13,7 +13,9 @@
package org.apache.juneau.dto.html5;
import java.net.*;
+import java.net.URI;
+import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
/**
@@ -67,12 +69,18 @@ public class Track extends HtmlElementVoid {
/**
* <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-track-src">src</a> attribute.
* Address of the resource.
+ * <p>
+ * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}.
+ * Strings must be valid URIs.
+ * <p>
+ * URIs defined by {@link UriResolver} can be used for values.
+ *
* @param src The new value for this attribute.
* Typically a {@link URL} or {@link String}.
* @return This object (for method chaining).
*/
public final Track src(Object src) {
- attr("src", src);
+ attrUri("src", src);
return this;
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/6dccf603/juneau-core/src/main/java/org/apache/juneau/dto/html5/Video.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Video.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Video.java
index 6616884..7e4c6a2 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Video.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Video.java
@@ -13,7 +13,9 @@
package org.apache.juneau.dto.html5;
import java.net.*;
+import java.net.URI;
+import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
/**
@@ -138,12 +140,18 @@ public class Video extends HtmlElementContainer {
/**
* <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-media-src">src</a> attribute.
* Address of the resource.
+ * <p>
+ * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}.
+ * Strings must be valid URIs.
+ * <p>
+ * URIs defined by {@link UriResolver} can be used for values.
+ *
* @param src The new value for this attribute.
* Typically a {@link URL} or {@link String}.
* @return This object (for method chaining).
*/
public final Video src(Object src) {
- attr("src", src);
+ attrUri("src", src);
return this;
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/6dccf603/juneau-core/src/main/java/org/apache/juneau/dto/jsonschema/Schema.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/jsonschema/Schema.java b/juneau-core/src/main/java/org/apache/juneau/dto/jsonschema/Schema.java
index d92bec3..550a0b2 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/jsonschema/Schema.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/jsonschema/Schema.java
@@ -12,6 +12,9 @@
// ***************************************************************************************************************************
package org.apache.juneau.dto.jsonschema;
+import static org.apache.juneau.internal.StringUtils.*;
+
+import java.net.*;
import java.net.URI;
import java.util.*;
@@ -126,27 +129,21 @@ public class Schema {
/**
* Bean property setter: <property>id</property>.
+ * <p>
+ * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}.
+ * Strings must be valid URIs.
+ * <p>
+ * URIs defined by {@link UriResolver} can be used for values.
*
* @param id The new value for the <property>id</property> property on this bean.
* @return This object (for method chaining).
*/
- public Schema setId(URI id) {
- this.id = id;
+ public Schema setId(Object id) {
+ this.id = toURI(id);
return this;
}
/**
- * Bean property setter: <property>id</property>.
- *
- * @param id The new value for the <property>id</property> property on this bean.
- * The parameter must be a valid URI. It can be <jk>null</jk>.
- * @return This object (for method chaining).
- */
- public Schema setId(String id) {
- return setId(id == null ? null : URI.create(id));
- }
-
- /**
* Bean property getter: <property>$schema</property>.
*
* @return The value of the <property>$schema</property> property on this bean, or <jk>null</jk> if it is not set.
@@ -158,28 +155,22 @@ public class Schema {
/**
* Bean property setter: <property>$schema</property>.
+ * <p>
+ * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}.
+ * Strings must be valid URIs.
+ * <p>
+ * URIs defined by {@link UriResolver} can be used for values.
*
* @param schemaVersion The new value for the <property>schemaVersion</property> property on this bean.
* @return This object (for method chaining).
*/
@BeanProperty("$schema")
- public Schema setSchemaVersionUri(URI schemaVersion) {
- this.schemaVersion = schemaVersion;
+ public Schema setSchemaVersionUri(Object schemaVersion) {
+ this.schemaVersion = toURI(schemaVersion);
return this;
}
/**
- * Bean property setter: <property>schemaVersion</property>.
- *
- * @param schemaVersion The new value for the <property>schemaVersion</property> property on this bean.
- * The parameter must be a valid URI. It can be <jk>null</jk>.
- * @return This object (for method chaining).
- */
- public Schema setSchemaVersionUri(String schemaVersion) {
- return setSchemaVersionUri(schemaVersion == null ? null : URI.create(schemaVersion));
- }
-
- /**
* Bean property getter: <property>title</property>.
*
* @return The value of the <property>title</property> property, or <jk>null</jk> if it is not set.
@@ -1287,13 +1278,18 @@ public class Schema {
/**
* Bean property setter: <property>$ref</property>.
+ * <p>
+ * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}.
+ * Strings must be valid URIs.
+ * <p>
+ * URIs defined by {@link UriResolver} can be used for values.
*
* @param ref The new value for the <property>$ref</property> property on this bean.
* @return This object (for method chaining).
*/
@BeanProperty("$ref")
- public Schema setRef(URI ref) {
- this.ref = ref;
+ public Schema setRef(Object ref) {
+ this.ref = toURI(ref);
return this;
}
@@ -1364,19 +1360,6 @@ public class Schema {
if (not != null)
not.setMaster(master);
}
-
-
- /**
- * Bean property setter: <property>$ref</property>.
- *
- * @param ref The new value for the <property>$ref</property> property on this bean.
- * The parameter must be a valid URI. It can be <jk>null</jk>.
- * @return This object (for method chaining).
- */
- public Schema setRef(String ref) {
- return setRef(ref == null ? null : URI.create(ref));
- }
-
/**
* If this schema is a reference to another schema (i.e. has its <property>$ref</property> property set),
* this method will retrieve the referenced schema from the schema map registered with this schema.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/6dccf603/juneau-core/src/main/java/org/apache/juneau/dto/jsonschema/SchemaMap.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/jsonschema/SchemaMap.java b/juneau-core/src/main/java/org/apache/juneau/dto/jsonschema/SchemaMap.java
index 2b12e0a..98a06f5 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/jsonschema/SchemaMap.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/jsonschema/SchemaMap.java
@@ -12,10 +12,12 @@
// ***************************************************************************************************************************
package org.apache.juneau.dto.jsonschema;
+import static org.apache.juneau.internal.StringUtils.*;
import java.io.*;
import java.net.*;
import java.util.concurrent.*;
+import org.apache.juneau.*;
import org.apache.juneau.json.*;
/**
@@ -40,30 +42,30 @@ public abstract class SchemaMap extends ConcurrentHashMap<URI,Schema> {
private static final long serialVersionUID = 1L;
- @Override /* Map */
- public Schema get(Object uri) {
- if (uri == null)
- return null;
- return get(URI.create(uri.toString()));
- }
-
/**
* Return the {@link Schema} object at the specified URI.
* If this schema object has not been loaded yet, calls {@link #load(URI)}.
+ * <p>
+ * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}.
+ * Strings must be valid URIs.
+ * <p>
+ * URIs defined by {@link UriResolver} can be used for values.
*
* @param uri The URI of the schema to retrieve.
* @return The Schema, or <jk>null</jk> if schema was not located and could not be loaded.
*/
- public Schema get(URI uri) {
- Schema s = super.get(uri);
+ @Override /* Map */
+ public Schema get(Object uri) {
+ URI u = toURI(uri);
+ Schema s = super.get(u);
if (s != null)
return s;
synchronized(this) {
- s = load(uri);
+ s = load(u);
if (s != null) {
// Note: Can't use add(Schema...) since the ID property may not be set.
s.setSchemaMap(this);
- put(uri, s);
+ put(u, s);
}
return s;
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/6dccf603/juneau-core/src/main/java/org/apache/juneau/dto/jsonschema/SchemaRef.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/jsonschema/SchemaRef.java b/juneau-core/src/main/java/org/apache/juneau/dto/jsonschema/SchemaRef.java
index 7b59186..ef1a8e1 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/jsonschema/SchemaRef.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/jsonschema/SchemaRef.java
@@ -14,6 +14,8 @@ package org.apache.juneau.dto.jsonschema;
import java.net.*;
+import org.apache.juneau.*;
+
/**
* Convenience class for representing a schema reference such as <js>"{'$ref':'/url/to/ref'}"</js>.
* <p>
@@ -36,10 +38,15 @@ public class SchemaRef extends Schema {
/**
* Constructor.
+ * <p>
+ * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}.
+ * Strings must be valid URIs.
+ * <p>
+ * URIs defined by {@link UriResolver} can be used for values.
*
* @param uri The URI of the target reference. Can be <jk>null</jk>.
*/
- public SchemaRef(String uri) {
- this.setRef(uri == null ? null : URI.create(uri));
+ public SchemaRef(Object uri) {
+ this.setRef(uri);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/6dccf603/juneau-core/src/main/java/org/apache/juneau/dto/swagger/Contact.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/swagger/Contact.java b/juneau-core/src/main/java/org/apache/juneau/dto/swagger/Contact.java
index 6b55535..54102a8 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/swagger/Contact.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/swagger/Contact.java
@@ -12,6 +12,12 @@
// ***************************************************************************************************************************
package org.apache.juneau.dto.swagger;
+import static org.apache.juneau.internal.StringUtils.*;
+
+import java.net.*;
+import java.net.URI;
+
+import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
/**
@@ -40,7 +46,7 @@ import org.apache.juneau.annotation.*;
public class Contact extends SwaggerElement {
private String name;
- private String url;
+ private URI url;
private String email;
/**
@@ -84,31 +90,34 @@ public class Contact extends SwaggerElement {
*
* @return The value of the <property>url</property> property on this bean, or <jk>null</jk> if it is not set.
*/
- public String getUrl() {
+ public URI getUrl() {
return url;
}
/**
* Bean property setter: <property>url</property>.
* <p>
- * The URL pointing to the contact information. MUST be in the format of a URL.
+ * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}.
+ * Strings must be valid URIs.
+ * <p>
+ * URIs defined by {@link UriResolver} can be used for values.
*
* @param url The new value for the <property>url</property> property on this bean.
* @return This object (for method chaining).
*/
- public Contact setUrl(String url) {
- this.url = url;
+ public Contact setUrl(Object url) {
+ this.url = toURI(url);
return this;
}
/**
- * Synonym for {@link #setUrl(String)}.
+ * Synonym for {@link #setUrl(Object)}.
*
* @param url The new value for the <property>url</property> property on this bean.
* @return This object (for method chaining).
*/
- public Contact url(String url) {
- return setName(url);
+ public Contact url(Object url) {
+ return setUrl(url);
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/6dccf603/juneau-core/src/main/java/org/apache/juneau/dto/swagger/ExternalDocumentation.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/swagger/ExternalDocumentation.java b/juneau-core/src/main/java/org/apache/juneau/dto/swagger/ExternalDocumentation.java
index 3882f43..2679755 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/swagger/ExternalDocumentation.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/swagger/ExternalDocumentation.java
@@ -12,6 +12,12 @@
// ***************************************************************************************************************************
package org.apache.juneau.dto.swagger;
+import static org.apache.juneau.internal.StringUtils.*;
+
+import java.net.*;
+import java.net.URI;
+
+import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
/**
@@ -39,7 +45,7 @@ import org.apache.juneau.annotation.*;
public class ExternalDocumentation extends SwaggerElement {
private String description;
- private String url;
+ private URI url;
/**
* Bean property getter: <property>description</property>.
@@ -78,34 +84,42 @@ public class ExternalDocumentation extends SwaggerElement {
/**
* Bean property getter: <property>url</property>.
* <p>
- * Required. The URL for the target documentation. Value MUST be in the format of a URL.
+ * Required. The URL for the target documentation.
+ * <p>
+ * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}.
+ * Strings must be valid URIs.
+ * <p>
+ * URIs defined by {@link UriResolver} can be used for values.
*
* @return The value of the <property>url</property> property on this bean, or <jk>null</jk> if it is not set.
*/
- public String getUrl() {
+ public URI getUrl() {
return url;
}
/**
* Bean property setter: <property>url</property>.
* <p>
- * Required. The URL for the target documentation. Value MUST be in the format of a URL.
+ * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}.
+ * Strings must be valid URIs.
+ * <p>
+ * URIs defined by {@link UriResolver} can be used for values.
*
* @param url The new value for the <property>url</property> property on this bean.
* @return This object (for method chaining).
*/
- public ExternalDocumentation setUrl(String url) {
- this.url = url;
+ public ExternalDocumentation setUrl(Object url) {
+ this.url = toURI(url);
return this;
}
/**
- * Synonym for {@link #setUrl(String)}.
+ * Synonym for {@link #setUrl(Object)}.
*
* @param url The new value for the <property>url</property> property on this bean.
* @return This object (for method chaining).
*/
- public ExternalDocumentation url(String url) {
+ public ExternalDocumentation url(Object url) {
return setUrl(url);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/6dccf603/juneau-core/src/main/java/org/apache/juneau/dto/swagger/License.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/swagger/License.java b/juneau-core/src/main/java/org/apache/juneau/dto/swagger/License.java
index 3c720d7..13cef34 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/swagger/License.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/swagger/License.java
@@ -12,6 +12,12 @@
// ***************************************************************************************************************************
package org.apache.juneau.dto.swagger;
+import static org.apache.juneau.internal.StringUtils.*;
+
+import java.net.*;
+import java.net.URI;
+
+import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
/**
@@ -39,7 +45,7 @@ import org.apache.juneau.annotation.*;
public class License extends SwaggerElement {
private String name;
- private String url;
+ private URI url;
/**
* Bean property getter: <property>name</property>.
@@ -78,34 +84,42 @@ public class License extends SwaggerElement {
/**
* Bean property getter: <property>url</property>.
* <p>
- * A URL to the license used for the API. MUST be in the format of a URL.
+ * A URL to the license used for the API.
+ * <p>
+ * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}.
+ * Strings must be valid URIs.
+ * <p>
+ * URIs defined by {@link UriResolver} can be used for values.
*
* @return The value of the <property>url</property> property on this bean, or <jk>null</jk> if it is not set.
*/
- public String getUrl() {
+ public URI getUrl() {
return url;
}
/**
* Bean property setter: <property>url</property>.
* <p>
- * A URL to the license used for the API. MUST be in the format of a URL.
+ * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}.
+ * Strings must be valid URIs.
+ * <p>
+ * URIs defined by {@link UriResolver} can be used for values.
*
* @param url The new value for the <property>url</property> property on this bean.
* @return This object (for method chaining).
*/
- public License setUrl(String url) {
- this.url = url;
+ public License setUrl(Object url) {
+ this.url = toURI(url);
return this;
}
/**
- * Synonym for {@link #setUrl(String)}.
+ * Synonym for {@link #setUrl(Object)}.
*
* @param url The new value for the <property>url</property> property on this bean.
* @return This object (for method chaining).
*/
- public License url(String url) {
+ public License url(Object url) {
return setUrl(url);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/6dccf603/juneau-core/src/main/java/org/apache/juneau/dto/swagger/SwaggerBuilder.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/swagger/SwaggerBuilder.java b/juneau-core/src/main/java/org/apache/juneau/dto/swagger/SwaggerBuilder.java
index f49263d..aa71038 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/swagger/SwaggerBuilder.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/swagger/SwaggerBuilder.java
@@ -12,6 +12,10 @@
// ***************************************************************************************************************************
package org.apache.juneau.dto.swagger;
+import java.net.*;
+
+import org.apache.juneau.*;
+
/**
* Various useful static methods for creating Swagger elements.
*
@@ -44,13 +48,16 @@ public class SwaggerBuilder {
}
/**
- * Creates an {@link Contact} element with the specified {@link Contact#name(String)}, {@link Contact#url(String)}, and {@link Contact#email(String)}, attributes.
+ * Creates an {@link Contact} element with the specified {@link Contact#name(String)}, {@link Contact#url(Object)}, and {@link Contact#email(String)}, attributes.
* @param name The {@link Contact#name(String)} attribute.
- * @param url The {@link Contact#url(String)} attribute.
+ * @param url The {@link Contact#url(Object)} attribute.
+ * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}.
+ * <br>Strings must be valid URIs.
+ * <br>URIs defined by {@link UriResolver} can be used for values.
* @param email The {@link Contact#email(String)} attribute.
* @return The new element.
*/
- public static final Contact contact(String name, String url, String email) {
+ public static final Contact contact(String name, Object url, String email) {
return contact().name(name).url(url).email(email);
}
@@ -63,21 +70,27 @@ public class SwaggerBuilder {
}
/**
- * Creates an {@link ExternalDocumentation} element with the specified {@link ExternalDocumentation#url(String)} attribute.
- * @param url The {@link ExternalDocumentation#url(String)} attribute.
+ * Creates an {@link ExternalDocumentation} element with the specified {@link ExternalDocumentation#url(Object)} attribute.
+ * @param url The {@link ExternalDocumentation#url(Object)} attribute.
+ * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}.
+ * <br>Strings must be valid URIs.
+ * <br>URIs defined by {@link UriResolver} can be used for values.
* @return The new element.
*/
- public static final ExternalDocumentation externalDocumentation(String url) {
+ public static final ExternalDocumentation externalDocumentation(Object url) {
return externalDocumentation().url(url);
}
/**
- * Creates an {@link ExternalDocumentation} element with the specified {@link ExternalDocumentation#url(String)} and {@link ExternalDocumentation#description(String)} attributes.
- * @param url The {@link ExternalDocumentation#url(String)} attribute.
+ * Creates an {@link ExternalDocumentation} element with the specified {@link ExternalDocumentation#url(Object)} and {@link ExternalDocumentation#description(String)} attributes.
+ * @param url The {@link ExternalDocumentation#url(Object)} attribute.
+ * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}.
+ * <br>Strings must be valid URIs.
+ * <br>URIs defined by {@link UriResolver} can be used for values.
* @param description The {@link ExternalDocumentation#description(String)} attribute.
* @return The new element.
*/
- public static final ExternalDocumentation externalDocumentation(String url, String description) {
+ public static final ExternalDocumentation externalDocumentation(Object url, String description) {
return externalDocumentation().url(url).description(description);
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/6dccf603/juneau-core/src/main/java/org/apache/juneau/html/HtmlDocSerializerContext.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/html/HtmlDocSerializerContext.java b/juneau-core/src/main/java/org/apache/juneau/html/HtmlDocSerializerContext.java
index b8f5ddf..ebea8a3 100644
--- a/juneau-core/src/main/java/org/apache/juneau/html/HtmlDocSerializerContext.java
+++ b/juneau-core/src/main/java/org/apache/juneau/html/HtmlDocSerializerContext.java
@@ -75,6 +75,8 @@ public final class HtmlDocSerializerContext extends HtmlSerializerContext {
* <li><b>Session-overridable:</b> <jk>true</jk>
* </ul>
* <p>
+ * Specifies the text for the title that shows up in the header section of the page generated by the basic template.
+ * <p>
*
* <h5 class='section'>Example:</h5>
* <p>
@@ -132,6 +134,8 @@ public final class HtmlDocSerializerContext extends HtmlSerializerContext {
* <li><b>Session-overridable:</b> <jk>true</jk>
* </ul>
* <p>
+ * Specifies the text for the subtitle that shows up in the header section of the page generated by the basic template.
+ * <p>
*
* <h5 class='section'>Example:</h5>
* <p>
@@ -180,6 +184,23 @@ public final class HtmlDocSerializerContext extends HtmlSerializerContext {
public static final String HTMLDOC_description = "HtmlSerializer.description";
/**
+ * <b>Configuration property:</b> Page branding.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"HtmlSerializer.branding"</js>
+ * <li><b>Data type:</b> <code>String</code>
+ * <li><b>Default:</b> <jk>null</jk>
+ * <li><b>Session-overridable:</b> <jk>true</jk>
+ * </ul>
+ * <p>
+ * Specifies arbitrary HTML for the header that can be used for adding custom branding to the page generated by the
+ * basic template.
+ * <p>
+ * A value of <js>"NONE"</js> can be used to represent no value to differentiate it from an empty string.
+ */
+ public static final String HTMLDOC_branding = "HtmlSerializer.branding";
+
+ /**
* <b>Configuration property:</b> Header section contents.
* <p>
* <ul>
@@ -476,7 +497,7 @@ public final class HtmlDocSerializerContext extends HtmlSerializerContext {
final String[] css;
final Map<String,String> links;
- final String title, description, header, nav, aside, footer, cssUrl, noResultsMessage;
+ final String title, description, branding, header, nav, aside, footer, cssUrl, noResultsMessage;
final boolean nowrap;
final HtmlDocTemplate template;
@@ -492,6 +513,7 @@ public final class HtmlDocSerializerContext extends HtmlSerializerContext {
css = ps.getProperty(HTMLDOC_css, String[].class, new String[0]);
title = ps.getProperty(HTMLDOC_title, String.class, null);
description = ps.getProperty(HTMLDOC_description, String.class, null);
+ branding = ps.getProperty(HTMLDOC_branding, String.class, null);
header = ps.getProperty(HTMLDOC_header, String.class, null);
nav = ps.getProperty(HTMLDOC_nav, String.class, null);
aside = ps.getProperty(HTMLDOC_aside, String.class, null);
@@ -510,6 +532,7 @@ public final class HtmlDocSerializerContext extends HtmlSerializerContext {
.append("cssImports", css)
.append("title", title)
.append("text", description)
+ .append("branding", branding)
.append("header", header)
.append("nav", nav)
.append("links", links)
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/6dccf603/juneau-core/src/main/java/org/apache/juneau/html/HtmlDocSerializerSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/html/HtmlDocSerializerSession.java b/juneau-core/src/main/java/org/apache/juneau/html/HtmlDocSerializerSession.java
index 5cb8d91..15fff6b 100644
--- a/juneau-core/src/main/java/org/apache/juneau/html/HtmlDocSerializerSession.java
+++ b/juneau-core/src/main/java/org/apache/juneau/html/HtmlDocSerializerSession.java
@@ -33,7 +33,7 @@ import org.apache.juneau.serializer.*;
*/
public final class HtmlDocSerializerSession extends HtmlSerializerSession {
- private final String title, description, header, nav, aside, footer, cssUrl, noResultsMessage;
+ private final String title, description, branding, header, nav, aside, footer, cssUrl, noResultsMessage;
private final String[] css;
private final Map<String,String> links;
private final boolean nowrap;
@@ -62,6 +62,7 @@ public final class HtmlDocSerializerSession extends HtmlSerializerSession {
if (op == null || op.isEmpty()) {
title = ctx.title;
description = ctx.description;
+ branding = ctx.branding;
header = ctx.header;
nav = ctx.nav;
aside = ctx.aside;
@@ -75,6 +76,7 @@ public final class HtmlDocSerializerSession extends HtmlSerializerSession {
} else {
title = op.getString(HTMLDOC_title, ctx.title);
description = op.getString(HTMLDOC_description, ctx.description);
+ branding = op.getString(HTMLDOC_branding, ctx.branding);
header = op.getString(HTMLDOC_header, ctx.nav);
nav = op.getString(HTMLDOC_nav, ctx.nav);
aside = op.getString(HTMLDOC_aside, ctx.aside);
@@ -134,6 +136,15 @@ public final class HtmlDocSerializerSession extends HtmlSerializerSession {
}
/**
+ * Returns the {@link HtmlDocSerializerContext#HTMLDOC_branding} setting value in this context.
+ * @return The {@link HtmlDocSerializerContext#HTMLDOC_branding} setting value in this context.
+ * <jk>null</jk> if not specified. Never an empty string.
+ */
+ public final String getBranding() {
+ return branding;
+ }
+
+ /**
* Returns the {@link HtmlDocSerializerContext#HTMLDOC_header} setting value in this context.
* @return The {@link HtmlDocSerializerContext#HTMLDOC_header} setting value in this context.
* <jk>null</jk> if not specified. Never an empty string.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/6dccf603/juneau-core/src/main/java/org/apache/juneau/html/HtmlDocTemplateBasic.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/html/HtmlDocTemplateBasic.java b/juneau-core/src/main/java/org/apache/juneau/html/HtmlDocTemplateBasic.java
index 6553fdb..05f9705 100644
--- a/juneau-core/src/main/java/org/apache/juneau/html/HtmlDocTemplateBasic.java
+++ b/juneau-core/src/main/java/org/apache/juneau/html/HtmlDocTemplateBasic.java
@@ -94,10 +94,13 @@ public class HtmlDocTemplateBasic implements HtmlDocTemplate {
} else {
String title = session.getTitle();
String description = session.getDescription();
+ String branding = session.getBranding();
if (exists(title))
w.oTag(1, "h3").attr("class", "title").append('>').text(title).eTag("h3").nl();
if (exists(description))
w.oTag(1, "h5").attr("class", "description").append('>').text(description).eTag("h5").nl();
+ if (exists(branding))
+ w.append(branding).nl();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/6dccf603/juneau-core/src/main/java/org/apache/juneau/internal/StringUtils.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/internal/StringUtils.java b/juneau-core/src/main/java/org/apache/juneau/internal/StringUtils.java
index c4bf1db..61bacb0 100644
--- a/juneau-core/src/main/java/org/apache/juneau/internal/StringUtils.java
+++ b/juneau-core/src/main/java/org/apache/juneau/internal/StringUtils.java
@@ -1395,6 +1395,56 @@ public final class StringUtils {
}
/**
+ * Efficiently determines whether a URL is of the pattern "xxx:/xxx".
+ * <p>
+ * The pattern matched is: <code>[a-z]{2,}\:\/.*</code>
+ * <p>
+ * Note that this excludes filesystem paths such as <js>"C:/temp"</js>.
+ *
+ * @param s The string to test.
+ * @return <jk>true</jk> if it's an absolute path.
+ */
+ public static boolean isUri(String s) {
+
+ if (isEmpty(s))
+ return false;
+
+ // Use a state machine for maximum performance.
+
+ int S1 = 1; // Looking for protocol char 1
+ int S2 = 2; // Found protocol char 1, looking for protocol char 2
+ int S3 = 3; // Found protocol char 2, looking for :
+ int S4 = 4; // Found :, looking for /
+
+
+ int state = S1;
+ for (int i = 0; i < s.length(); i++) {
+ char c = s.charAt(i);
+ if (state == S1) {
+ if (c >= 'a' && c <= 'z')
+ state = S2;
+ else
+ return false;
+ } else if (state == S2) {
+ if (c >= 'a' && c <= 'z')
+ state = S3;
+ else
+ return false;
+ } else if (state == S3) {
+ if (c == ':')
+ state = S4;
+ else if (c < 'a' || c > 'z')
+ return false;
+ } else if (state == S4) {
+ if (c == '/')
+ return true;
+ return false;
+ }
+ }
+ return false;
+ }
+
+ /**
* Given an absolute URI, returns just the authority portion (e.g. <js>"http://hostname:port"</js>)
*
* @param s The URI string.
@@ -1446,4 +1496,20 @@ public final class StringUtils {
}
return s;
}
+
+ /**
+ * Converts the specified object to a URI.
+ *
+ * @param o The object to convert to a URI.
+ * @return A new URI, or the same object if the object was already a URI, or
+ */
+ public static URI toURI(Object o) {
+ if (o == null || o instanceof URI)
+ return (URI)o;
+ try {
+ return new URI(o.toString());
+ } catch (URISyntaxException e) {
+ throw new RuntimeException(e);
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/6dccf603/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerContext.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerContext.java b/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerContext.java
index 1381972..ac65ab2 100644
--- a/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerContext.java
+++ b/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerContext.java
@@ -238,7 +238,7 @@ public class SerializerContext extends BeanContext {
* <ul>
* <li><b>Name:</b> <js>"Serializer.uriResolution"</js>
* <li><b>Data type:</b> {@link UriResolution}
- * <li><b>Default:</b> {@link UriResolution#ROOT_RELATIVE}
+ * <li><b>Default:</b> {@link UriResolution#NONE}
* <li><b>Session-overridable:</b> <jk>true</jk>
* </ul>
* <p>
@@ -392,7 +392,7 @@ public class SerializerContext extends BeanContext {
abridged = ps.getProperty(SERIALIZER_abridged, boolean.class, false);
quoteChar = ps.getProperty(SERIALIZER_quoteChar, String.class, "\"").charAt(0);
uriContext = ps.getProperty(SERIALIZER_uriContext, UriContext.class, UriContext.DEFAULT);
- uriResolution = ps.getProperty(SERIALIZER_uriResolution, UriResolution.class, UriResolution.ROOT_RELATIVE);
+ uriResolution = ps.getProperty(SERIALIZER_uriResolution, UriResolution.class, UriResolution.NONE);
uriRelativity = ps.getProperty(SERIALIZER_uriRelativity, UriRelativity.class, UriRelativity.RESOURCE);
listener = ps.getProperty(SERIALIZER_listener, Class.class, null);
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/6dccf603/juneau-core/src/main/javadoc/overview.html
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/javadoc/overview.html b/juneau-core/src/main/javadoc/overview.html
index 9f7d54f..9d4a49e 100644
--- a/juneau-core/src/main/javadoc/overview.html
+++ b/juneau-core/src/main/javadoc/overview.html
@@ -6294,6 +6294,7 @@
<ul>
<li>{@link org.apache.juneau.html.HtmlDocSerializerContext#HTMLDOC_title}
<li>{@link org.apache.juneau.html.HtmlDocSerializerContext#HTMLDOC_description}
+ <li>{@link org.apache.juneau.html.HtmlDocSerializerContext#HTMLDOC_branding}
<li>{@link org.apache.juneau.html.HtmlDocSerializerContext#HTMLDOC_header}
<li>{@link org.apache.juneau.html.HtmlDocSerializerContext#HTMLDOC_nav}
<li>{@link org.apache.juneau.html.HtmlDocSerializerContext#HTMLDOC_aside}
@@ -6456,6 +6457,7 @@
<ul>
<li>{@link org.apache.juneau.rest.RestConfig#setHtmlTitle(String) setHtmlTitle(String)}
<li>{@link org.apache.juneau.rest.RestConfig#setHtmlDescription(String) setHtmlDescription(String)}
+ <li>{@link org.apache.juneau.rest.RestConfig#setHtmlBranding(String) setHtmlBranding(String)}
<li>{@link org.apache.juneau.rest.RestConfig#setHtmlHeader(String) setHtmlHeader(String)}
<li>{@link org.apache.juneau.rest.RestConfig#setHtmlLinks(String) setHtmlLinks(String)}
<li>{@link org.apache.juneau.rest.RestConfig#setHtmlNav(String) setHtmlNav(String)}
@@ -6473,6 +6475,7 @@
<ul>
<li>{@link org.apache.juneau.rest.RestResponse#setHtmlTitle(Object) setHtmlTitle(Object)}
<li>{@link org.apache.juneau.rest.RestResponse#setHtmlDescription(Object) setHtmlDescription(Object)}
+ <li>{@link org.apache.juneau.rest.RestResponse#setHtmlBranding(Object) setHtmlBranding(Object)}
<li>{@link org.apache.juneau.rest.RestResponse#setHtmlHeader(Object) setHtmlHeader(Object)}
<li>{@link org.apache.juneau.rest.RestResponse#setHtmlLinks(Object) setHtmlLinks(Object)}
<li>{@link org.apache.juneau.rest.RestResponse#setHtmlNav(Object) setHtmlNav(Object)}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/6dccf603/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/RootResources.java
----------------------------------------------------------------------
diff --git a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/RootResources.java b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/RootResources.java
index 2637411..3f572e6 100644
--- a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/RootResources.java
+++ b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/RootResources.java
@@ -36,10 +36,11 @@ import org.apache.juneau.rest.widget.*;
+ " <p>All content on pages in the UI are serialized POJOs. In this case, it's a serialized array of beans with 2 properties.</p>"
+ " <p>Other features (such as this aside) are added through annotations.</p>"
+ "</div>",
- footer="$W{poweredByJuneau}"
+ footer="$W{poweredByApache}"
),
widgets={
PoweredByJuneauWidget.class,
+ PoweredByApacheWidget.class,
ContentTypeLinksWidget.class
},
children={
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/6dccf603/juneau-rest/src/main/java/org/apache/juneau/rest/CallMethod.java
----------------------------------------------------------------------
diff --git a/juneau-rest/src/main/java/org/apache/juneau/rest/CallMethod.java b/juneau-rest/src/main/java/org/apache/juneau/rest/CallMethod.java
index 69d6814..f6753e5 100644
--- a/juneau-rest/src/main/java/org/apache/juneau/rest/CallMethod.java
+++ b/juneau-rest/src/main/java/org/apache/juneau/rest/CallMethod.java
@@ -66,8 +66,8 @@ class CallMethod implements Comparable<CallMethod> {
private final org.apache.juneau.rest.annotation.Parameter[] parameters;
private final Response[] responses;
private final RestContext context;
- private final String htmlTitle, htmlDescription, htmlHeader, htmlLinks, htmlNav, htmlAside, htmlFooter, htmlCss,
- htmlCssUrl, htmlNoResultsMessage;
+ private final String htmlTitle, htmlDescription, htmlBranding, htmlHeader, htmlLinks, htmlNav, htmlAside,
+ htmlFooter, htmlCss, htmlCssUrl, htmlNoResultsMessage;
private final boolean htmlNoWrap;
private final HtmlDocTemplate htmlTemplate;
private final Map<String,Widget> widgets;
@@ -103,6 +103,7 @@ class CallMethod implements Comparable<CallMethod> {
this.responses = b.responses;
this.htmlTitle = b.htmlTitle;
this.htmlDescription = b.htmlDescription;
+ this.htmlBranding = b.htmlBranding;
this.htmlHeader = b.htmlHeader;
this.htmlLinks = b.htmlLinks;
this.htmlNav = b.htmlNav;
@@ -118,7 +119,7 @@ class CallMethod implements Comparable<CallMethod> {
private static class Builder {
private String httpMethod, defaultCharset, description, tags, summary, externalDocs, htmlTitle, htmlDescription,
- htmlLinks, htmlNav, htmlAside, htmlFooter, htmlCssUrl, htmlCss, htmlHeader, htmlNoResultsMessage;
+ htmlBranding, htmlLinks, htmlNav, htmlAside, htmlFooter, htmlCssUrl, htmlCss, htmlHeader, htmlNoResultsMessage;
private boolean htmlNoWrap;
private HtmlDocTemplate htmlTemplate;
private UrlPathPattern pathPattern;
@@ -173,6 +174,7 @@ class CallMethod implements Comparable<CallMethod> {
HtmlDoc hd = m.htmldoc();
htmlTitle = hd.title().isEmpty() ? context.getHtmlTitle() : hd.title();
htmlDescription = hd.description().isEmpty() ? context.getHtmlDescription() : hd.description();
+ htmlBranding = hd.branding().isEmpty() ? context.getHtmlBranding() : hd.branding();
htmlHeader = hd.header().isEmpty() ? context.getHtmlHeader() : hd.header();
htmlLinks = hd.links().isEmpty() ? context.getHtmlLinks() : hd.links();
htmlNav = hd.nav().isEmpty() ? context.getHtmlNav() : hd.nav();
@@ -875,6 +877,8 @@ class CallMethod implements Comparable<CallMethod> {
}
if (k.equals(HTMLDOC_header))
return htmlHeader == null ? null : req.resolveVars(htmlHeader);
+ if (k.equals(HTMLDOC_branding))
+ return htmlBranding == null ? null : req.resolveVars(htmlBranding);
if (k.equals(HTMLDOC_links))
return htmlLinks == null ? null : req.resolveVars(htmlLinks);
if (k.equals(HTMLDOC_nav))