001: /*
002: * The contents of this file are subject to the terms of the Common Development
003: * and Distribution License (the License). You may not use this file except in
004: * compliance with the License.
005: *
006: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
007: * or http://www.netbeans.org/cddl.txt.
008: *
009: * When distributing Covered Code, include this CDDL Header Notice in each file
010: * and include the License file at http://www.netbeans.org/cddl.txt.
011: * If applicable, add the following below the CDDL Header, with the fields
012: * enclosed by brackets [] replaced by your own identifying information:
013: * "Portions Copyrighted [year] [name of copyright owner]"
014: *
015: * The Original Software is NetBeans. The Initial Developer of the Original
016: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
017: * Microsystems, Inc. All Rights Reserved.
018: */
019: package org.netbeans.modules.xslt.project;
020:
021: import java.io.File;
022:
023: import java.net.URI;
024:
025: /**
026: *
027: * Basic Java class representing the XML Catalog Provider. This class is
028: * used by both in Populate Catalog Wizard and in Ant task for project building.
029: * The reason for creation of this class is to eliminate the netbeans
030: * dependency XMLCatalogProvider has on Project API( FileObject)
031: * @author Sreenivasan Genipudi
032: * @author Vitaly Bychkov
033: * @version 1.0
034: */
035: public class CommandlineXsltProjectXmlCatalogProvider {
036:
037: private String mCatalogXMLPath = null;
038: private String mRetreiverPath = null;
039: private URI mCatalogXMLURI = null;
040: private String mSourceDir = null;
041: private static CommandlineXsltProjectXmlCatalogProvider mInstance = null;
042: private URI mCatlogXMLLocationForWizardURI = null;
043:
044: CommandlineXsltProjectXmlCatalogProvider() {
045: }
046:
047: /**
048: * Singleton
049: * @return The current instance
050: */
051: public static CommandlineXsltProjectXmlCatalogProvider getInstance() {
052: if (mInstance == null) {
053: mInstance = new CommandlineXsltProjectXmlCatalogProvider();
054: }
055: return mInstance;
056: }
057:
058: /**
059: * Set the source directory
060: * @param sourceDir Source directory
061: */
062: public void setSourceDirectory(String sourceDir) {
063: mSourceDir = sourceDir;
064: String projectDir = mSourceDir + File.separator + ".."
065: + File.separator;
066: String catalogXMLDir = projectDir
067: + org.netbeans.modules.xml.retriever.XMLCatalogProvider.TYPE_RETRIEVED;
068: mCatalogXMLPath = (catalogXMLDir + File.separator + "catalog.xml")
069: .replace('\\', '/');
070: ;
071: mRetreiverPath = (catalogXMLDir + File.separator + "src")
072: .replace('\\', '/');
073:
074: mCatlogXMLLocationForWizardURI = new File((projectDir
075: + File.separator + "catalog.xml").replace('\\', '/'))
076: .toURI();
077: mCatalogXMLURI = new File(mCatalogXMLPath).toURI();
078: }
079:
080: /**
081: * Set the catalog xml location
082: * @param catalogXMLPath Catalog XML location
083: */
084: public void setCatalogXMLPath(String catalogXMLPath) {
085: mCatalogXMLPath = catalogXMLPath;
086: }
087:
088: /**
089: * Get the Retriever download location
090: * @return Get the Retriever download location
091: */
092: public String getRetrieverPath() {
093: return mRetreiverPath;
094: }
095:
096: /**
097: * Get the project wide Catalog
098: * @return Location of Project wide catalog
099: */
100: public URI getProjectWideCatalog() {
101: return mCatalogXMLURI;
102: }
103:
104: public URI getProjectWideCatalogForWizard() {
105: return mCatlogXMLLocationForWizardURI;
106: }
107:
108: }
|