Java 类com.liferay.portal.kernel.util.CharPool 实例源码

项目:personal    文件:Decode.java   
protected static int getValue(char c) {
    if ((c >= CharPool.UPPER_CASE_A) && (c <= CharPool.UPPER_CASE_Z)) {
        return c - 65;
    }

    if ((c >= CharPool.LOWER_CASE_A) && (c <= CharPool.LOWER_CASE_Z)) {
        return (c - 97) + 26;
    }

    if ((c >= CharPool.NUMBER_0) && (c <= CharPool.NUMBER_9)) {
        return (c - 48) + 52;
    }

    if (c == CharPool.PLUS) {
        return 62;
    }

    if (c == CharPool.SLASH) {
        return 63;
    }

    return c != CharPool.EQUAL ? -1 : 0;
}
项目:index-checker    文件:IndexCheckerQueryHelper.java   
public static Object processTreePath(Object treePath) {
    if (treePath == null) {
        return null;
    }

    if (treePath instanceof Set) {
        Set<?> treePathSet = (Set<?>)treePath;

        Set<Object> treePathFiltered = new HashSet<Object>();

        for (Object obj : treePathSet) {
            if (Validator.isNotNull(obj)) {
                treePathFiltered.add(obj);
            }
        }

        return treePathFiltered;
    }

    if (!(treePath instanceof String)) {
        return treePath;
    }

    String treePathStr = (String)treePath;

    if ((treePathStr.length() > 0) &&
        (treePathStr.charAt(0) == CharPool.SLASH)) {

        treePathStr = treePathStr.substring(1);
    }

    if (Validator.isNull(treePathStr)) {
        return StringPool.BLANK;
    }

    return StringUtil.split(treePathStr, CharPool.SLASH);
}
项目:liferaylms-portlet    文件:CourseStats.java   
private CSVWriter initCsv(ResourceResponse resourceResponse)
        throws IOException, UnsupportedEncodingException {
    //Necesario para crear el fichero csv.
    resourceResponse.setCharacterEncoding(StringPool.UTF8);
    resourceResponse.setContentType(ContentTypes.TEXT_CSV_UTF8);
    resourceResponse.addProperty(HttpHeaders.CONTENT_DISPOSITION,"attachment; fileName=Statistics.csv");
    byte b[] = {(byte)0xEF, (byte)0xBB, (byte)0xBF};

    resourceResponse.getPortletOutputStream().write(b);

    CSVWriter writer = new CSVWriter(new OutputStreamWriter(resourceResponse.getPortletOutputStream(),StringPool.UTF8),CharPool.SEMICOLON);
    return writer;
}
项目:qrcode-display-portlet    文件:QRCodeDisplayPortlet.java   
private int _toInt(String color) {
    if (color.charAt(0) == CharPool.POUND) {
        color = color.substring(1);
    }

    return Integer.parseInt(color, 16);
}
项目:ch-inofix-timetracker    文件:TaskRecordExportBackgroundTaskExecutor.java   
@Override
public BackgroundTaskResult execute(BackgroundTask backgroundTask) throws PortalException {

    ExportImportConfiguration exportImportConfiguration = getExportImportConfiguration(backgroundTask);

    long userId = backgroundTask.getUserId();

    StringBundler sb = new StringBundler(4);

    sb.append(StringUtil.replace(exportImportConfiguration.getName(), CharPool.SPACE, CharPool.UNDERLINE));
    sb.append(StringPool.DASH);
    sb.append(Time.getTimestamp());
    sb.append(".zip");

    File xmlFile = TaskRecordLocalServiceUtil.exportTaskRecordsAsFile(exportImportConfiguration);

    BackgroundTaskManagerUtil.addBackgroundTaskAttachment(userId, backgroundTask.getBackgroundTaskId(),
            sb.toString(), xmlFile);

    return BackgroundTaskResult.SUCCESS;
}
项目:ch-inofix-contact-manager    文件:ContactExportBackgroundTaskExecutor.java   
@Override
public BackgroundTaskResult execute(BackgroundTask backgroundTask) throws PortalException {

    ExportImportConfiguration exportImportConfiguration = getExportImportConfiguration(backgroundTask);

    long userId = backgroundTask.getUserId();

    StringBundler sb = new StringBundler(4);

    sb.append(StringUtil.replace(exportImportConfiguration.getName(), CharPool.SPACE, CharPool.UNDERLINE));
    sb.append(StringPool.DASH);
    sb.append(Time.getTimestamp());
    sb.append(".zip");

    File xmlFile = ContactLocalServiceUtil.exportContactsAsFile(exportImportConfiguration);

    BackgroundTaskManagerUtil.addBackgroundTaskAttachment(userId, backgroundTask.getBackgroundTaskId(),
            sb.toString(), xmlFile);

    return BackgroundTaskResult.SUCCESS;
}
项目:ch-inofix-data-manager    文件:MeasurementExportBackgroundTaskExecutor.java   
@Override
public BackgroundTaskResult execute(BackgroundTask backgroundTask) throws PortalException {

    ExportImportConfiguration exportImportConfiguration = getExportImportConfiguration(backgroundTask);

    long userId = backgroundTask.getUserId();

    StringBundler sb = new StringBundler(4);

    sb.append(StringUtil.replace(exportImportConfiguration.getName(), CharPool.SPACE, CharPool.UNDERLINE));
    sb.append(StringPool.DASH);
    sb.append(Time.getTimestamp());
    sb.append(".zip");

    File xmlFile = MeasurementLocalServiceUtil.exportMeasurementsAsFile(exportImportConfiguration);

    BackgroundTaskManagerUtil.addBackgroundTaskAttachment(userId, backgroundTask.getBackgroundTaskId(),
            sb.toString(), xmlFile);

    return BackgroundTaskResult.SUCCESS;
}
项目:liferaylms-portlet    文件:OfflineActivity.java   
@Override
public void serveResource(ResourceRequest resourceRequest,
        ResourceResponse resourceResponse) throws IOException,
        PortletException {
    ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest.getAttribute(WebKeys.THEME_DISPLAY);
    String action = ParamUtil.getString(resourceRequest, "action");
    long actId = ParamUtil.getLong(resourceRequest, "actId",0);


    if(action.equals("export")){

        try {

            CalificationType ct = new CalificationTypeRegistry().getCalificationType(CourseLocalServiceUtil.getCourseByGroupCreatedId(themeDisplay.getScopeGroupId()).getCalificationType());

            //Necesario para crear el fichero csv.
            resourceResponse.setCharacterEncoding(StringPool.UTF8);
            resourceResponse.setContentType(ContentTypes.TEXT_CSV_UTF8);
            resourceResponse.addProperty(HttpHeaders.CONTENT_DISPOSITION,"attachment; fileName=data.csv");
            byte b[] = {(byte)0xEF, (byte)0xBB, (byte)0xBF};

            resourceResponse.getPortletOutputStream().write(b);

            CSVWriter writer = new CSVWriter(new OutputStreamWriter(resourceResponse.getPortletOutputStream(),StringPool.UTF8),CharPool.SEMICOLON);
            String[] cabeceras = new String[4];


            //En esta columna vamos a tener el nombre del usuario.
            cabeceras[0]= LanguageUtil.get(getPortletConfig(), themeDisplay.getLocale(), "onlinetaskactivity.export.user");
            cabeceras[1]= LanguageUtil.get(getPortletConfig(), themeDisplay.getLocale(), "onlinetaskactivity.export.date");
            cabeceras[2]= LanguageUtil.get(getPortletConfig(), themeDisplay.getLocale(), "onlinetaskactivity.export.result");
            cabeceras[3]= LanguageUtil.get(getPortletConfig(), themeDisplay.getLocale(), "onlinetaskactivity.export.comment");

            writer.writeNext(cabeceras);
            DynamicQuery dq=DynamicQueryFactoryUtil.forClass(LearningActivityResult.class);
            Criterion criterion=PropertyFactoryUtil.forName("actId").eq(actId);
            dq.add(criterion);

            //Partiremos del usuario para crear el csv para que sea más facil ver los intentos.
            List<LearningActivityResult> listresult = LearningActivityResultLocalServiceUtil.dynamicQuery(dq);
            for(LearningActivityResult learningActivityResult:listresult){
                //Array con los resultados de los intentos.
                String[] resultados = new String[4];
                //En la primera columna del csv introducidos el nombre del estudiante.
                resultados[0] = UserLocalServiceUtil.getUser(learningActivityResult.getUserId()).getScreenName();
                resultados[1] = _dateFormat.format(learningActivityResult.getEndDate());
                resultados[2] = ct.translate(themeDisplay.getLocale(), themeDisplay.getScopeGroupId(), learningActivityResult.getResult());
                resultados[3] = learningActivityResult.getComments()!=null?learningActivityResult.getComments():"";

                //Escribimos las respuestas obtenidas para el intento en el csv.
                writer.writeNext(resultados);
            }
            writer.flush();
            writer.close();
            resourceResponse.getPortletOutputStream().flush();
            resourceResponse.getPortletOutputStream().close();

        } catch (NestableException e) {

        }finally{
            resourceResponse.getPortletOutputStream().flush();
            resourceResponse.getPortletOutputStream().close();
        }
    } 
}
项目:edemocracia    文件:LayoutImporter.java   
protected void fixTypeSettings(Layout layout) throws Exception {
    if (!layout.isTypeURL()) {
        return;
    }

    UnicodeProperties typeSettings = layout.getTypeSettingsProperties();

    String url = GetterUtil.getString(typeSettings.getProperty("url"));

    String friendlyURLPrivateGroupPath =
        PropsValues.LAYOUT_FRIENDLY_URL_PRIVATE_GROUP_SERVLET_MAPPING;
    String friendlyURLPrivateUserPath =
        PropsValues.LAYOUT_FRIENDLY_URL_PRIVATE_USER_SERVLET_MAPPING;
    String friendlyURLPublicPath =
        PropsValues.LAYOUT_FRIENDLY_URL_PUBLIC_SERVLET_MAPPING;

    if (!url.startsWith(friendlyURLPrivateGroupPath) &&
        !url.startsWith(friendlyURLPrivateUserPath) &&
        !url.startsWith(friendlyURLPublicPath)) {

        return;
    }

    int x = url.indexOf(CharPool.SLASH, 1);

    if (x == -1) {
        return;
    }

    int y = url.indexOf(CharPool.SLASH, x + 1);

    if (y == -1) {
        return;
    }

    String friendlyURL = url.substring(x, y);

    if (!friendlyURL.equals(LayoutExporter.SAME_GROUP_FRIENDLY_URL)) {
        return;
    }

    Group group = layout.getGroup();

    typeSettings.setProperty(
        "url",
        url.substring(0, x) + group.getFriendlyURL() + url.substring(y));
}