Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
*
* 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.
*
*/
package flex2.tools.oem;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
import java.lang.annotation.Annotation;
import java.net.URI;
import org.apache.royale.compiler.clients.COMPJSC;
import org.apache.royale.compiler.clients.problems.ProblemFormatter;
import org.apache.royale.compiler.clients.problems.ProblemQuery;
import org.apache.royale.compiler.problems.CompilerProblemSeverity;
import org.apache.royale.compiler.problems.ICompilerProblem;
import org.apache.royale.compiler.problems.annotations.DefaultSeverity;
import flex2.compiler.CompilerException;
import flex2.compiler.Source;
import flex2.compiler.SourceList;
import flex2.compiler.common.CompilerConfiguration;
import flex2.compiler.config.ConfigurationException;
import flex2.compiler.io.FileUtil;
import flex2.compiler.io.LocalFile;
import flex2.compiler.io.VirtualFile;
import flex2.compiler.util.Benchmark;
import flex2.compiler.util.CompilerControl;
import flex2.compiler.util.CompilerMessage;
import flex2.compiler.util.MimeMappings;
import flex2.compiler.util.PerformanceData;
import flex2.compiler.util.ThreadLocalToolkit;
import flex2.linker.SimpleMovie;
import flex2.tools.oem.internal.ApplicationCompilerConfiguration;
import flex2.tools.oem.internal.LibraryCompilerConfiguration;
import flex2.tools.oem.internal.OEMConfiguration;
import flex2.tools.oem.internal.OEMReport;
import flex2.tools.oem.internal.OEMUtil;
/**
* The Library class represents a SWC archive or a RSL. It implements the Builder interface
* which allows for building the library incrementally. The following example defines a SWC archive or RSL:
*
*
* Library lib = new Library();
*
*
* You can add components to the Library object in the following ways:
*
*
* 1. String - Specify a fully-qualified name.
* 2. File - Specify a source file.
* 3. VirtualLocalFile - Specify an in-memory source object.
* 4. URI - Specify a namespace URI.
*
*
*
* To add resource bundles to the Library, you can use the addResourceBundle() method,
* as the following example shows:
*
*
* lib.addResourceBundle("mx.controls"));
*
*
*
* To add archive files to the Library, you can use the addArchiveFile() method, as the following
* example shows:
*
*
* lib.addArchiveFile("defaults.css", new File("path1/myStyle.css"));
*
*
* Before you can compile with a Library object, you must configure it. The following
* four methods are the most common methods you use to configure the Library object:
*
*
* 1. setLogger() - Use this to set a Logger so that the client can be notified of events that occurred during the compilation.
* 2. setConfiguration() - Optional. Use this to specify compiler options.
* 3. setOutput() - Optional. Use this to specify an output file name.
* 4. setDirectory() - Optional. Use this to specify an RSL output directory.
*
*
* You must implement the flex2.tools.oem.Logger interface and use the implementation as the Logger
* for the compilation. The following is an example Logger implementation:
*
*
*
* To specify compiler options for the Library object, you
* must get a Configuration object that is populated with default values. Then, you set
* compiler options programmatically using methods of the Configuration class.
*
*
* The setOutput() method lets you specify where the Library object writes
* the output to. If you call the setOutput() method, the build(boolean) method
* writes directly to the specified location; for example:
*
*
*
* If you do not call the setOutput() method, you can use the build(OutputStream, boolean)
* method. This requires that you provide a buffered output stream; for example:
*
*
*
* You can save the Library object compilation
* data for reuse. You do this using the save(OutputStream) method. Subsequent compilations can use
* the load(OutputStream) method to get the old data into the Library object; for example:
*
*
*
* When a cache file (for example, MyLib.incr) from a previous compilation is available before the
* compilation, you can call the load(OutputStream) method before you call the build() method; for example:
*
*
*
* The build(false) and build(OutputStream, false) methods always rebuild the library.
* The first time you build the Library
* object, the build(true)/build(OutputStream, true) methods do a complete build, which
* is equivalent to the build(false)/build(OutputStream, false) methods, respectively. After you call the
* clean() method, the Library object always does a full build.
*
*
* The clean() method cleans up compilation data in the Library object the output
* file, if the setOutput() method was called.
*
*
* You can use the Library class to build a library from a combination of source
* files in the file system and in-memory, dynamically-generated source objects. You
* must use the addComponent(VirtualLocalFile), addResourceBundle(VirtualLocalFile), and
* addArchiveFile(String, VirtualLocalFile) methods to use in-memory objects.
*
*
* The Library class can be part of a Project.
*
* @see flex2.tools.oem.Configuration
* @see flex2.tools.oem.Project
* @version 2.0.1
* @author Clement Wong
*/
public class Library implements Builder, Cloneable
{
static
{
// This "should" trigger the static initialization of Application which locates
// flex-compiler-oem.jar and set application.home correctly.
try
{
// in Java 1.4, simply saying Application.class would load the class
// Java 1.5 is much smarter, and you have to coax the JVM to actually load it
Class.forName("flex2.tools.oem.Application");
}
catch (ClassNotFoundException e)
{
// I guess it didn't work *shrug*
e.printStackTrace();
assert false;
}
}
/**
* Constructor.
*/
public Library()
{
sources = new TreeSet(new Comparator()
{
public int compare(VirtualFile f0, VirtualFile f1)
{
return f0.getName().compareTo(f1.getName());
}
});
classes = new TreeSet();
namespaces = new TreeSet();
resourceBundles = new TreeSet();
files = new TreeMap();
stylesheets = new TreeMap();
oemConfiguration = null;
logger = null;
output = null;
directory = null;
mimeMappings = new MimeMappings();
meter = null;
resolver = null;
cc = new CompilerControl();
//data = null;
cacheName = null;
configurationReport = null;
messages = new ArrayList();
}
private Set sources;
private Set classes, resourceBundles;
private Set namespaces;
private Map files, stylesheets;
private OEMConfiguration oemConfiguration;
private Logger logger;
private File output, directory;
private MimeMappings mimeMappings;
private ProgressMeter meter;
protected PathResolver resolver;
private CompilerControl cc;
private ApplicationCache applicationCache;
private LibraryCache libraryCache;
private List