Java Code Examples for org.apache.http.util.TextUtils

The following examples show how to use org.apache.http.util.TextUtils. These examples are extracted from open source projects. 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 Project: htmlunit   Source File: HtmlUnitDomainHandler.java    License: Apache License 2.0 6 votes vote down vote up
@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 2
Source Project: GoogleTranslation   Source File: GoogleTranslation.java    License: Apache License 2.0 6 votes vote down vote up
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 3
Source Project: ReciteWords   Source File: ReciteWords.java    License: MIT License 6 votes vote down vote up
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 4
/**
 * 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 5
Source Project: weex-language-support   Source File: Settings.java    License: MIT License 6 votes vote down vote up
@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 6
Source Project: weex-language-support   Source File: Attribute.java    License: MIT License 6 votes vote down vote up
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 7
Source Project: instamojo-java   Source File: ApiContext.java    License: MIT License 6 votes vote down vote up
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 8
Source Project: WIFIADB   Source File: RootWindow.java    License: Apache License 2.0 6 votes vote down vote up
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 9
Source Project: WIFIADB   Source File: RootWindow.java    License: Apache License 2.0 6 votes vote down vote up
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 10
Source Project: MVPManager   Source File: EditorMVPDialog.java    License: MIT License 6 votes vote down vote up
/**
 * 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 11
Source Project: WxBot   Source File: WxBot.java    License: GNU General Public License v3.0 6 votes vote down vote up
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 Project: message_interface   Source File: WXUserService.java    License: MIT License 6 votes vote down vote up
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 13
Source Project: GsonFormat   Source File: ClassEntity.java    License: Apache License 2.0 6 votes vote down vote up
@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 14
Source Project: GsonFormat   Source File: ConvertBridge.java    License: Apache License 2.0 6 votes vote down vote up
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 15
Source Project: GsonFormat   Source File: LombokProcessor.java    License: Apache License 2.0 6 votes vote down vote up
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 16
Source Project: GsonFormat   Source File: AutoValueProcessor.java    License: Apache License 2.0 6 votes vote down vote up
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 17
Source Project: GsonFormat   Source File: Processor.java    License: Apache License 2.0 6 votes vote down vote up
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 18
Source Project: GsonFormat   Source File: JsonDialog.java    License: Apache License 2.0 6 votes vote down vote up
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 19
Source Project: GsonFormat   Source File: StringUtils.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 转成驼峰
 *
 * @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 20
Source Project: restcountries   Source File: StripeRest.java    License: Mozilla Public License 2.0 6 votes vote down vote up
@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 21
Source Project: swagger-showdoc   Source File: OkHttpUtil.java    License: Apache License 2.0 5 votes vote down vote up
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 22
Source Project: TinyPngPlugin   Source File: TinyPngExtension.java    License: Apache License 2.0 5 votes vote down vote up
@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 23
Source Project: AndroidLocalizePlugin   Source File: LanguageHelper.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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 24
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 25
Source Project: JtSQL   Source File: App.java    License: Apache License 2.0 5 votes vote down vote up
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 26
Source Project: AndroidGodEye   Source File: OpenAction.java    License: Apache License 2.0 5 votes vote down vote up
@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 27
Source Project: weex-language-support   Source File: Settings.java    License: MIT License 5 votes vote down vote up
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 28
Source Project: MVPManager   Source File: EditorMVPDialog.java    License: MIT License 5 votes vote down vote up
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 29
Source Project: MVPManager   Source File: EditorMVPDialog.java    License: MIT License 5 votes vote down vote up
private void fillMultiPackageTree(DefaultMutableTreeNode root)
{
    String name = contractName.getText();

    DefaultMutableTreeNode contract  = new DefaultMutableTreeNode(ClassHelper.PACKAGE_CONTRACT);
    DefaultMutableTreeNode presenter = new DefaultMutableTreeNode(ClassHelper.PACKAGE_PRESENTER);
    DefaultMutableTreeNode model     = new DefaultMutableTreeNode(ClassHelper.PACKAGE_MODEL);

    if (viewPackageName.getSelectedItem() != null)
    {
        String viewPackage = viewPackageName.getSelectedItem().toString();
        DefaultMutableTreeNode view  = new DefaultMutableTreeNode(viewPackage);
        view     .add(new DefaultMutableTreeNode(TextUtils.isEmpty(viewImpName.getText()) ? "(Please input Activity/Fragment!)" : viewImpName.getText() + ".java"));
        root.add(view);
    } else
    {
        root     .add(new DefaultMutableTreeNode(TextUtils.isEmpty(viewImpName.getText()) ? "(Please input Activity/Fragment!)" : viewImpName.getText() + ".java"));
    }

    contract .add(new DefaultMutableTreeNode(name + ClassHelper.CONTRACT  + ".java"));
    presenter.add(new DefaultMutableTreeNode(name + ClassHelper.PRESENTER + ".java"));
    model    .add(new DefaultMutableTreeNode(name + ClassHelper.MODEL     + ".java"));

    root.add(contract);
    root.add(presenter);
    root.add(model);

}
 
Example 30
Source Project: message_interface   Source File: OfficialAccountController.java    License: MIT License 5 votes vote down vote up
/**
 * 处理来自微信的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;
}