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.
/*
* ====================================================================
* Project: openmdx, http://www.openmdx.org/
* Description: XMI2 Reference Resolver
* Owner: OMEX AG, Switzerland, http://www.omex.ch
* ====================================================================
*
* This software is published under the BSD license
* as listed below.
*
* Copyright (c) 2004-2005, OMEX AG, Switzerland
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* * Neither the name of the openMDX team nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* ------------------
*
* This product includes software developed by the Apache Software
* Foundation (http://www.apache.org/).
*/
package org.openmdx.application.mof.externalizer.xmi;
import java.io.PrintStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.Map;
import java.util.Stack;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.openmdx.application.mof.externalizer.xmi.uml1.UML1AssociationEnd;
import org.openmdx.application.mof.externalizer.xmi.uml1.UML1Comment;
import org.openmdx.application.mof.externalizer.xmi.uml1.UML1Generalization;
import org.openmdx.application.mof.externalizer.xmi.uml1.UML1TagDefinition;
import org.openmdx.base.exception.ServiceException;
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
public class XMI2ReferenceResolver
implements ContentHandler, XMIReferenceResolver {
//---------------------------------------------------------------------------
public XMI2ReferenceResolver(
Map xmiReferences,
Stack scope,
Map pathMap,
PrintStream infos,
PrintStream warnings,
PrintStream errors,
Map umlAssociationEnds
) {
this.xmiReferences = xmiReferences;
this.umlAssociationEnds = umlAssociationEnds;
this.scope = scope;
this.pathMap = pathMap;
this.infos = infos;
this.warnings = warnings;
this.errors = errors;
this.projects = new HashMap();
}
/**
* Get href as URI.
*
* @param href
* @return
*/
public URI hrefToURI(
String href
) {
URI hrefURI = null;
String schema = null;
String value = null;
try {
value = href;
value = value.replace(" ", "%20");
// Convert relative paths to platform resource paths
schema = "";
while(value.startsWith("../") || value.startsWith("..\\")) {
value = value.substring(3);
schema = "platform:/resource/";
}
hrefURI = new URI(schema + value);
} catch(URISyntaxException e) {
this.error("Reference is not a valid URI >" + schema + value + "<");
}
return hrefURI;
}
/**
* Retrieves the fully qualified name of the model element identified by a
* given xmiId.
*
* @param xmiId the xmi.id that identifies desired model element
* @return the fully qualified name of the model element
*/
public String lookupXMIId(
String xmiId
) {
return this.xmiReferences.get(xmiId);
}
/* (non-Javadoc)
* @see org.openmdx.application.mof.externalizer.xmi.XMIReferenceResolver#lookupGeneralization(java.lang.String)
*/
@Override
public UML1Generalization lookupGeneralization(
String xmiId
) {
return null;
}
/* (non-Javadoc)
* @see org.openmdx.application.mof.externalizer.xmi.XMIReferenceResolver#lookupComment(java.lang.String)
*/
@Override
public UML1Comment lookupComment(
String xmiId
) {
return null;
}
/* (non-Javadoc)
* @see org.openmdx.application.mof.externalizer.xmi.XMIReferenceResolver#lookupTagDefinition(java.lang.String)
*/
@Override
public UML1TagDefinition lookupTagDefinition(
String xmiId
) {
return null;
}
/* (non-Javadoc)
* @see org.openmdx.application.mof.externalizer.xmi.XMIReferenceResolver#lookupAssociationEnd(java.lang.String)
*/
@Override
public UML1AssociationEnd lookupAssociationEnd(
String xmiId
) {
return this.umlAssociationEnds == null ? null : this.umlAssociationEnds.get(xmiId);
}
/* (non-Javadoc)
* @see org.openmdx.application.mof.externalizer.xmi.XMIReferenceResolver#lookupProject(java.lang.String)
*/
@Override
public String lookupProject(
String packageName
) {
return this.projects.get(packageName);
}
/* (non-Javadoc)
* @see org.xml.sax.ContentHandler#startDocument()
*/
@Override
public void startDocument(
) throws SAXException {
this.hasErrors = false;
this.elementStack = this.umlAssociationEnds == null ? null : new Stack