Project

General

Profile

Download (4.51 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2020 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.cdm.api.service.media;
10

    
11
/**
12
 * Defines a transformation rule to create volatile media representation on base of existing ones.
13
 * <p>
14
 * All defined {@link SearchReplace} rules must match otherwise the transformations is omitted.
15
 * A {@link SearchReplace} rule can be mediate an identity transformation of is URI part
16
 * in which case the rule just acts as a filter.
17
 * <p>
18
 * <b>CHANGING THIS CLASS MAY BREAK DESERIALIZATION OF EXISTING CDM PREFERENCES!</b>
19
 *
20
 * @author a.kohlbecker
21
 * @since Jul 8, 2020
22
 */
23
public class MediaUriTransformation {
24

    
25
    SearchReplace scheme = null;
26
    SearchReplace host = null;
27
    SearchReplace pathQueryFragment = null;
28

    
29
    String mimeType = null;
30

    
31
    Integer width = null;
32
    Integer height = null;
33
    boolean isMaxExtend = false;
34

    
35
    public MediaUriTransformation() {}
36

    
37
    public SearchReplace getScheme() {
38
        return scheme;
39
    }
40

    
41
    /**
42
     * Replacement rule for the scheme part of the URI.
43
     * <p>
44
     * In case the regex pattern {@link SearchReplace#getSearch()} does not match the URI part
45
     * the whole <code>MediaUriTransformation</code> must be omitted.
46
     *
47
     * @param scheme The search replace rule for the URI scheme
48
     */
49
    public void setScheme(SearchReplace scheme) {
50
        this.scheme = scheme;
51
    }
52

    
53

    
54
    public SearchReplace getHost() {
55
        return host;
56
    }
57

    
58
    /**
59
     * Replacement rule for the host part of the URI.
60
     * <p>
61
     * In case the regex pattern {@link SearchReplace#getSearch()} does not match the URI part
62
     * the whole <code>MediaUriTransformation</code> must be omitted.
63
     *
64
     * @param scheme The search replace rule for the URI host
65
     */
66
    public void setHost(SearchReplace host) {
67
        this.host = host;
68
    }
69

    
70

    
71
    public SearchReplace getPathQueryFragment() {
72
        return pathQueryFragment;
73
    }
74

    
75

    
76
    /**
77
     * Replacement rule for the combined {@code path + "?" + query + "#" + fragment} parts of the URI.
78
     * <p>
79
     * In case the regex pattern {@link SearchReplace#getSearch()} does not match this string
80
     * the whole <code>MediaUriTransformation</code> must be omitted.
81
     *
82
     * @param scheme The search replace rule for combined {@code path + "?" + query + "#" + fragment} parts of the URI.
83
     */
84
    public void setPathQueryFragment(SearchReplace pathQueryFragment) {
85
        this.pathQueryFragment = pathQueryFragment;
86
    }
87

    
88
    /**
89
     * The mime type of the target media
90
     *
91
     * @return the mimeType
92
     */
93
    public String getMimeType() {
94
        return mimeType;
95
    }
96

    
97
    /**
98
     * The mime type of the target media
99
     *
100
     * @param mimeType the mimeType to set
101
     */
102
    public void setMimeType(String mimeType) {
103
        this.mimeType = mimeType;
104
    }
105

    
106
    /**
107
     * The pixel width of the target media, usually of an image.
108
     * The resulting image size also depends on {@link #isMaxExtend()}.
109
     *
110
     * @return the width
111
     */
112
    public Integer getWidth() {
113
        return width;
114
    }
115

    
116
    /**
117
     * The pixel width of the target media, usually of an image.
118
     * The resulting image size also depends on {@link #isMaxExtend()}.
119
     *
120
     * @param width the width to set
121
     */
122
    public void setWidth(Integer width) {
123
        this.width = width;
124
    }
125

    
126
    /**
127
     * The pixel height of the target media, usually of an image.
128
     * The resulting image size also depends on {@link #isMaxExtend()}.
129
     *
130
     * @return the height
131
     */
132
    public Integer getHeight() {
133
        return height;
134
    }
135

    
136
    /**
137
     * The pixel height of the target media, usually of an image.
138
     * The resulting image size also depends on {@link #isMaxExtend()}.
139
     *
140
     * @param height the height to set
141
     */
142
    public void setHeight(Integer height) {
143
        this.height = height;
144
    }
145

    
146
    /**
147
     * When true, the {@link #getWidth() width} and {@link #getHeight() height} are interpreted as max-extend. Otherwise
148
     * it is is assumed that the image will be cropped to the specified size.
149
     *
150
     * @return the isMaxExtend
151
     */
152
    public boolean isMaxExtend() {
153
        return isMaxExtend;
154
    }
155

    
156
    /**
157
     * See {@link #isMaxExtend()}
158
     *
159
     * @param isMaxExtend the isMaxExtend to set
160
     */
161
    public void setMaxExtend(boolean isMaxExtend) {
162
        this.isMaxExtend = isMaxExtend;
163
    }
164

    
165

    
166
}
(7-7/9)