org.apache.http.util.TextUtils Java Examples
The following examples show how to use
org.apache.http.util.TextUtils.
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: EditorMVPDialog.java From MVPManager with MIT License | 6 votes |
/** * Get data in JTable * * @param jTable * @return */ private ArrayList<String> getData(JTable jTable) { ArrayList<String> list = new ArrayList<>(); for (int i = 0; i < jTable.getModel().getRowCount(); i++) { TableModel model = jTable.getModel(); String returnStr = (String) model.getValueAt(i, 0); String methodStr = (String) model.getValueAt(i, 1); returnStr = returnStr.trim(); methodStr = methodStr.trim(); if (TextUtils.isEmpty(returnStr) || TextUtils.isEmpty(methodStr)) { return null; } list.add(returnStr + "##" + methodStr); } return list; }
Example #2
Source File: StripeRest.java From restcountries with Mozilla Public License 2.0 | 6 votes |
@POST public Object contribute(Contribution contribution) { LOG.debug("Contribution: " + contribution); if (contribution == null || TextUtils.isBlank(contribution.getToken())) { return getResponse(Response.Status.BAD_REQUEST); } Stripe.apiKey = ""; Map<String, Object> params = new HashMap<>(); params.put("amount", contribution.getAmount()); params.put("currency", "eur"); params.put("description", "REST Countries"); params.put("source", contribution.getToken()); try { Charge.create(params); } catch (AuthenticationException | InvalidRequestException | CardException | APIConnectionException | APIException e) { LOG.error(e.getMessage(), e); return getResponse(Response.Status.BAD_REQUEST); } return getResponse(Response.Status.ACCEPTED); }
Example #3
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 #4
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 #5
Source File: Processor.java From GsonFormat with Apache License 2.0 | 6 votes |
private String generateFieldText(ClassEntity classEntity, FieldEntity fieldEntity, String fixme) { fixme = fixme == null ? "" : fixme; StringBuilder fieldSb = new StringBuilder(); String filedName = fieldEntity.getGenerateFieldName(); if (!TextUtils.isEmpty(classEntity.getExtra())) { fieldSb.append(classEntity.getExtra()).append("\n"); classEntity.setExtra(null); } if (fieldEntity.getTargetClass() != null) { fieldEntity.getTargetClass().setGenerate(true); } if (!filedName.equals(fieldEntity.getKey()) || Config.getInstant().isUseSerializedName()) { fieldSb.append(Config.getInstant().geFullNameAnnotation().replaceAll("\\{filed\\}", fieldEntity.getKey())); } if (Config.getInstant().isFieldPrivateMode()) { fieldSb.append("private ").append(fieldEntity.getFullNameType()).append(" ").append(filedName).append(" ; "); } else { fieldSb.append("public ").append(fieldEntity.getFullNameType()).append(" ").append(filedName).append(" ; "); } return fieldSb.append(fixme).toString(); }
Example #6
Source File: AutoValueProcessor.java From GsonFormat with Apache License 2.0 | 6 votes |
private String generateFieldText(ClassEntity classEntity, FieldEntity fieldEntity, String fixme) { fixme = fixme == null ? "" : fixme; StringBuilder fieldSb = new StringBuilder(); String fieldName = fieldEntity.getGenerateFieldName(); if (!TextUtils.isEmpty(classEntity.getExtra())) { fieldSb.append(classEntity.getExtra()).append("\n"); classEntity.setExtra(null); } if (!fieldName.equals(fieldEntity.getKey()) || Config.getInstant().isUseSerializedName()) { fieldSb.append(Constant.gsonFullNameAnnotation.replaceAll("\\{filed\\}", fieldEntity.getKey())); } if (fieldEntity.getTargetClass() != null) { fieldEntity.getTargetClass().setGenerate(true); } return fieldSb.append(String.format("public abstract %s %s(); " + fixme, fieldEntity.getFullNameType(), fieldName)).toString(); }
Example #7
Source File: LombokProcessor.java From GsonFormat with Apache License 2.0 | 6 votes |
private String generateLombokFieldText(ClassEntity classEntity, FieldEntity fieldEntity, String fixme) { fixme = fixme == null ? "" : fixme; StringBuilder fieldSb = new StringBuilder(); String filedName = fieldEntity.getGenerateFieldName(); if (!TextUtils.isEmpty(classEntity.getExtra())) { fieldSb.append(classEntity.getExtra()).append("\n"); classEntity.setExtra(null); } if (fieldEntity.getTargetClass() != null) { fieldEntity.getTargetClass().setGenerate(true); } if (Config.getInstant().isFieldPrivateMode()) { fieldSb.append("private ").append(fieldEntity.getFullNameType()).append(" ").append(filedName).append(" ; "); } else { fieldSb.append("public ").append(fieldEntity.getFullNameType()).append(" ").append(filedName).append(" ; "); } return fieldSb.append(fixme).toString(); }
Example #8
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 #9
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 #10
Source File: WXUserService.java From message_interface with MIT License | 6 votes |
public String queryWxUserNick(String openId) throws IOException { String nick = userNickMap.get(openId); if (TextUtils.isEmpty(nick)) { String url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=%s&openid=%s&lang=zh_CN"; url = String.format(url, wxAuthService.queryAccessToken(), openId); String res = HttpClientPool.getInstance().get(url); if (TextUtils.isEmpty(res)) { return null; } else { JSONObject json = JSONObject.parseObject(res); nick = json.getString("nickname"); userNickMap.put(openId, nick); // 更新到七鱼 updateWxUserToQiyu(openId, json); } } return nick; }
Example #11
Source File: WxBot.java From WxBot with GNU General Public License v3.0 | 6 votes |
public void start() { this.getUuid();// 获取uuid if (!TextUtils.isBlank(uuid)) { this.downQrCode();// 下载二维码图片 this.showQrCode();// 显示二维码图片 } this.login();// 登录操作 if (!TextUtils.isBlank(redirectUri)) {// 跳转到登录后页面 this.wxNewLoginPage(); } if (!TextUtils.isBlank(skey)) {// 初始化微信 this.wxInit(); } if (syncKeyJsonObject != null) {// 开启微信状态通知 this.wxStatusNotify(); this.listenMsg(); } }
Example #12
Source File: RootWindow.java From WIFIADB with Apache License 2.0 | 6 votes |
private boolean verifyIpText(){ for (JTextField field : mIPTextFields){ final String text = field.getText(); if(TextUtils.isBlank(text)){ return false; } try{ int ip = Integer.valueOf(text); if(ip < 0 || ip > 255){ return false; } }catch (Exception e){ e.printStackTrace(); return false; } } return true; }
Example #13
Source File: RootWindow.java From WIFIADB with Apache License 2.0 | 6 votes |
private boolean verifyPortText(){ final String text = mPort.getText(); if(TextUtils.isBlank(text)){ return false; } try { int port = Integer.valueOf(text); if(port >= 0 && port < 65535){ return true; } }catch (Exception e){ e.printStackTrace(); } return false; }
Example #14
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 #15
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 #16
Source File: HtmlUnitDomainHandler.java From htmlunit with Apache License 2.0 | 6 votes |
@Override public void parse(final SetCookie cookie, final String value) throws MalformedCookieException { Args.notNull(cookie, HttpHeader.COOKIE); if (TextUtils.isBlank(value)) { throw new MalformedCookieException("Blank or null value for domain attribute"); } // Ignore domain attributes ending with '.' per RFC 6265, 4.1.2.3 if (value.endsWith(".")) { return; } String domain = value; domain = domain.toLowerCase(Locale.ROOT); final int dotIndex = domain.indexOf('.'); if (browserVersion_.hasFeature(HTTP_COOKIE_REMOVE_DOT_FROM_ROOT_DOMAINS) && dotIndex == 0 && domain.length() > 1 && domain.indexOf('.', 1) == -1) { domain = domain.toLowerCase(Locale.ROOT); domain = domain.substring(1); } if (dotIndex > 0) { domain = '.' + domain; } cookie.setDomain(domain); }
Example #17
Source File: PluginSettingsConfigurable.java From IDEA-Native-Terminal-Plugin with MIT License | 6 votes |
public PluginSettingsConfigurable() { // Set 'chooseFolders' depend on OS, because macOS application represents a directory. terminalChooserDescriptor = new FileChooserDescriptor(true, OS.isMacOSX(), false, false, false, false); Project[] openProjects = ProjectManager.getInstance().getOpenProjects(); if (openProjects.length > 0) { project = openProjects[0]; } else { project = ProjectManager.getInstance().getDefaultProject(); } pluginSettingsForm = new PluginSettingsForm(); pluginSettings = PluginSettings.getInstance(); // FileChooserDialog support -longforus String favoriteTerminal = ""; if (pluginSettings.getState() != null) { favoriteTerminal = pluginSettings.getState().getFavoriteTerminal(); } if (!TextUtils.isEmpty(favoriteTerminal)) { selectedTerminal = VirtualFileManager.getInstance().findFileByUrl(getFileUrl(favoriteTerminal)); } pluginSettingsForm.getTerminalFileChooserButton().addActionListener(e -> { VirtualFile[] chosenTerminals = new FileChooserDialogImpl(terminalChooserDescriptor, project) .choose(project, selectedTerminal); if (chosenTerminals.length > 0) { VirtualFile file = chosenTerminals[0]; if (file != null) { String canonicalPath = file.getCanonicalPath(); Terminal terminal = Terminal.fromString(canonicalPath); if (terminal == Terminal.GENERIC) { Messages.showWarningDialog(warningMessage, "Warning"); } selectedTerminal = file; pluginSettingsForm.getFavoriteTerminalField().setText(canonicalPath); } } }); }
Example #18
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 #19
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 #20
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 #21
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 #22
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 #23
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 #24
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); }
Example #25
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 #26
Source File: Settings.java From weex-language-support with MIT License | 5 votes |
public static WeexTag[] getRules() { String path = PropertiesComponent.getInstance().getValue(KEY_RULES_PATH, ""); if (!TextUtils.isEmpty(path)) { try { return load(path); } catch (Exception e) { return null; } } return null; }
Example #27
Source File: App.java From JtSQL with Apache License 2.0 | 5 votes |
private static void doExec(String code) { if (TextUtils.isEmpty(code)) { LogUtil.write("error", "no code!!!"); return; } try { engine.exec(code); } catch (Exception ex) { LogUtil.write("error", engine.last_sql()); ex.printStackTrace(); } }
Example #28
Source File: ConvertBridge.java From GsonFormat with Apache License 2.0 | 5 votes |
private String convertSerializedName(String fieldName) { if (Config.getInstant().isUseFieldNamePrefix() && !TextUtils.isEmpty(Config.getInstant().getFiledNamePreFixStr())) { fieldName = Config.getInstant().getFiledNamePreFixStr() + "_" + fieldName; } return fieldName; }
Example #29
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 #30
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; }