1 package org.codehaus.mojo.javascript.compress;
2
3 /*
4 * Copyright 2001-2005 The Apache Software Foundation.
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19 import java.io.File;
20
21 /**
22 * Abstraction of a JS compression tool.
23 */
24 public interface JSCompressor
25 {
26
27 /**
28 * Constants for optimization level
29 */
30 int NONE = 0;
31
32 int MAX = 9;
33
34 /**
35 * Javascript language versions
36 */
37 int JAVASCRIPT_1_1 = 110;
38
39 int JAVASCRIPT_1_2 = 120;
40
41 int JAVASCRIPT_1_3 = 130;
42
43 /**
44 * Set a the JSCompressorLogger implementation that will receive logs
45 * @param logger a logger
46 */
47 void setLogger(JSCompressorLogger logger)
48 throws CompressionException;
49
50 /**
51 * Return current JSCompressorLogger used for logging
52 * @return the current JSCompressorLogger used for logging
53 */
54 JSCompressorLogger getLogger()
55 throws CompressionException;
56
57 /**
58 * Compress the input script file into the output file (may be same).
59 *
60 * @param input source to get compressed
61 * @param output compressed script
62 * @param level optimization level from 0 to 9. May have various
63 * signification dependending on the compressor, from beeing ignored to some
64 * fine tweaking the output.
65 * @param language version of javascript to be used ("130" for JS 1.3), as
66 * defined by Mozilla Rhino engine
67 * @throws CompressionException any error during compression
68 */
69 void compress( File input, File output, int level, int language )
70 throws CompressionException;
71 }