1 package org.kuali.common.util.properties;
2
3 import java.nio.charset.Charset;
4
5 import org.kuali.common.util.Assert;
6 import org.kuali.common.util.Mode;
7 import org.kuali.common.util.property.PropertyFormat;
8
9 public final class Location {
10
11 public static final Mode DEFAULT_MISSING_MODE = Mode.ERROR;
12 public static final boolean DEFAULT_CACHEABLE = false;
13 public static final PropertyFormat DEFAULT_PROPERTY_FORMAT = PropertyFormat.NORMAL;
14 public static final String DEFAULT_ENCODING = Charset.defaultCharset().toString();
15
16 private final Mode missingMode;
17 private final String encoding;
18 private final PropertyFormat format;
19 private final String value;
20 private final boolean cacheable;
21
22 public Location(String value) {
23 this(value, DEFAULT_ENCODING, DEFAULT_MISSING_MODE, DEFAULT_PROPERTY_FORMAT);
24 }
25
26 public Location(String value, String encoding) {
27 this(value, encoding, DEFAULT_MISSING_MODE, DEFAULT_PROPERTY_FORMAT);
28 }
29
30 public Location(String value, String encoding, boolean cacheable) {
31 this(value, encoding, DEFAULT_MISSING_MODE, DEFAULT_PROPERTY_FORMAT, cacheable);
32 }
33
34 public Location(String value, String encoding, Mode missingMode, PropertyFormat format) {
35 this(value, encoding, DEFAULT_MISSING_MODE, DEFAULT_PROPERTY_FORMAT, DEFAULT_CACHEABLE);
36 }
37
38 public Location(String value, String encoding, Mode missingMode, PropertyFormat format, boolean cacheable) {
39 Assert.noBlanks(value, encoding);
40 Assert.noNulls(missingMode, format);
41 this.value = value;
42 this.encoding = encoding;
43 this.missingMode = missingMode;
44 this.format = format;
45 this.cacheable = cacheable;
46 }
47
48 public Mode getMissingMode() {
49 return missingMode;
50 }
51
52 public String getEncoding() {
53 return encoding;
54 }
55
56 public PropertyFormat getFormat() {
57 return format;
58 }
59
60 public String getValue() {
61 return value;
62 }
63
64 public boolean isCacheable() {
65 return cacheable;
66 }
67
68 }