Example usage for java.util.regex Pattern MULTILINE

List of usage examples for java.util.regex Pattern MULTILINE

Introduction

In this page you can find the example usage for java.util.regex Pattern MULTILINE.

Prototype

int MULTILINE

To view the source code for java.util.regex Pattern MULTILINE.

Click Source Link

Document

Enables multiline mode.

Usage

From source file:io.mapzone.controller.ui.StartPanel.java

protected void createFrontpageContents() {
    parent.setLayout(FormLayoutFactory.defaults().spacing(10).margins(10, 0, 10, 0).create());

    ContentProvider cp = ContentProvider.instance();
    List<String> specials = Lists.newArrayList("1welcome", "99bottom");

    // banner//from w w  w  .j  a va2  s  . c  o m
    Composite banner = tk().createComposite(parent, SWT.BORDER);
    banner.setBackground(UIUtils.getColor(60, 70, 80));
    FormDataFactory.on(banner).fill().noBottom(); //.height( 200 )
    banner.setLayout(FormLayoutFactory.defaults().margins(0, 0).create());

    Label welcome = new Label(banner, SWT.WRAP) {
        @Override
        public Point computeSize(int wHint, int hHint, boolean changed) {
            // suppress default text size computation in order to avoid flickering
            // caused by client side font size determination
            double area = 596 * 222;
            int height = Math.max(Math.min((int) (area / wHint), 350), 250);
            Point result = new Point(wHint, height);
            //log.info( "" + result );
            return result;
        }
    };
    tk().adapt(welcome, false, false);
    String welcomeContent = cp.findContent("frontpage/1welcome.md").content();
    welcome.setText(tk().markdownToHtml(welcomeContent, welcome));
    on(welcome).fill().left(10).right(60);

    // btn
    Matcher matcher = Pattern.compile("^button.text=(.+)$", Pattern.MULTILINE).matcher(welcomeContent);
    String btnText = matcher.find() ? matcher.group(1) : "Join...";
    Composite btnContainer = tk().createComposite(banner);
    FormDataFactory.on(btnContainer).fill().left(65).right(100);
    btnContainer.setLayout(FormLayoutFactory.defaults().create());
    Control filled = on(tk().createComposite(btnContainer)).fill().control();
    Button btn = on(tk().createButton(btnContainer, btnText, SWT.PUSH)).top(filled, 0, Alignment.CENTER)
            .left(10).height(45).width(135).control();
    btn.setToolTipText("Create an accountTest drive mapzone for free");
    btn.moveAbove(null);
    btn.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent ev) {
            getContext().openPanel(site().path(), RegisterPanel.ID);
        }
    });
    welcome.moveAbove(null);

    // article grid
    Composite grid = on(tk().createComposite(parent)).fill().top(banner).bottom(100, -80).control();
    LayoutSupplier layoutPrefs = BatikApplication.instance().getAppDesign().getPanelLayoutPreferences();
    grid.setLayout(new ConstraintLayout(layoutPrefs).setMaxColumns(3));

    for (ContentObject co : cp.listContent("frontpage")) {
        if (co.contentType().startsWith("text") && !specials.contains(co.name())) {
            createArticleSection(grid, co);
        }
    }

    // bottom links
    Composite bottom = on(tk().createComposite(parent)).fill().top(100, -40).control();
    bottom.setLayout(FormLayoutFactory.defaults().create());
    filled = on(tk().createComposite(bottom)).fill().control();
    on(tk().createFlowText(bottom, cp.findContent("frontpage/99bottom.md").content())).fill()
            .left(filled, 0, Alignment.CENTER).control().moveAbove(null);
}

From source file:org.eclim.plugin.pydev.project.PydevProjectManager.java

@Override
public List<Error> update(IProject project, CommandLine commandLine) throws Exception {
    PythonNature nature = PythonNature.getPythonNature(project);
    // force a reload of .pydevproject
    nature.setProject(project);//from   w w w  .  j ava2 s . c om

    // call refresh to ensure the project interpreter is validated properly
    refresh(project, commandLine);

    String dotPydevProject = project.getFile(PYDEVPROJECT).getRawLocation().toOSString();
    FileOffsets offsets = FileOffsets.compile(dotPydevProject);
    String contents = IOUtils.toString(new FileInputStream(dotPydevProject));

    Tuple<List<ProjectConfigError>, IInterpreterInfo> configErrorsAndInfo = nature
            .getConfigErrorsAndInfo(project);
    ArrayList<Error> errors = new ArrayList<Error>();
    for (ProjectConfigError e : configErrorsAndInfo.o1) {
        String message = e.getLabel();
        int line = 1;
        int col = 1;
        // attempt to locate the line the error occurs on.
        for (Pattern pattern : new Pattern[] { NOT_FOUND, INVALID }) {
            Matcher matcher = pattern.matcher(message);
            // extract the value that is triggering the error (path, interpreter
            // name, etc.).
            String value = null;
            if (matcher.find()) {
                value = matcher.group(1).trim();
                matcher = Pattern.compile(">\\s*(\\Q" + value + "\\E)\\b", Pattern.MULTILINE).matcher(contents);
                if (matcher.find()) {
                    int[] position = offsets.offsetToLineColumn(matcher.start(1));
                    line = position[0];
                    col = position[1];
                }
                break;
            }
        }

        errors.add(new Error(message, dotPydevProject, line, col, false));
    }

    return errors;
}

From source file:org.parosproxy.paros.core.spider.SpiderParam.java

private void parseSkipURL(String skipURL) {
    patternSkipURL = null;//  w  w  w.j av  a2  s. c o m

    if (skipURL == null || skipURL.equals("")) {
        return;
    }

    skipURL = skipURL.replaceAll("\\.", "\\\\.");
    skipURL = skipURL.replaceAll("\\*", ".*?").replaceAll("(\\s+$)|(^\\s+)", "");
    skipURL = "\\A(" + skipURL.replaceAll("\\s+", "|") + ")";
    patternSkipURL = Pattern.compile(skipURL, Pattern.CASE_INSENSITIVE | Pattern.MULTILINE);

}

From source file:com.canoo.webtest.plugins.emailtest.EmailMessageContentFilter.java

private byte[] getRawBytes(final String content, final int partIndex) throws MessagingException {
    // iterate over string looking for ^begin ddd$
    final String lineStr = "(^.*$)";
    final String startUuencodeStr = "begin \\d\\d\\d .*";
    final String endUuencodeStr = "^end.*";
    final Pattern linePattern = Pattern.compile(lineStr, Pattern.MULTILINE);
    final Matcher matcher = linePattern.matcher(content);
    boolean extracting = false;
    int count = 0;
    final StringBuffer buf = new StringBuffer();
    while (matcher.find()) {
        final String line = matcher.group(0);
        if (extracting) {
            if (line.matches(endUuencodeStr)) {
                buf.append(" \n").append(line).append('\n');
                extracting = false;/* w w w.jav  a 2 s .  co m*/
                break;
            } else {
                buf.append(line).append('\n');
            }
        } else if (line.matches(startUuencodeStr)) {
            if (count++ == partIndex) {
                extracting = true;
                buf.append(line).append('\n');
                final int lastSpace = line.lastIndexOf(" ");
                fFilename = line.substring(lastSpace + 1);
            }
        }
    }
    if (buf.length() == 0) {
        throw new StepFailedException("Unable to find part with index " + partIndex + ".");
    }
    LOG.debug("buf=" + buf.toString());
    return buf.toString().getBytes();
}

From source file:org.openanzo.jdbc.opgen.ant.DDLTask.java

private void writeFile(Writer writer, String filename, String file, String outputFormat)
        throws FileNotFoundException, IOException {
    Reader in = new InputStreamReader(new FileInputStream(file), "UTF-8");
    LineNumberReader lnr = new LineNumberReader(in);
    StringBuilder content = new StringBuilder();
    String line;// ww  w .ja v  a 2 s .  co m
    while ((line = lnr.readLine()) != null) {
        line = StringUtils.trim(line);
        if (line.length() == 0 || line.startsWith("#"))
            continue;
        line = Pattern.compile("[\\s+]", Pattern.MULTILINE).matcher(line).replaceAll(" ");
        line = Pattern.compile(";+", Pattern.MULTILINE).matcher(line).replaceAll(";;");
        line = Pattern.compile("&sc", Pattern.MULTILINE).matcher(line).replaceAll(";");
        line = Pattern.compile("&plus", Pattern.MULTILINE).matcher(line).replaceAll("+");
        content.append(line);
        content.append(" ");
    }
    writer.write(content.toString());
    in.close();
    lnr.close();
}

From source file:org.opennms.web.rest.AcknowledgmentRestServiceTest.java

@Test
@JUnitTemporaryDatabase// w ww . j  av  a  2 s  .c  o  m
public void testAcknowlegeAlarm() throws Exception {
    final Pattern p = Pattern.compile("^.*<ackTime>(.*?)</ackTime>.*$", Pattern.DOTALL & Pattern.MULTILINE);
    sendData(POST, MediaType.APPLICATION_FORM_URLENCODED, "/acks", "alarmId=1&action=ack");
    String xml = sendRequest(GET, "/alarms/1", new HashMap<String, String>(), 200);
    Matcher m = p.matcher(xml);
    assertTrue(m.matches());
    assertTrue(m.group(1).length() > 0);
    sendData(POST, MediaType.APPLICATION_FORM_URLENCODED, "/acks", "alarmId=1&action=unack");
    xml = sendRequest(GET, "/alarms/1", new HashMap<String, String>(), 200);
    m = p.matcher(xml);
    assertFalse(m.matches());
}

From source file:apm.common.utils.StringUtils.java

public static String getClearWhereSQL(String table_sql_temp) {
    Pattern p = Pattern.compile("\\s*where\\s*1\\s*=\\s*1\\s*and?",
            Pattern.CASE_INSENSITIVE | Pattern.MULTILINE);
    table_sql_temp = p.matcher(table_sql_temp).replaceAll(" _W_H_E_R_E_ ");
    p = Pattern.compile("\\s*where\\s*1\\s*=\\s*1\\s*", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE);
    table_sql_temp = p.matcher(table_sql_temp).replaceAll(" ");
    p = Pattern.compile(" _W_H_E_R_E_ ", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE);
    table_sql_temp = p.matcher(table_sql_temp).replaceAll(" WHERE ");
    return table_sql_temp;
}

From source file:org.sonar.dotnet.tools.commons.visualstudio.ModelFactory.java

private static List<String> getBuildConfigurations(String solutionContent) {
    // A pattern to extract the build configurations from a visual studio solution
    String confExtractExp = "(\tGlobalSection\\(SolutionConfigurationPlatforms\\).*?^\tEndGlobalSection$)";
    Pattern confExtractPattern = Pattern.compile(confExtractExp, Pattern.MULTILINE + Pattern.DOTALL);
    List<String> buildConfigurations = new ArrayList<String>();
    // Extracts all the projects from the solution
    Matcher blockMatcher = confExtractPattern.matcher(solutionContent);
    if (blockMatcher.find()) {
        String buildConfigurationBlock = blockMatcher.group(1);
        String buildConfExtractExp = " = (.*)\\|";
        Pattern buildConfExtractPattern = Pattern.compile(buildConfExtractExp);
        Matcher buildConfMatcher = buildConfExtractPattern.matcher(buildConfigurationBlock);
        while (buildConfMatcher.find()) {
            String buildConfiguration = buildConfMatcher.group(1);
            buildConfigurations.add(buildConfiguration);
        }//from w  ww .ja v a 2  s.  co  m
    }
    return buildConfigurations;
}

From source file:de.unidue.inf.is.ezdl.gframedl.utils.HighlightingUtils.java

/**
 * Returns {@link Matcher} for highlighting.
 * //from  ww  w  .  j  av a2 s .  co m
 * @param highlightStrings
 * @param escapeHighlightStrings
 * @param stringToHighlight
 * @param highlightOnlyWords
 *            true, if only words should be highlighted
 * @return
 */
public static Matcher matcher(List<String> highlightStrings, boolean escapeHighlightStrings,
        String stringToHighlight, boolean highlightOnlyWords) {
    if (stringToHighlight == null || highlightStrings.isEmpty()
            || highlightStrings.size() == 1 && highlightStrings.get(0).isEmpty()) {
        return null;
    }

    String p = highlightOnlyWords ? "\\b(" : "(";
    for (int i = 0; i < highlightStrings.size(); i++) {
        String queryTerm = highlightStrings.get(i);
        if (escapeHighlightStrings) {
            p += Pattern.quote(queryTerm);
        } else {
            p += queryTerm;

        }
        if (i < highlightStrings.size() - 1) {
            p += "|";
        }
    }
    p += highlightOnlyWords ? ")\\b" : ")";
    Pattern pattern = Pattern.compile(p, Pattern.CASE_INSENSITIVE | Pattern.MULTILINE);
    Matcher matcher = pattern.matcher(stringToHighlight);
    return matcher;
}

From source file:com.asual.summer.core.faces.FacesResponseWriter.java

private void printTextIfNecessary(boolean end) throws IOException {
    String textStr = textWriter.toString();
    if (StringUtils.hasText(textStr)) {
        String name = nodeDepth[depth];
        textStr = textStr.replaceAll("\t", INDENT);
        if (ComponentUtils.isStyleOrScript(name)) {
            textStr = Pattern.compile("^\\s{" + calculateIndent(textStr) + "}", Pattern.MULTILINE)
                    .matcher(textStr).replaceAll(getIndent(depth)).trim();
        }//w  ww . j  a va  2s.c om
        if (block.contains(name) && !pre.contains(name)) {
            Matcher m = Pattern.compile("^( *\\n)+.*", Pattern.DOTALL).matcher(textStr);
            if (m.matches()) {
                textStr = m.replaceFirst("$1") + getIndent(depth) + StringUtils.trimLeadingWhitespace(textStr);
            } else if (start) {
                textStr = "\n" + getIndent(depth) + StringUtils.trimLeadingWhitespace(textStr);
            }
            m = Pattern.compile(".*(\\n)+ *$", Pattern.DOTALL).matcher(textStr);
            if (m.matches()) {
                textStr = StringUtils.trimTrailingWhitespace(textStr) + m.replaceFirst("$1") + getIndent(depth);
            }
        }
        if (end) {
            textStr = StringUtils.trimTrailingWhitespace(textStr);
        }
        writer.write(textStr);
        textWriter.getBuffer().setLength(0);
        start = false;

        nodeDepth[depth + 1] = null;
        for (int i = 0; i < depth + 1; i++) {
            nodeDepthContent[i] = true;
        }
    }
}