blob: f397edb044c61ad6da84ce026adc23d14d3b95c5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* $Id: $ */
package org.apache.fop.render.afp;
/**
* The level at which a resource is to reside in the AFP output
*/
public class ResourceLevel {
private static final String EXTERNAL = "external";
private static final String PRINT_FILE = "print-file";
private static final String DOCUMENT = "document";
private static final String PAGE_GROUP = "page-group";
private static final String PAGE = "page";
/**
* where the resource will reside in the AFP output
*/
private String level = PAGE; // default is page level
/**
* the destination location of the resource
*/
private String dest = null;
/**
* @return true if this is a page level resource group
*/
public boolean isPage() {
return level.equals(PAGE);
}
/**
* @return true if this is a page group level resource group
*/
public boolean isPageGroup() {
return level.equals(PAGE_GROUP);
}
/**
* @return true if this is a document level resource group
*/
public boolean isDocument() {
return level.equals(DOCUMENT);
}
/**
* @return true if this is an external level resource group
*/
public boolean isExternal() {
return level.equals(EXTERNAL);
}
/**
* @return true if this is a print-file level resource group
*/
public boolean isPrintFile() {
return level.equals(PRINT_FILE);
}
private boolean isValid(String lvl) {
return lvl.equals(EXTERNAL)
|| lvl.equals(PRINT_FILE)
|| lvl.equals(DOCUMENT)
|| lvl.equals(PAGE_GROUP)
|| lvl.equals(PAGE);
}
/**
* Sets the resource placement level within the AFP output
* @param level the resource level (page, page-group, document, print-file or external)
* @return true if the resource level was successfully set
*/
public boolean setLevel(String level) {
if (isValid(level)) {
this.level = level;
return true;
}
return false;
}
/**
* @return the external destination of the resource
*/
public String getExternalDest() {
return dest;
}
/**
* Sets the external destination of the resource
* @param dest the external destination of the resource
*/
public void setExternalDest(String dest) {
this.dest = dest;
}
/**
* {@inheritDoc}
*/
public String toString() {
return "level=" + level + (isExternal() ? ", dest=" + dest : "");
}
}
|