Java Code Examples for org.apache.http.util.TextUtils#isEmpty()
The following examples show how to use
org.apache.http.util.TextUtils#isEmpty() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StringUtils.java From GsonFormat with Apache License 2.0 | 6 votes |
/** * 转成驼峰 * * @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(); }
Example 2
Source File: ClassEntity.java From GsonFormat with Apache License 2.0 | 6 votes |
@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; } }
Example 3
Source File: ConvertBridge.java From GsonFormat with Apache License 2.0 | 6 votes |
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; }
Example 4
Source File: ApiContext.java From instamojo-java with MIT License | 6 votes |
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); } }
Example 5
Source File: Attribute.java From weex-language-support with MIT License | 6 votes |
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; } } }
Example 6
Source File: Settings.java From weex-language-support with MIT License | 6 votes |
@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(); }
Example 7
Source File: ResourceUsageCountUtils.java From Android-Resource-Usage-Count with MIT License | 6 votes |
/** * 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"); }
Example 8
Source File: ReciteWords.java From ReciteWords with MIT License | 6 votes |
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(); }
Example 9
Source File: GoogleTranslation.java From GoogleTranslation with Apache License 2.0 | 6 votes |
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(); }
Example 10
Source File: JsonDialog.java From GsonFormat with Apache License 2.0 | 6 votes |
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(); }
Example 11
Source File: OpenAction.java From AndroidGodEye with Apache License 2.0 | 5 votes |
@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)); } }
Example 12
Source File: OkHttpUtil.java From swagger-showdoc with Apache License 2.0 | 5 votes |
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 ""; }
Example 13
Source File: IterableFieldEntity.java From GsonFormat with Apache License 2.0 | 5 votes |
@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); } } }
Example 14
Source File: ClassEntity.java From GsonFormat with Apache License 2.0 | 5 votes |
public String getQualifiedName() { String fullClassName; if (!TextUtils.isEmpty(packName)) { fullClassName = packName + "." + className; } else { fullClassName = className; } return fullClassName; }
Example 15
Source File: EditorMVPDialog.java From MVPManager with MIT License | 5 votes |
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); }
Example 16
Source File: LanguageHelper.java From AndroidLocalizePlugin with Apache License 2.0 | 5 votes |
/** * 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(",")); }
Example 17
Source File: IterableFieldEntity.java From GsonFormat with Apache License 2.0 | 5 votes |
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; }
Example 18
Source File: OfficialAccountController.java From message_interface with MIT License | 5 votes |
/** * 处理来自微信的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; }
Example 19
Source File: PsiClassUtil.java From GsonFormat with Apache License 2.0 | 5 votes |
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; }
Example 20
Source File: TinyPngExtension.java From TinyPngPlugin with Apache License 2.0 | 5 votes |
@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); }