Example usage for java.lang Class getPackage

List of usage examples for java.lang Class getPackage

Introduction

In this page you can find the example usage for java.lang Class getPackage.

Prototype

public Package getPackage() 

Source Link

Document

Gets the package of this class.

Usage

From source file:com.tojc.ormlite.android.compiler.AbstractAnnotationProcessorTest.java

protected File getResourceFile(Class<?> clazz) {
    return new File(getClass()
            .getResource("/" + toPath(clazz.getPackage()) + "/" + clazz.getSimpleName() + OUTPUT_FILE_SUFFIX)
            .getFile());//from w  ww .  ja  v  a  2 s .  c  o m
}

From source file:org.eclipse.gemini.blueprint.test.FilteringProbeBuilder.java

@Override
public TestProbeBuilder ignorePackageOf(Class<?>... classes) {
    for (Class<?> c : classes) {
        ignorePackages.add(c.getPackage().getName());
    }//  www.j  a v a2 s  .c  o m
    return this;
}

From source file:org.rimudb.editor.swing.OkCancelPanel.java

/** 
 * Register the UI Delegate //from   ww  w  .j  a  v  a 2  s  . co m
 */
protected ComponentUI registerUIDelegate() {
    ComponentUI compUI = null;

    Object obj = UIManager.get(uiClassID);
    if (obj == null) {
        // The default delegate class name
        Class basicDelegateClassName = org.rimudb.editor.swing.plaf.basic.BasicOkCancelPanelUI.class;
        String lafName = UIManager.getLookAndFeel().getID();

        // Look for a delegate for this LAF
        String packageName = basicDelegateClassName.getPackage().getName();
        int pos = packageName.indexOf("basic");
        String delegatePackageName = packageName.substring(0, pos);

        String lafDelegateClassName = delegatePackageName + lafName.toLowerCase() + "." + lafName
                + "OkCancelPanelUI";

        try {
            // Try the specific delegate
            compUI = (ComponentUI) (Class.forName(lafDelegateClassName)).newInstance();
        } catch (Exception e1) {
            try {
                // Default to the default delegate
                compUI = (ComponentUI) basicDelegateClassName.newInstance();
            } catch (Exception e2) {
                log.error("in OkCancelPanel.registerUIDelegate", e2);
            }
        }
    } else {
        compUI = (ComponentUI) obj;
    }
    return compUI;
}

From source file:es.logongas.ix3.util.FactoryHelper.java

private String getFQCNImplInSpecificPackage(Class entityClass, String domainBasePackageName,
        String implBasePackageName) {
    if ((domainBasePackageName != null) && (implBasePackageName != null)) {
        String packageName = entityClass.getPackage().getName().replace(domainBasePackageName,
                implBasePackageName);/*from   w  w  w.j  a v  a  2  s .c o m*/
        return packageName + "." + getImplClassName(entityClass);
    } else {
        return null;
    }

}

From source file:es.logongas.ix3.util.FactoryHelper.java

private String getFQCNImplInSubPackage(Class entityClass, String domainBasePackageName,
        String implBasePackageName) {
    if ((domainBasePackageName != null) && (implBasePackageName != null)) {
        String packageName = entityClass.getPackage().getName().replace(domainBasePackageName,
                implBasePackageName) + "." + implSubPackageName;
        return packageName + "." + getImplClassName(entityClass);
    } else {// w  ww  .  j  av  a2s . com
        return null;
    }

}

From source file:pl.baczkowicz.spy.xml.XMLParser.java

/**
 * Creates the XMLParser with the given class as root. No schema validation.
 * /*  w ww . j  ava  2s  . co  m*/
 * @param classToBeBound The class to be bound
 * 
 * @throws XMLException Thrown when cannot instantiate the marshaller/unmarshaller
 */
public XMLParser(final Class classToBeBound) throws XMLException {
    try {
        JAXBContext jc = JAXBContext.newInstance(classToBeBound.getPackage().getName());
        marshaller = jc.createMarshaller();
        unmarshaller = jc.createUnmarshaller();

    } catch (JAXBException e) {
        throw new XMLException("Cannot instantiate marshaller/unmarshaller for " + classToBeBound, e);
    }
}

From source file:gr.abiss.calipso.tiers.util.ModelContext.java

public ModelContext(ModelResource modelResource, Class<?> domainClass) {
    Assert.notNull(domainClass, "A domain class is required");
    String packageName = domainClass.getPackage().getName();
    this.beansBasePackage = packageName.endsWith(".model")
            ? packageName.substring(0, packageName.indexOf(".model"))
            : packageName;/*w  ww  .  ja v a  2  s.c o  m*/
    this.modelType = (Class<?>) domainClass;
    this.modelResource = modelResource;

    this.name = getPath(domainClass);
    this.apiAnnotationMembers = getApiAnnotationMembers(domainClass);
    this.path = "/" + name;

    this.generatedClassNamePrefix = domainClass.getSimpleName().replace("Model", "").replace("Entity", "");
    this.parentClass = null;
    this.parentProperty = null;

    this.modelIdType = EntityUtil.getIdType(domainClass);

}

From source file:es.logongas.ix3.util.FactoryHelper.java

private String getFQCNInterfaceInSpecificPackage(Class entityClass, String domainBasePackageName,
        String interfaceBasePackageName) {
    if ((domainBasePackageName != null) && (interfaceBasePackageName != null)) {
        String packageName = entityClass.getPackage().getName().replace(domainBasePackageName,
                interfaceBasePackageName);
        return packageName + "." + getInterfaceClassName(entityClass);
    } else {//from   w  ww .j  a  v  a 2s  .  c  o  m
        return null;
    }

}

From source file:org.wings.plaf.css.AbstractComponentCG.java

/**
 * Install the appropriate CG for <code>component</code>.
 *
 * @param component the component//from w  w  w. ja  v a2s  . c om
 */
public void installCG(COMPONENT_TYPE component) {
    Class clazz = component.getClass();
    while (clazz.getPackage() == null || !("org.wings".equals(clazz.getPackage().getName())
            || "org.wingx".equals(clazz.getPackage().getName())))
        clazz = clazz.getSuperclass();
    String style = clazz.getName();
    style = style.substring(style.lastIndexOf('.') + 1);
    component.setStyle(style); // set default style name to component class (ie. SLabel).
    component.setBorder(SDefaultBorder.INSTANCE); // the default style writes _no_ attributes, thus the stylesheet is in effect

    if (Utils.isMSIE(component)) {
        final CGManager manager = component.getSession().getCGManager();
        Object value;
        int verticalOversize = 0;
        value = manager.getObject(style + ".verticalOversize", Integer.class);
        if (value != null)
            verticalOversize = ((Integer) value).intValue();
        int horizontalOversize = 0;
        value = manager.getObject(style + ".horizontalOversize", Integer.class);
        if (value != null)
            horizontalOversize = ((Integer) value).intValue();

        if (verticalOversize != 0 || horizontalOversize != 0)
            component.putClientProperty("oversize", new SEmptyBorder(verticalOversize, horizontalOversize,
                    verticalOversize, horizontalOversize));
    }
}

From source file:org.codehaus.enunciate.modules.xfire_client.EnunciatedClientOperationBinding.java

/**
 * Loads the set of input properties for the specified operation.
 *
 * @param op The operation.//  w  ww. jav  a2 s.c o m
 * @return The input properties, or null if the request info wasn't found.
 */
protected OperationBeanInfo getRequestInfo(OperationInfo op) throws XFireFault {
    Method method = op.getMethod();
    Class ei = method.getDeclaringClass();
    Package pckg = ei.getPackage();

    if ((this.annotations.hasSOAPBindingAnnotation(method))
            && (this.annotations.getSOAPBindingAnnotation(method)
                    .getParameterStyle() == SOAPBindingAnnotation.PARAMETER_STYLE_BARE)) {
        //bare method...
        return new OperationBeanInfo(method.getParameterTypes()[0], null);
    } else {
        String requestWrapperClassName;
        RequestWrapperAnnotation requestWrapperInfo = this.annotations.getRequestWrapperAnnotation(method);
        if ((requestWrapperInfo != null) && (requestWrapperInfo.className() != null)
                && (requestWrapperInfo.className().length() > 0)) {
            requestWrapperClassName = requestWrapperInfo.className();
        } else {
            StringBuffer builder = new StringBuffer(pckg == null ? "" : pckg.getName());
            if (builder.length() > 0) {
                builder.append(".");
            }

            builder.append("jaxws.");

            String methodName = method.getName();
            builder.append(PropertyUtil.capitalize(methodName));
            requestWrapperClassName = builder.toString();
        }

        Class wrapperClass;
        try {
            wrapperClass = ClassLoaderUtils.loadClass(requestWrapperClassName, getClass());
        } catch (ClassNotFoundException e) {
            LOG.error("Unabled to find request wrapper class " + requestWrapperClassName + "... Operation "
                    + op.getQName() + " will not be able to send...");
            return null;
        }

        return new OperationBeanInfo(wrapperClass, loadOrderedProperties(wrapperClass));
    }
}