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: ClassDef
* Owner: OMEX AG, Switzerland, http://www.omex.ch
* ====================================================================
*
* This software is published under the BSD license as listed below.
*
* Copyright (c) 2004-2014, 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.mapping.cci;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Set;
import org.openmdx.base.exception.ServiceException;
import org.openmdx.base.mof.cci.ModelElement_1_0;
import org.openmdx.base.mof.cci.Model_1_0;
import org.openmdx.base.mof.cci.Stereotypes;
import org.openmdx.base.naming.Path;
@SuppressWarnings("rawtypes")
public class ClassDef
extends ClassifierDef {
//-------------------------------------------------------------------------
public ClassDef(
ModelElement_1_0 classDef,
Model_1_0 model
) throws ServiceException {
this(
classDef,
model,
false, // lazySuperTypes
null // metaData
);
}
public ClassDef(
ModelElement_1_0 classDef,
Model_1_0 model,
MetaData_1_0 metaData
) throws ServiceException {
this(
classDef,
model,
false, // lazySuperTypes
metaData
);
}
@SuppressWarnings("unchecked")
private ClassDef(
ModelElement_1_0 classDef,
Model_1_0 model,
boolean lazySuperTypes,
MetaData_1_0 metaData
) throws ServiceException {
this(
classDef.getName(),
classDef.getQualifiedName(),
(String)classDef.objGetValue("annotation"),
new HashSet(classDef.objGetList("stereotype")),
classDef.isAbstract().booleanValue(),
lazySuperTypes ? null : getSuperTypes(classDef, model, metaData),
classDef.objGetList("allSupertype"),
lazySuperTypes ? classDef : null,
lazySuperTypes ? model : null,
metaData
);
}
//-------------------------------------------------------------------------
public boolean isInstanceOf(
String qualifiedName
){
for(
ListIterator i = this.allSupertypes.listIterator();
i.hasNext();
){
if (((Path) i.next()).getLastSegment().toClassicRepresentation().equals(qualifiedName)) {
return true;
}
}
return false;
}
//-------------------------------------------------------------------------
@SuppressWarnings("unchecked")
private static List getSuperTypes(
ModelElement_1_0 classDef,
Model_1_0 model,
MetaData_1_0 metaData
) throws ServiceException {
List supertypes = new ArrayList();
for(
Iterator it = classDef.objGetList("supertype").iterator();
it.hasNext();
) {
ModelElement_1_0 supertype = model.getDereferencedType(it.next());
supertypes.add(
new ClassDef(
supertype,
model,
true, // lazySuperTypes
metaData
)
);
}
return supertypes;
}
//-------------------------------------------------------------------------
private ClassDef(
String name,
String qualifiedName,
String annotation,
Set stereotype,
boolean isAbstract,
List supertypes,
List