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:
020: package org.netbeans.modules.bpel.project;
021:
022: import java.io.File;
023:
024: import java.net.URI;
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: */
033: public class CommandlineBpelProjectXmlCatalogProvider {
034:
035: private String mCatalogXMLPath = null;
036: private String mRetreiverPath = null;
037: private URI mCatalogXMLURI = null;
038: private String mSourceDir = null;
039: private static CommandlineBpelProjectXmlCatalogProvider mInstance = null;
040: private URI mCatlogXMLLocationForWizardURI = null;
041:
042: CommandlineBpelProjectXmlCatalogProvider() {
043: }
044:
045: /**
046: * Singleton
047: * @return The current instance
048: */
049: public static CommandlineBpelProjectXmlCatalogProvider getInstance() {
050: if (mInstance == null) {
051: mInstance = new CommandlineBpelProjectXmlCatalogProvider();
052: }
053: return mInstance;
054: }
055:
056: /**
057: * Set the source directory
058: * @param sourceDir Source directory
059: */
060: public void setSourceDirectory(String sourceDir) {
061: mSourceDir = sourceDir;
062: String projectDir = mSourceDir + File.separator + ".."
063: + File.separator;
064: String catalogXMLDir = projectDir
065: + org.netbeans.modules.xml.retriever.XMLCatalogProvider.TYPE_RETRIEVED;
066: mCatalogXMLPath = (catalogXMLDir + File.separator + "catalog.xml")
067: .replace('\\', '/');
068: ;
069: mRetreiverPath = (catalogXMLDir + File.separator + "src")
070: .replace('\\', '/');
071:
072: mCatlogXMLLocationForWizardURI = new File((projectDir
073: + File.separator + "catalog.xml").replace('\\', '/'))
074: .toURI();
075: mCatalogXMLURI = new File(mCatalogXMLPath).toURI();
076: }
077:
078: /**
079: * Set the catalog xml location
080: * @param catalogXMLPath Catalog XML location
081: */
082: public void setCatalogXMLPath(String catalogXMLPath) {
083: mCatalogXMLPath = catalogXMLPath;
084: }
085:
086: /**
087: * Get the Retriever download location
088: * @return Get the Retriever download location
089: */
090: public String getRetrieverPath() {
091: return mRetreiverPath;
092: }
093:
094: /**
095: * Get the project wide Catalog
096: * @return Location of Project wide catalog
097: */
098: public URI getProjectWideCatalog() {
099: return mCatalogXMLURI;
100: }
101:
102: public URI getProjectWideCatalogForWizard() {
103: return mCatlogXMLLocationForWizardURI;
104: }
105:
106: }
|