Example usage for java.lang Class toString

List of usage examples for java.lang Class toString

Introduction

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

Prototype

public String toString() 

Source Link

Document

Converts the object to a string.

Usage

From source file:com.toolsverse.mvc.model.ModelImpl.java

/**
 * Checks if it is a setter method./* ww w.ja  va  2  s  . co  m*/
 *
 * @param method the method
 * @return true, if it is a setter method
 */
protected boolean isSetterMethod(Method method) {
    Class<?>[] paramsTypes = method.getParameterTypes();
    Class<?> retType = method.getReturnType();

    return paramsTypes != null && paramsTypes.length == 1 && retType != null
            && retType.toString().equals("void");
}

From source file:com.toolsverse.mvc.model.ModelImpl.java

/**
 * Checks if it is a reader method./*from w  ww  .j a va2  s  .co  m*/
 *
 * @param method the method
 * @return true, if it is a reader method
 */
protected boolean isReaderMethod(Method method) {
    Class<?>[] paramsTypes = method.getParameterTypes();
    Class<?> retType = method.getReturnType();

    return paramsTypes != null && paramsTypes.length == 1 && retType != null
            && !retType.toString().equals("void");
}

From source file:com.toolsverse.mvc.model.ModelImpl.java

/**
 * Checks if it is a getter method./*from  w  w w .j  a  va 2 s . c  o m*/
 *
 * @param method the method
 * @return true, if it is a getter method
 */
protected boolean isGetterMethod(Method method) {
    Class<?>[] paramsTypes = method.getParameterTypes();
    Class<?> retType = method.getReturnType();

    return (paramsTypes == null || paramsTypes.length == 0) && retType != null
            && !retType.toString().equals("void");
}

From source file:com.toolsverse.mvc.model.ModelImpl.java

/**
 * Checks if it is a writer method.//from ww  w.j a va 2  s  .c o m
 *
 * @param method the method
 * @return true, if it is a writer method
 */
protected boolean isWriterMethod(Method method) {
    Class<?>[] paramsTypes = method.getParameterTypes();
    Class<?> retType = method.getReturnType();

    return (paramsTypes == null || paramsTypes.length == 0) && retType != null
            && !retType.toString().equals("void");
}

From source file:org.energyos.espi.common.repositories.jpa.ResourceRepositoryImpl.java

@SuppressWarnings("unchecked")
@Override//from   www  .j a  v a2 s  .  c  o  m
public <T extends IdentifiedObject> List<Long> findAllIdsByXPath(Long id1, Long id2, Class<T> clazz) {
    try {
        String findAllIdsByXPath = (String) clazz.getDeclaredField("QUERY_FIND_ALL_IDS_BY_XPATH_2")
                .get(String.class);
        Query query = em.createNamedQuery(findAllIdsByXPath).setParameter("o1Id", id1).setParameter("o2Id",
                id2);
        return query.getResultList();
    } catch (NoSuchFieldException | IllegalAccessException e) {
        System.out.printf("**** findAllIdsByXPath(Long id1, Long id2) Exception: %s - %s\n", clazz.toString(),
                e.toString());
        throw new RuntimeException(e);
    }
}

From source file:com.asakusafw.bulkloader.collector.ExportFileSend.java

/**
 * ExportDB????/*from  w  w  w . j a  v  a2 s .c om*/
 * <p>
 * Export??TSV???????DB?????
 * ???Exporter??????
 * </p>
 * @param bean ???Bean
 * @param user OS???
 * @return Export??true:??false:
 */
public boolean sendExportFile(ExporterBean bean, String user) {

    // ???
    String strCompType = ConfigurationLoader.getProperty(Constants.PROP_KEY_EXP_FILE_COMP_TYPE);
    FileCompType compType = FileCompType.find(strCompType);

    OutputStream output = getOutputStream();
    try {
        FileList.Writer writer;
        try {
            writer = FileList.createWriter(output, compType == FileCompType.DEFLATED);
        } catch (IOException e) {
            throw new BulkLoaderSystemException(e, getClass(), "TG-COLLECTOR-02001",
                    "Exporter??????????");
        }
        Configuration conf = new Configuration();
        List<String> l = bean.getExportTargetTableList();
        for (String tableName : l) {
            ExportTargetTableBean targetTable = bean.getExportTargetTable(tableName);
            Class<? extends Writable> targetTableModel = targetTable.getExportTargetType()
                    .asSubclass(Writable.class);

            List<Path> filePath = FileNameUtil.createPaths(conf, targetTable.getDfsFilePaths(),
                    bean.getExecutionId(), user);

            // Export???
            int fileCount = filePath.size();
            long recordCount = 0;
            for (int i = 0; i < fileCount; i++) {
                // Export?
                LOG.info("TG-COLLECTOR-02002", tableName, filePath.get(i), compType.getSymbol(),
                        targetTableModel.toString());
                long countInFile = send(targetTableModel, filePath.get(i).toString(), writer, tableName);
                if (countInFile >= 0) {
                    recordCount += countInFile;
                }
                LOG.info("TG-COLLECTOR-02003", tableName, filePath.get(i), compType.getSymbol(),
                        targetTableModel.toString());
            }

            LOG.info("TG-PROFILE-01004", bean.getTargetName(), bean.getBatchId(), bean.getJobflowId(),
                    bean.getExecutionId(), tableName, recordCount);
        }

        try {
            writer.close();
        } catch (IOException e) {
            // ????????????
            e.printStackTrace();
        }

        // 
        return true;
    } catch (BulkLoaderSystemException e) {
        LOG.log(e);
        return false;
    } finally {
        try {
            output.close();
        } catch (IOException e) {
            // ????????????
            e.printStackTrace();
        }
    }
}

From source file:org.ajax4jsf.resource.ResourceBuilderImpl.java

/**
 * Create resource by instatiate given class.
 * //from w w  w .j  a va 2 s  .c om
 * @param path
 * @param instatiate
 * @return
 */
protected InternetResource createDynamicResource(String path, Class<?> instatiate)
        throws ResourceNotFoundException {
    if (InternetResource.class.isAssignableFrom(instatiate)) {
        InternetResource resource;
        try {
            resource = (InternetResource) instatiate.newInstance();
            addResource(path, resource);
        } catch (Exception e) {
            String message = Messages.getMessage(Messages.INSTANTIATE_RESOURCE_ERROR, instatiate.toString());
            log.error(message, e);
            throw new ResourceNotFoundException(message, e);
        }
        return resource;
    }
    throw new FacesException(Messages.getMessage(Messages.INSTANTIATE_CLASS_ERROR));
}

From source file:org.energyos.espi.common.repositories.jpa.ResourceRepositoryImpl.java

@SuppressWarnings("unchecked")
@Override//from  w w  w. j ava 2s  .c o m
public <T extends IdentifiedObject> List<Long> findAllIdsByUsagePointId(Long usagePointId, Class<T> clazz) {
    try {
        String queryFindAllIdsByUsagePointId = (String) clazz
                .getDeclaredField("QUERY_FIND_ALL_IDS_BY_USAGE_POINT_ID").get(String.class);

        return em.createNamedQuery(queryFindAllIdsByUsagePointId).setParameter("usagePointId", usagePointId)
                .getResultList();
    } catch (NoSuchFieldException | IllegalAccessException e) {
        System.out.printf("**** FindAllIdsByUsagePointId(Long usagePointId) Exception: %s - %s\n",
                clazz.toString(), e.toString());
        throw new RuntimeException(e);
    }
}

From source file:org.energyos.espi.common.repositories.jpa.ResourceRepositoryImpl.java

@Override
public <T extends IdentifiedObject> Long findIdByXPath(Long id1, Long id2, Long id3, Class<T> clazz) {
    try {//  ww  w.  ja v  a  2 s. co m
        String findIdByXPath = (String) clazz.getDeclaredField("QUERY_FIND_ID_BY_XPATH").get(String.class);
        Query query = em.createNamedQuery(findIdByXPath).setParameter("o1Id", id1).setParameter("o2Id", id2)
                .setParameter("o3Id", id3);
        return (Long) query.getSingleResult();
    } catch (NoSuchFieldException | IllegalAccessException e) {
        System.out.printf("**** findIdByXPath(Long id1, Long id2, Long id3) Exception: %s - %s\n",
                clazz.toString(), e.toString());
        throw new RuntimeException(e);
    }
}

From source file:org.energyos.espi.common.repositories.jpa.ResourceRepositoryImpl.java

@SuppressWarnings("unchecked")
@Override/*from  w w  w .j  a  va  2s. c  om*/
public <T extends IdentifiedObject> List<Long> findAllIdsByXPath(Long id1, Long id2, Long id3, Class<T> clazz) {
    try {
        String findAllIdsByXPath = (String) clazz.getDeclaredField("QUERY_FIND_ALL_IDS_BY_XPATH_3")
                .get(String.class);
        Query query = em.createNamedQuery(findAllIdsByXPath).setParameter("o1Id", id1).setParameter("o2Id", id2)
                .setParameter("o3Id", id3);
        return query.getResultList();
    } catch (NoSuchFieldException | IllegalAccessException e) {
        System.out.printf("**** findAllIdsByXPath(Long id1, Long id2, Long id3) Exception: %s - %s\n",
                clazz.toString(), e.toString());
        throw new RuntimeException(e);
    }
}