Example usage for java.lang Package getName

List of usage examples for java.lang Package getName

Introduction

In this page you can find the example usage for java.lang Package getName.

Prototype

public String getName() 

Source Link

Document

Return the name of this package.

Usage

From source file:com.link_intersystems.lang.reflect.Class2.java

/**
 * The string representation of a {@link Class2}.
 *
 * <ul>/*from w  w w  . jav  a 2s . c  o m*/
 * <li>
 * Types are represented by their canonical name. If a type is a
 * &quot;well-known&quot; type (all types in java.lang) the type's simple
 * name is used. E.g. String - java.util.List.</li>
 * <ul>
 * <li>
 * Arrays are represented by their type and appended by []. E.g. int[]
 * String[] java.beans.PropertyDescriptor[].</li>
 *
 * @param wellKnownPackages
 *            packages that are &quot;well known&quot; will not be printed
 *            in the string representation. E.g. if java.lang is defined as
 *            well known the Class2 that represents a String class will be
 *            printed just as &quot;String&quot; and not java.lang.String.
 *
 * @return a string representation of this {@link Class2};
 * @since 1.0.0.0
 */
public String toString(String... wellKnownPackages) {
    Assert.notNull("wellKnownPackages", wellKnownPackages);
    StringBuilder toStringBuilder = new StringBuilder();
    Class<?> clazz = getType();
    boolean isArray = clazz.isArray();
    if (isArray) {
        clazz = clazz.getComponentType();
    }
    Package clazzPackage = clazz.getPackage();
    String packageName = StringUtils.EMPTY;
    if (clazzPackage != null) {
        packageName = clazzPackage.getName();
    }

    boolean isWellKnownPackage = Arrays.binarySearch(wellKnownPackages, packageName) > -1;

    if (isWellKnownPackage) {
        toStringBuilder.append(clazz.getSimpleName());
    } else {
        toStringBuilder.append(clazz.getCanonicalName());
    }

    TypeVariable<?>[] typeParameters = clazz.getTypeParameters();
    String typeParametersToString = typeParametersToString(typeParameters);
    toStringBuilder.append(typeParametersToString);

    if (isArray) {
        toStringBuilder.append("[]");
    }
    return toStringBuilder.toString();
}

From source file:de.uzk.hki.da.model.ObjectPremisXmlWriter.java

/**
 * Creates the package element.//w  w w .  ja v  a2  s  .c o  m
 *
 * @param o the o
 * @param pkg the pkg
 * @throws XMLStreamException the xML stream exception
 */
private void createPackageElement(Object o, Package pkg) throws XMLStreamException {
    createOpenElement("object", 1);
    createAttribute(C.XSI_NS, "type", "representation");
    createOpenElement("objectIdentifier", 2);
    createTextElement("objectIdentifierType", "PACKAGE_NAME", 3);
    createTextElement("objectIdentifierValue", o.getIdentifier() + ".pack_" + pkg.getName() + ".tar", 3);
    createCloseElement(2);
    createTextElement("originalName", pkg.getContainerName(), 2);
    createCloseElement(1);
}

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

/**
 * Loads the set of output properties for the specified operation.
 *
 * @param op The operation./*from   w  w  w  .j av a 2  s . c om*/
 * @return The output properties.
 */
protected OperationBeanInfo getResponseInfo(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.getReturnType(), null);
    } else {
        String responseWrapperClassName;
        ResponseWrapperAnnotation responseWrapperInfo = annotations.getResponseWrapperAnnotation(method);
        if ((responseWrapperInfo != null) && (responseWrapperInfo.className() != null)
                && (responseWrapperInfo.className().length() > 0)) {
            responseWrapperClassName = responseWrapperInfo.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)).append("Response");
            responseWrapperClassName = builder.toString();
        }

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

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

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 w  w. j  av a 2s.  c  om*/
 * @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));
    }
}

From source file:com.phonegap.DroidGap.java

/**
 * Create and initialize web container.//from w  w w.  j  a  va  2 s .  c o  m
 */
public void init() {

    // Create web container
    this.appView = new WebView(DroidGap.this);
    this.appView.setId(100);

    this.appView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT, 1.0F));

    WebViewReflect.checkCompatibility();

    if (android.os.Build.VERSION.RELEASE.startsWith("2.")) {
        this.appView.setWebChromeClient(new EclairClient(DroidGap.this));
    } else {
        this.appView.setWebChromeClient(new GapClient(DroidGap.this));
    }

    this.setWebViewClient(this.appView, new GapViewClient(this));

    this.appView.setInitialScale(100);

    this.appView.setHorizontalScrollbarOverlay(false);
    this.appView.setVerticalScrollbarOverlay(false);
    this.appView.setVerticalScrollBarEnabled(false);
    this.appView.setHorizontalScrollBarEnabled(false);
    this.appView.requestFocusFromTouch();

    /*
    this.appView.setOnTouchListener(new View.OnTouchListener() {
            public boolean onTouch(View v, MotionEvent event) {
                return(event.getAction() == MotionEvent.ACTION_MOVE);
            }
    });
    */

    // Enable JavaScript
    WebSettings settings = this.appView.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setJavaScriptCanOpenWindowsAutomatically(true);
    settings.setLayoutAlgorithm(LayoutAlgorithm.NORMAL);

    // Enable database
    Package pack = this.getClass().getPackage();
    String appPackage = pack.getName();
    WebViewReflect.setStorage(settings, true, "/data/data/" + appPackage + "/app_database/");

    // Enable DOM storage
    WebViewReflect.setDomStorage(settings);

    // Enable built-in geolocation
    WebViewReflect.setGeolocationEnabled(settings, true);

    // Bind PhoneGap objects to JavaScript
    this.bindBrowser(this.appView);

    // Add web view
    root.addView(this.appView);
    setContentView(root);

    // Clear cancel flag
    this.cancelLoadUrl = false;

    // If url specified, then load it
    String url = this.getStringProperty("url", null);
    if (url != null) {
        System.out.println("Loading initial URL=" + url);
        this.loadUrl(url);
    }
}

From source file:de.interactive_instruments.ShapeChange.Model.EA.EADocument.java

public void executeCommonInitializationProcedure() throws ShapeChangeAbortException {

    // determine if specific packages should not be loaded
    this.excludedPackageNames = options.getExcludedPackages();

    /** Cache classes and packages */
    // First set up initial evaluation tasks of packages consisting
    // of the models in the repository
    class EvalTask {
        PackageInfoEA fatherPI;/*from w  ww  . j ava  2 s  . co  m*/
        org.sparx.Package eaPackage;

        EvalTask(PackageInfoEA fpi, org.sparx.Package p) {
            fatherPI = fpi;
            eaPackage = p;
        }
    }

    StatusBoard.getStatusBoard().statusChanged(STATUS_EADOCUMENT_READMODEL);

    LinkedList<EvalTask> evalp = new LinkedList<EvalTask>();
    Collection<org.sparx.Package> model = repository.GetModels();
    for (org.sparx.Package p : model) {

        // Check if this model and all its contents shall be excluded
        String name = p.GetName();
        if (excludedPackageNames != null && excludedPackageNames.contains(name)) {
            // stop processing this model and continue with the next
            continue;
        }

        evalp.addLast(new EvalTask(null, p));
    }

    // Now remove tasks from the list, adding further tasks as we proceed
    // until we have no more tasks to evaluate
    while (evalp.size() > 0) {
        // Remove next evaluation task
        EvalTask et = evalp.removeFirst();
        org.sparx.Package pack = et.eaPackage;
        PackageInfoEA fpi = et.fatherPI;

        // Check if this package and all its contents shall be excluded from
        // the model
        String name = pack.GetName();
        if (excludedPackageNames != null && excludedPackageNames.contains(name)) {
            // stop processing this package and continue with the next
            continue;
        }

        // Add to package cache. The PackageInfo Ctor does the necessary
        // parent/child linkage of packages
        Element packelmt = pack.GetElement();
        PackageInfoEA pi = new PackageInfoEA(this, fpi, pack, packelmt);
        fPackageById.put(pi.id(), pi);
        if (packelmt != null)
            this.fPackageByElmtId.put(new Integer(packelmt.GetElementID()).toString(), pi);
        // Now pick all classes and add these to their to caches.
        for (org.sparx.Element elmt : pack.GetElements()) {
            String type = elmt.GetType();
            if (!type.equals("DataType") && !type.equals("Class") && !type.equals("Interface")
                    && !type.equals("Enumeration"))
                continue;
            ClassInfoEA ci = new ClassInfoEA(this, pi, elmt);
            fClassById.put(ci.id(), ci);
            // TODO What's happening to identical class names? How is this
            // supposed to be handled? Open issue.While classifier names
            // have to be
            // unique per app schema only, it is a legacy from Rational Rose
            // that it is expected that classifier names are unique in the
            // whole
            // model. The correct solution would be to add namespace
            // qualifiers.
            fClassByName.put(ci.name(), ci);
        }
        // Add next level packages for further evaluation
        for (org.sparx.Package pnxt : pack.GetPackages()) {
            evalp.addLast(new EvalTask(pi, pnxt));
        }
    }

    StatusBoard.getStatusBoard().statusChanged(STATUS_EADOCUMENT_ESTABLISHCLASSES);

    /**
     * Now that all classes are collected, in a second go establish class
     * derivation hierarchy and all other associations between classes.
     */
    for (ClassInfoEA ci : fClassById.values()) {

        // Generalization - class derivation hierarchy
        ci.establishClassDerivationHierarchy();
        // Other associations where the class is source or target
        ci.establishAssociations();
    }

    String checkingConstraints = options.parameter("checkingConstraints");
    if (checkingConstraints == null || !checkingConstraints.toLowerCase().trim().equals("disabled")) {
        StatusBoard.getStatusBoard().statusChanged(STATUS_EADOCUMENT_READCONSTARINTS);

        // TODO The following may be removed when constraints have been
        // tested.
        /** In a third go collect all constraints */
        for (ClassInfoEA ci : fClassById.values()) {
            ci.constraints();
            SortedMap<StructuredNumber, PropertyInfo> props = ci.properties();
            for (PropertyInfo pi : props.values())
                pi.constraints();
        }
    }

    /**
     * Loop over all schemas (i.e packages with a target namespace) and
     * store the schema location, so that it can be added in import
     * statements
     */
    SortedSet<PackageInfo> schemas = schemas("");
    for (Iterator<PackageInfo> i = schemas.iterator(); i.hasNext();) {
        PackageInfo pi = i.next();
        options.addSchemaLocation(pi.targetNamespace(), pi.xsdDocument());
    }

    // ==============================
    // load diagrams if so requested
    String loadDiagrams = options.parameter("loadDiagrams");

    if (loadDiagrams != null && loadDiagrams.equalsIgnoreCase("true")) {

        java.io.File tmpDir = options.imageTmpDir();

        if (tmpDir.exists()) {

            // probably content from previous run, delete the content of the directory
            try {
                FileUtils.deleteDirectory(tmpDir);
            } catch (IOException e) {
                result.addWarning(null, 34, tmpDir.getAbsolutePath());
            }

            if (!tmpDir.exists()) {
                try {
                    FileUtils.forceMkdir(tmpDir);
                } catch (IOException e) {
                    result.addWarning(null, 32, tmpDir.getAbsolutePath());
                }
            }
        }

        AtomicInteger imgIdCounter = new AtomicInteger(0);

        SortedSet<? extends PackageInfo> selectedSchema = this.selectedSchemas();

        for (PackageInfo pi : selectedSchema) {

            if (pi == null) {
                continue;
            }

            // Only process schemas in a namespace and name that matches a
            // user-selected pattern
            if (options.skipSchema(null, pi))
                continue;

            saveDiagrams(imgIdCounter, "img", tmpDir, escapeFileName(tmpDir.getName()), pi);
        }
    }

}

From source file:org.talend.repository.hcatalog.ui.HCatalogTableSelectorForm.java

private void refreshExistItem(final MetadataTable existTable, final TreeItem item) {
    Display.getDefault().syncExec(new Runnable() {

        @Override//from   w ww.  j a v  a 2 s  .  c om
        public void run() {
            orgomg.cwm.objectmodel.core.Package pack = (orgomg.cwm.objectmodel.core.Package) existTable
                    .eContainer();
            boolean confirm = MessageDialog.openConfirm(Display.getDefault().getActiveShell(),
                    Messages.getString("HCatalogTableSelectorForm.title.confirm"), //$NON-NLS-1$
                    Messages.getString("HCatalogTableSelectorForm.tableIsExist", existTable.getLabel(), //$NON-NLS-1$
                            pack.getName()));
            if (confirm) {
                TreeItem existItem = getExistItem(existTable);
                if (existItem != null) {
                    clearTreeItem(existItem);
                    existItem.setChecked(false);
                }
                item.setText(2, Messages.getString("HCatalogTableSelectorForm.Pending")); //$NON-NLS-1$
                countPending++;
                parentWizardPage.setPageComplete(false);
                refreshTable(item, -1);
            } else {
                item.setChecked(false);
                boolean hasCheckedItem = false;
                TreeItem parentItem = item.getParentItem();
                if (parentItem != null) {
                    for (TreeItem i : parentItem.getItems()) {
                        if (i.getChecked()) {
                            hasCheckedItem = true;
                            break;
                        }
                    }
                }
                if (!hasCheckedItem && parentItem != null) {
                    parentItem.setChecked(false);
                }
            }
        }
    });
}

From source file:org.apache.axis2.description.java2wsdl.DefaultSchemaGenerator.java

protected String getQualifiedName(Package packagez) {
    if (packagez != null) {
        return packagez.getName();
    } else {/*from  ww  w . ja  va2s .c  o m*/
        return "";
    }
}

From source file:de.uzk.hki.da.model.ObjectPremisXmlWriter.java

/**
 * @param object//w  ww  .j a v  a2 s  .com
 * @throws XMLStreamException
 * @throws  
 */
private void generateEvents(Object object) throws XMLStreamException {
    for (Package pkg : object.getPackages())
        for (Event e : pkg.getEvents()) {

            if (e.getType().toUpperCase().equals(C.EVENT_TYPE_CONVERT)
                    || e.getType().toUpperCase().equals(C.EVENT_TYPE_COPY)
                    || e.getType().toUpperCase().equals(C.EVENT_TYPE_CREATE)
                    || e.getType().toUpperCase().equals(C.EVENT_TYPE_CONVERSION_SUPRESSED)) {
                logger.debug("Serializing convert event: " + e);
                createConvertEventElement(e);
            } else
            // DANRW-1452: Event virus-scan
            if (e.getType().toUpperCase().equals(C.EVENT_TYPE_VIRUS_SCAN)) {
                logger.debug("Serializing scan event: " + e);
                createVirusEventElement(object, pkg.getName(), e);
            } else {
                logger.debug("Serializing package event:" + e);
                createPackageEventElement(object, pkg, e);
            }
        }
}

From source file:org.codehaus.enunciate.modules.xfire.EnunciatedJAXWSOperationBinding.java

/**
 * Loads the set of output properties for the specified operation.
 *
 * @param op The operation.//from   w w  w. j a va  2 s.  com
 * @return The output properties.
 */
protected OperationBeanInfo getResponseInfo(OperationInfo op) throws XFireFault {
    Method method = op.getMethod();
    Class ei = method.getDeclaringClass();
    Package pckg = ei.getPackage();
    SOAPBinding.ParameterStyle paramStyle = SOAPBinding.ParameterStyle.WRAPPED;
    if (method.isAnnotationPresent(SOAPBinding.class)) {
        SOAPBinding annotation = method.getAnnotation(SOAPBinding.class);
        paramStyle = annotation.parameterStyle();
    } else if (ei.isAnnotationPresent(SOAPBinding.class)) {
        SOAPBinding annotation = ((SOAPBinding) ei.getAnnotation(SOAPBinding.class));
        paramStyle = annotation.parameterStyle();
    }

    if (paramStyle == SOAPBinding.ParameterStyle.BARE) {
        //bare return type.
        //todo: it's not necessarily the return type! it could be an OUT parameter...
        return new OperationBeanInfo(method.getReturnType(), null, op.getOutputMessage());
    } else {
        String responseWrapperClassName;
        ResponseWrapper responseWrapperInfo = method.getAnnotation(ResponseWrapper.class);
        if ((responseWrapperInfo != null) && (responseWrapperInfo.className() != null)
                && (responseWrapperInfo.className().length() > 0)) {
            responseWrapperClassName = responseWrapperInfo.className();
        } else {
            StringBuilder builder = new StringBuilder(pckg == null ? "" : pckg.getName());
            if (builder.length() > 0) {
                builder.append(".");
            }

            builder.append("jaxws.");

            String methodName = method.getName();
            builder.append(capitalize(methodName)).append("Response");
            responseWrapperClassName = builder.toString();
        }

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

        return new OperationBeanInfo(wrapperClass, loadOrderedProperties(wrapperClass), op.getOutputMessage());
    }
}