org.apache.http.util.TextUtils#isEmpty ( )源码实例Demo

下面列出了org.apache.http.util.TextUtils#isEmpty ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: GsonFormat   文件: JsonDialog.java
private void onOK() {

        this.setAlwaysOnTop(false);
        String jsonSTR = editTP.getText().trim();
        if (TextUtils.isEmpty(jsonSTR)) {
            return;
        }
        String generateClassName = generateClassTF.getText().replaceAll(" ", "").replaceAll(".java$", "");
        if (TextUtils.isEmpty(generateClassName) || generateClassName.endsWith(".")) {
            Toast.make(project, generateClassP, MessageType.ERROR, "the path is not allowed");
            return;
        }
        PsiClass generateClass = null;
        if (!currentClass.equals(generateClassName)) {
            generateClass = PsiClassUtil.exist(file, generateClassTF.getText());
        } else {
            generateClass = cls;
        }

        new ConvertBridge(this, jsonSTR, file, project, generateClass,
                cls, generateClassName).run();
    }
 
源代码2 项目: GoogleTranslation   文件: GoogleTranslation.java
private void getTranslation(AnActionEvent event) {
    Editor editor = event.getData(PlatformDataKeys.EDITOR);
    if (editor == null) {
        return;
    }
    SelectionModel model = editor.getSelectionModel();
    String selectedText = model.getSelectedText();
    if (TextUtils.isEmpty(selectedText)) {
        selectedText = getCurrentWords(editor);
        if (TextUtils.isEmpty(selectedText)) {
            return;
        }
    }
    String queryText = strip(addBlanks(selectedText));
    new Thread(new RequestRunnable(mTranslator, editor, queryText)).start();
}
 
源代码3 项目: ReciteWords   文件: ReciteWords.java
private void getTranslation(AnActionEvent event) {
    Editor mEditor = event.getData(PlatformDataKeys.EDITOR);
    Project project = event.getData(PlatformDataKeys.PROJECT);
    String basePath = project.getBasePath();

    if (null == mEditor) {
        return;
    }
    SelectionModel model = mEditor.getSelectionModel();
    String selectedText = model.getSelectedText();
    if (TextUtils.isEmpty(selectedText)) {
        selectedText = getCurrentWords(mEditor);
        if (TextUtils.isEmpty(selectedText)) {
            return;
        }
    }
    String queryText = strip(addBlanks(selectedText));
    new Thread(new RequestRunnable(mEditor, queryText,basePath)).start();
}
 
/**
 * valid tag to count
 */
public static boolean isTargetTagToCount(PsiElement tag) {
    if (tag == null || !(tag instanceof XmlTag) || TextUtils.isEmpty(((XmlTag)tag).getName())) {
        return false;
    }
    String name = ((XmlTag)tag).getName();
    return name.equals("array")
            || name.equals("attr")
            || name.equals("bool")
            || name.equals("color")
            || name.equals("declare-styleable")
            || name.equals("dimen")
            || name.equals("drawable")
            || name.equals("eat-comment")
            || name.equals("fraction")
            || name.equals("integer")
            || name.equals("integer-array")
            || name.equals("item")
            || name.equals("plurals")
            || name.equals("string")
            || name.equals("string-array")
            || name.equals("style");
}
 
源代码5 项目: weex-language-support   文件: Settings.java
@Override
public void apply() throws ConfigurationException {
    try {
        PropertiesComponent.getInstance().setValue(KEY_RULES_PATH, rulesPath.getText());
        if (!TextUtils.isEmpty(rulesPath.getText())) {
            load(rulesPath.getText());
            DirectiveLint.prepare();
        } else {
            DirectiveLint.reset();
        }
    } catch (Exception e) {
        ProjectUtil.guessCurrentProject(select).getMessageBus().syncPublisher(Notifications.TOPIC).notify(
                new Notification(Notifications.SYSTEM_MESSAGES_GROUP_ID,
                        "Weex language support - bad rules",
                        e.toString(),
                        NotificationType.ERROR));
    }
    savePaths();
}
 
源代码6 项目: GsonFormat   文件: StringUtils.java
/**
 * 转成驼峰
 *
 * @param text
 * @return
 */
public static String captureStringLeaveUnderscore(String text) {
    if (TextUtils.isEmpty(text)) {
        return text;
    }
    String temp = text.replaceAll("^_+", "");

    if (!TextUtils.isEmpty(temp)) {
        text = temp;
    }
    String[] strings = text.split("_");
    StringBuilder stringBuilder = new StringBuilder();
    stringBuilder.append(strings[0]);
    for (int i = 1; i < strings.length; i++) {
        stringBuilder.append(captureName(strings[i]));
    }
    return stringBuilder.toString();
}
 
源代码7 项目: weex-language-support   文件: Attribute.java
public boolean match(String value) {
    if (TextUtils.isEmpty(valuePattern)) {
        return false;
    }
    if (valuePattern.toLowerCase().equals("mustache")) {
        return Pattern.compile("\\{\\{.*\\}\\}").matcher(value).matches();
    }  else if (valuePattern.toLowerCase().equals("number")) {
        return Pattern.compile("[0-9]+([.][0-9]+)?$").matcher(value).matches();
    } else if (valuePattern.toLowerCase().equals("boolean")) {
        return Pattern.compile("(true|false)$").matcher(value).matches();
    }  else {
        try {
            return Pattern.compile(valuePattern).matcher(value).matches();
        } catch (Exception e) {
            return false;
        }
    }
}
 
源代码8 项目: instamojo-java   文件: ApiContext.java
private void loadAccessToken(Map<String, String> params) throws ConnectionException, HTTPException {
    try {
        String response = HttpUtils.post(getAuthEndpoint(), null, params);

        AccessToken accessTokenResponse = new Gson().fromJson(response,
                AccessToken.class);

        if (TextUtils.isEmpty(accessTokenResponse.getToken())) {
            throw new InvalidClientException(
                    "Could not get the access token due to " + accessTokenResponse.getError());
        }

        this.accessToken = accessTokenResponse;
        this.tokenCreationTime = System.nanoTime();

    } catch (IOException e) {
        LOGGER.log(Level.SEVERE, e.toString(), e);
        throw new ConnectionException(e.toString(), e);
    }
}
 
源代码9 项目: GsonFormat   文件: ConvertBridge.java
private String createSubClassName(String key, Object o) {
    String name = "";
    if (o instanceof JSONObject) {
        if (TextUtils.isEmpty(key)) {
            return key;
        }
        String[] strings = key.split("_");
        StringBuilder stringBuilder = new StringBuilder();
        for (int i = 0; i < strings.length; i++) {
            stringBuilder.append(StringUtils.captureName(strings[i]));
        }
        name = stringBuilder.toString() + Config.getInstant().getSuffixStr();
    }
    return name;

}
 
源代码10 项目: GsonFormat   文件: ClassEntity.java
@Override
public void setValueAt(int column, String text) {
    switch (column) {
        case 2:
            break;
        case 3:
            String result;
            if (!TextUtils.isEmpty(fieldTypeSuffix)) {
                result = fieldTypeSuffix + "." + text;
            } else {
                result = text;
            }
            if (CheckUtil.getInstant().containsDeclareClassName(result)) {
                return;
            }
            CheckUtil.getInstant().removeDeclareClassName(getQualifiedName());
            setClassName(text);
            break;
    }
}
 
源代码11 项目: swagger-showdoc   文件: OkHttpUtil.java
private static String getHeaderFileName(Response response) {
    String dispositionHeader = response.header("Content-Disposition");
    if (!TextUtils.isEmpty(dispositionHeader)) {
        dispositionHeader.replace("attachment;filename=", "");
        dispositionHeader.replace("filename*=utf-8", "");
        String[] strings = dispositionHeader.split("; ");
        if (strings.length > 1) {
            dispositionHeader = strings[1].replace("filename=", "");
            dispositionHeader = dispositionHeader.replace("\"", "");
            return dispositionHeader;
        }
        return "";
    }
    return "";
}
 
源代码12 项目: TinyPngPlugin   文件: TinyPngExtension.java
@Override
public void actionPerformed(AnActionEvent actionEvent) {
    Project project = actionEvent.getProject();
    String apiKey = PropertiesComponent.getInstance().getValue(TINY_PNG_API_KEY);
    if (TextUtils.isEmpty(apiKey)) {
        apiKey = Messages.showInputDialog(project, "What's your ApiKey?", "ApiKey", Messages.getQuestionIcon());
        PropertiesComponent.getInstance().setValue(TINY_PNG_API_KEY, apiKey);
    }
    VirtualFile[] selectedFiles = PlatformDataKeys.VIRTUAL_FILE_ARRAY.getData(actionEvent.getDataContext());
    Tinify.setKey(apiKey);
    ProgressDialog dialog = new ProgressDialog();
    sExecutorService.submit(() -> {
        //writing to file
        int i = 1;
        successCount = 0;
        failCount = 0;
        List<VirtualFile> failFileList = new ArrayList<>();
        for (VirtualFile file : selectedFiles) {
            failFileList.addAll(processFile(dialog, i + "/" + selectedFiles.length, file));
            i++;
        }
        dialog.setLabelMsg("Success :" + successCount + " Fail :" + failCount);
        dialog.setButtonOKVisible();
    });
    dialog.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            runningFlag.set(false);
        }
    });
    dialog.setLabelMsg("processing");
    JFrame frame = WindowManager.getInstance().getFrame(project);
    dialog.setMinimumSize(new Dimension(frame.getWidth() / 4, frame.getHeight() / 4));
    dialog.setLocationRelativeTo(frame);
    dialog.pack();
    dialog.setVisible(true);
}
 
源代码13 项目: AndroidLocalizePlugin   文件: LanguageHelper.java
/**
 * Get saved language code data.
 *
 * @param project current project.
 * @return null if not saved.
 */
@Nullable
public static List<String> getSelectedLanguageCodes(@NotNull Project project) {
    Objects.requireNonNull(project);

    String codeString = PropertiesComponent.getInstance(project)
            .getValue(Constants.KEY_SELECTED_LANGUAGES);

    if (TextUtils.isEmpty(codeString)) {
        return null;
    }

    return Arrays.asList(codeString.split(","));
}
 
源代码14 项目: GsonFormat   文件: ClassEntity.java
public String getQualifiedName() {
    String fullClassName;
    if (!TextUtils.isEmpty(packName)) {
        fullClassName = packName + "." + className;
    } else {
        fullClassName = className;
    }

    return fullClassName;
}
 
源代码15 项目: AndroidGodEye   文件: OpenAction.java
@Override
public void actionPerformed(AnActionEvent anActionEvent) {
    try {
        Project project = anActionEvent.getProject();
        String path = parseAndroidSDKPath(Objects.requireNonNull(project));
        if (TextUtils.isEmpty(path)) {
            Notifications.Bus.notify(new Notification("AndroidGodEye", "Open AndroidGodEye Failed", "Can not parse sdk.dir, Please add 'sdk.dir' to 'local.properties'.", NotificationType.ERROR));
            return;
        }
        mLogger.info("Current os name is " + SystemUtils.OS_NAME);
        String adbPath = String.format("%s/platform-tools/adb", path);
        mLogger.info("ADB path is " + adbPath);
        String parsedPort = parsePortByLogcatWithTimeout(project, adbPath);
        mLogger.info("Parse AndroidGodEye port is running at " + parsedPort);
        String inputPort = askForPort(project, parsedPort, getSavedPort(project));
        if (inputPort == null) {
            mLogger.warn("inputPort == null");
            return;
        }
        saveDefaultPort(project, inputPort);
        final String commandTcpProxy = String.format("%s forward tcp:%s tcp:%s", adbPath, inputPort, inputPort);
        mLogger.info("Exec [" + commandTcpProxy + "].");
        Runtime.getRuntime().exec(commandTcpProxy);
        String commandOpenUrl;
        if (SystemUtils.IS_OS_WINDOWS) {
            commandOpenUrl = String.format("cmd /c start http://localhost:%s/index.html", inputPort);
        } else {
            commandOpenUrl = String.format("open http://localhost:%s/index.html", inputPort);
        }
        mLogger.info("Exec [" + commandOpenUrl + "].");
        Runtime.getRuntime().exec(commandOpenUrl);
        Notifications.Bus.notify(new Notification("AndroidGodEye", "Open AndroidGodEye Success", String.format("http://localhost:%s/index.html", inputPort), NotificationType.INFORMATION));
    } catch (Throwable e) {
        mLogger.warn(e);
        Notifications.Bus.notify(new Notification("AndroidGodEye", "Open AndroidGodEye Failed", String.valueOf(e), NotificationType.ERROR));
    }
}
 
源代码16 项目: GsonFormat   文件: IterableFieldEntity.java
@Override
public void checkAndSetType(String text) {
    if (targetClass.isLock()) {
        return;
    }
    String regex = getBriefTypeReg().replaceAll("%s", "(\\\\w+)");
    Pattern pattern = Pattern.compile(regex);
    Matcher matcher = pattern.matcher(text);
    if (matcher.find() && matcher.groupCount() > 0) {
        String temp = matcher.group(1);
        if (!TextUtils.isEmpty(temp)) {
            targetClass.setClassName(temp);
        }
    }
}
 
源代码17 项目: MVPManager   文件: EditorMVPDialog.java
private void fillSinglePackageTree(DefaultMutableTreeNode root)
{
    String name = contractName.getText();
    DefaultMutableTreeNode createdFolder = new DefaultMutableTreeNode(TextUtils.isEmpty(name) ? "(Please input contract name!)" : name.toLowerCase());
    createdFolder.add(new DefaultMutableTreeNode(TextUtils.isEmpty(viewImpName.getText()) ? "(Please input Activity/Fragment!)" : viewImpName.getText() + ".java"));
    createdFolder.add(new DefaultMutableTreeNode(name + ClassHelper.CONTRACT  + ".java"));
    createdFolder.add(new DefaultMutableTreeNode(name + ClassHelper.PRESENTER + ".java"));
    createdFolder.add(new DefaultMutableTreeNode(name + ClassHelper.MODEL     + ".java"));
    root.add(createdFolder);
}
 
源代码18 项目: GsonFormat   文件: IterableFieldEntity.java
private String getClassTypeName() {
    String typeName = "";
    if (targetClass != null) {
        if (TextUtils.isEmpty(targetClass.getPackName())) {
            typeName = targetClass.getClassName();
        } else {
            typeName = targetClass.getPackName() + "." + targetClass.getClassName();
        }
    } else if (getType() != null && getType().length() > 0) {
        typeName = getType();
    }
    return typeName;
}
 
/**
 * 处理来自微信的HTTP请求。
 * @param signature
 * @param timestamp
 * @param nonce
 * @param echoStr
 * @param request
 * @param is
 * @return
 */
@RequestMapping(value = "/recv_wx")
@ResponseBody
public String onWxMessage(
        @RequestParam(value = "signature", required = false) String signature,
        @RequestParam(value = "timestamp", required = false) String timestamp,
        @RequestParam(value = "nonce", required = false) String nonce,
        @RequestParam(value = "echostr", required = false) String echoStr,
        HttpServletRequest request,
        InputStream is) {
    try {
        if (TextUtils.isEmpty(echoStr)) {
            // 收到消息
            String msg = StringUtil.isToString(is);
            logger.debug("msg content" + msg);

            // 解析XML, 分离消息来源,内容
            return parseWxMessage(msg);
        } else {
            // 验证url
            String sha1 = SHA1.getSHA1(Constants.WX_TOKEN, timestamp, nonce);
            logger.debug("verify url: " + sha1 + " - " + signature + " - " + echoStr);
            if (signature.equals(sha1)) {
                return echoStr;
            } else {
                return "";
            }
        }
    } catch (Throwable e) {
        logger.warn("onWxMessage error, " + e);
    }
    return Constants.WX_RET_SUCCESS;
}
 
源代码20 项目: GsonFormat   文件: PsiClassUtil.java
public static PsiClass exist(PsiFile psiFile, String generateClass) {
    PsiClass psiClass = null;
    PsiDirectory psiDirectory = getJavaSrc(psiFile);
    if (psiDirectory == null || psiDirectory.getVirtualFile().getCanonicalPath() == null) {
        return null;
    }

    File file = new File(psiDirectory.getVirtualFile().getCanonicalPath().concat("/")
            .concat(generateClass.trim().replace(".", "/")).concat(".java"));

    String[] strArray = generateClass.replace(" ", "").split("\\.");
    if (TextUtils.isEmpty(generateClass)) {
        return null;
    }
    String className = strArray[strArray.length - 1];
    String packName = generateClass.substring(generateClass.length() - className.length(), generateClass.length());
    if (file.exists()) {
        for (int i = 0; i < strArray.length - 1; i++) {
            psiDirectory = psiDirectory.findSubdirectory(strArray[i]);
            if (psiDirectory == null) {
                return null;
            }
        }
        PsiFile psiFile1 = psiDirectory.findFile(className + ".java");
        if ((psiFile1 instanceof PsiJavaFile) && ((PsiJavaFile) psiFile1).getClasses().length > 0) {
            psiClass = ((PsiJavaFile) psiFile1).getClasses()[0];
        }
    }
    return psiClass;
}
 
 同类方法