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 java.net.*;
20  
21  import org.apache.juneau.annotation.*;
22  import org.apache.juneau.common.utils.*;
23  import org.apache.juneau.xml.annotation.*;
24  
25  @Bean(sort=true)
26  public class TestURIc {
27  
28  	@Uri(on="Dummy1")
29  	@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")
30  	@Uri(on="Dummy2")
31  	public static class Config {}
32  
33  	// String annotated as a URI
34  	@Xml(format=XmlFormat.ATTR)
35  	public String f0 = "f0/x0";
36  
37  	// URI properties
38  	public URI
39  		f1a = URI.create("http://www.apache.org/f1a"),
40  		f1b = URI.create("/f1b"),
41  		f1c = URI.create("/f1c/x/y"),
42  		f1d = URI.create("f1d"),
43  		f1e = URI.create("f1e/x/y"),
44  		f1f = URI.create(""),
45  		f1g = URI.create("servlet:/f1g/x"),
46  		f1h = URI.create("servlet:/f1h"),
47  		f1i = URI.create("servlet:/"),
48  		f1j = URI.create("servlet:/.."),
49  		f1k = URI.create("context:/f1j/x"),
50  		f1l = URI.create("context:/f1k"),
51  		f1m = URI.create("context:/"),
52  		f1n = URI.create("context:/.."),
53  		fio = null;
54  
55  	// Strings annotated with @URI properties
56  	public String
57  		f2a = "http://www.apache.org/f2a",
58  		f2b = "/f2b",
59  		f2c = "/f2c/x/y",
60  		f2d = "f2d",
61  		f2e = "f2e/x/y",
62  		f2f = "",
63  		f2g = "servlet:/f2g/x",
64  		f2h = "servlet:/f2h",
65  		f2i = "servlet:/",
66  		f2j = "servlet:/..",
67  		f2k = "context:/f2j/x",
68  		f2l = "context:/f2k",
69  		f2m = "context:/",
70  		f2n = "context:/..",
71  		f2o = null;
72  
73  	// Strings with labels
74  	public String
75  		f3a = "http://www.apache.org/f3a/x?label=MY_LABEL&foo=bar",
76  		f3b = StringUtils.urlEncode("<>&'\""),
77  		f3c = "<>&'\"";  // Invalid URI, but should produce parsable output.
78  
79  	// @URI on bean
80  	public TestURIbc f4 = new TestURIbc();
81  
82  	// @URI on bean property method.
83  	public String getF5() {
84  		return "f5/x";
85  	}
86  
87  	public static class TestURIbc {
88  		@Override /* Object */
89  		public String toString() {
90  			return "test/uri/b";
91  		}
92  	}
93  }