View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.juneau.serializer;
18  
19  import static org.apache.juneau.commons.utils.StringUtils.*;
20  
21  import java.net.*;
22  
23  import org.apache.juneau.annotation.*;
24  import org.apache.juneau.xml.annotation.*;
25  
26  @Bean(sort=true)
27  public class TestURIc {
28  
29  	@Uri(on="Dummy1")
30  	@Uri(on="TestURIc.f0,TestURIc.f2a,TestURIc.f2b,TestURIc.f2c,TestURIc.f2d,TestURIc.f2e,TestURIc.f2f,TestURIc.f2g,TestURIc.f2h,TestURIc.f2i,TestURIc.f2j,TestURIc.f2k,TestURIc.f2l,TestURIc.f2m,TestURIc.f2n,TestURIc.f2o,TestURIc.f3a,,TestURIc.f3b,TestURIc.f3c,TestURIc.getF5,TestURIbc")
31  	@Uri(on="Dummy2")
32  	public static class Config {}
33  
34  	// String annotated as a URI
35  	@Xml(format=XmlFormat.ATTR)
36  	public String f0 = "f0/x0";
37  
38  	// URI properties
39  	public URI
40  		f1a = URI.create("http://www.apache.org/f1a"),
41  		f1b = URI.create("/f1b"),
42  		f1c = URI.create("/f1c/x/y"),
43  		f1d = URI.create("f1d"),
44  		f1e = URI.create("f1e/x/y"),
45  		f1f = URI.create(""),
46  		f1g = URI.create("servlet:/f1g/x"),
47  		f1h = URI.create("servlet:/f1h"),
48  		f1i = URI.create("servlet:/"),
49  		f1j = URI.create("servlet:/.."),
50  		f1k = URI.create("context:/f1j/x"),
51  		f1l = URI.create("context:/f1k"),
52  		f1m = URI.create("context:/"),
53  		f1n = URI.create("context:/.."),
54  		fio = null;
55  
56  	// Strings annotated with @URI properties
57  	public String
58  		f2a = "http://www.apache.org/f2a",
59  		f2b = "/f2b",
60  		f2c = "/f2c/x/y",
61  		f2d = "f2d",
62  		f2e = "f2e/x/y",
63  		f2f = "",
64  		f2g = "servlet:/f2g/x",
65  		f2h = "servlet:/f2h",
66  		f2i = "servlet:/",
67  		f2j = "servlet:/..",
68  		f2k = "context:/f2j/x",
69  		f2l = "context:/f2k",
70  		f2m = "context:/",
71  		f2n = "context:/..",
72  		f2o = null;
73  
74  	// Strings with labels
75  	public String
76  		f3a = "http://www.apache.org/f3a/x?label=MY_LABEL&foo=bar",
77  		f3b = urlEncode("<>&'\""),
78  		f3c = "<>&'\"";  // Invalid URI, but should produce parsable output.
79  
80  	// @URI on bean
81  	public TestURIbc f4 = new TestURIbc();
82  
83  	// @URI on bean property method.
84  	public String getF5() {
85  		return "f5/x";
86  	}
87  
88  	public static class TestURIbc {
89  		@Override /* Overridden from Object */
90  		public String toString() {
91  			return "test/uri/b";
92  		}
93  	}
94  }