Example usage for org.apache.commons.lang StringUtils contains

List of usage examples for org.apache.commons.lang StringUtils contains

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils contains.

Prototype

public static boolean contains(String str, String searchStr) 

Source Link

Document

Checks if String contains a search String, handling null.

Usage

From source file:gda.device.detector.addetector.filewriter.FileWriterBase.java

private String substituteDatadir(String template) {

    if (StringUtils.contains(template, "$datadir$")) {
        template = StringUtils.replace(template, "$datadir$", PathConstructor.createFromDefaultProperty());
    }/*from  www  .j a va  2  s .  c  o  m*/

    return template;
}

From source file:com.microsoft.alm.plugin.external.ToolRunner.java

/**
 * Command line arguments should have all embedded double quotes repeated to escape them.
 * They should also be surrounded by double quotes if they contain a space.
 */// www.  ja v  a 2 s . c  om
private String escapeArgument(final String argument) {
    String escaped = StringUtils.replace(argument, "\"", "\"\"");
    if (StringUtils.contains(escaped, " ")) {
        escaped = "\"" + escaped + "\"";
    }
    return escaped;
}

From source file:info.magnolia.rendering.renderer.AbstractRenderer.java

protected <T extends RenderingModel<?>> T newModel(Class<T> modelClass, final Node content,
        final RenderableDefinition definition, final RenderingModel<?> parentModel) throws RenderException {

    try {/*w  ww.ja  v  a2  s . c o  m*/

        T model = Components.getComponentProvider().newInstanceWithParameterResolvers(modelClass,
                new ParameterResolver() {
                    @Override
                    public Object resolveParameter(ParameterInfo parameter) {
                        if (parameter.getParameterType().equals(Node.class)) {
                            return content;
                        }
                        if (parameter.getParameterType().isAssignableFrom(definition.getClass())) {
                            return definition;
                        }
                        if (parameter.getParameterType().equals(RenderingModel.class)) {
                            return parentModel;
                        }
                        return UNRESOLVED;
                    }
                });

        // populate the instance with values given as request parameters
        Map<String, String[]> params = MgnlContext.getWebContext().getRequest().getParameterMap();
        // needed workaround to not break rendering when there is no index between square brackets
        // see https://issues.apache.org/jira/browse/BEANUTILS-419
        Map<String, Object> filtered = new HashMap<String, Object>();
        if (params != null) {
            for (Entry<String, String[]> entry : params.entrySet()) {
                String key = entry.getKey();
                String[] value = entry.getValue();
                if (StringUtils.contains(key, "[")) {
                    key = StringUtils.substringBefore(key, "[");
                }
                filtered.put(key, value);
            }
        }

        BeanUtils.populate(model, filtered);

        return model;

    } catch (MgnlInstantiationException e) {
        throw new RenderException("Can't instantiate model: " + modelClass, e);
    } catch (InvocationTargetException e) {
        throw new RenderException("Can't create rendering model: " + ExceptionUtils.getRootCauseMessage(e), e);
    } catch (IllegalAccessException e) {
        throw new RenderException("Can't create rendering model: " + ExceptionUtils.getRootCauseMessage(e), e);
    }
}

From source file:de.tudarmstadt.ukp.dkpro.core.io.conll.ConllUReader.java

public void convert(JCas aJCas, BufferedReader aReader) throws IOException {
    if (readPos) {
        try {//w w  w.j  a  v a 2s .  com
            posMappingProvider.configure(aJCas.getCas());
        } catch (AnalysisEngineProcessException e) {
            throw new IOException(e);
        }
    }

    JCasBuilder doc = new JCasBuilder(aJCas);

    List<String[]> words;
    while ((words = readSentence(aReader)) != null) {
        if (words.isEmpty()) {
            // Ignore empty sentences. This can happen when there are multiple end-of-sentence
            // markers following each other.
            continue;
        }

        int sentenceBegin = doc.getPosition();
        int sentenceEnd = sentenceBegin;

        int surfaceBegin = -1;
        int surfaceEnd = -1;
        String surfaceString = null;

        // Tokens, Lemma, POS
        Int2ObjectMap<Token> tokens = new Int2ObjectOpenHashMap<>();
        Iterator<String[]> wordIterator = words.iterator();
        while (wordIterator.hasNext()) {
            String[] word = wordIterator.next();
            if (word[ID].contains("-")) {
                String[] fragments = word[ID].split("-");
                surfaceBegin = Integer.valueOf(fragments[0]);
                surfaceEnd = Integer.valueOf(fragments[1]);
                surfaceString = word[FORM];
                continue;
            }

            // Read token
            int tokenIdx = Integer.valueOf(word[ID]);
            Token token = doc.add(word[FORM], Token.class);
            tokens.put(tokenIdx, token);
            if (!StringUtils.contains(word[MISC], "SpaceAfter=No") && wordIterator.hasNext()) {
                doc.add(" ");
            }

            // Read lemma
            if (!UNUSED.equals(word[LEMMA]) && readLemma) {
                Lemma lemma = new Lemma(aJCas, token.getBegin(), token.getEnd());
                lemma.setValue(word[LEMMA]);
                lemma.addToIndexes();
                token.setLemma(lemma);
            }

            // Read part-of-speech tag
            POS pos = null;
            String tag = useCPosAsPos ? word[CPOSTAG] : word[POSTAG];
            if (!UNUSED.equals(tag) && readPos) {
                Type posTag = posMappingProvider.getTagType(tag);
                pos = (POS) aJCas.getCas().createAnnotation(posTag, token.getBegin(), token.getEnd());
                pos.setPosValue(tag.intern());
            }

            // Read coarse part-of-speech tag
            if (!UNUSED.equals(word[CPOSTAG]) && readCPos && pos != null) {
                pos.setCoarseValue(word[CPOSTAG].intern());
            }

            if (pos != null) {
                pos.addToIndexes();
                token.setPos(pos);
            }

            // Read morphological features
            if (!UNUSED.equals(word[FEATS]) && readMorph) {
                MorphologicalFeatures morphtag = new MorphologicalFeatures(aJCas, token.getBegin(),
                        token.getEnd());
                morphtag.setValue(word[FEATS]);
                morphtag.addToIndexes();
                token.setMorph(morphtag);

                // Try parsing out individual feature values. Since the DKPro Core
                // MorphologicalFeatures type is based on the definition from the UD project,
                // we can do this rather straightforwardly.
                Type morphType = morphtag.getType();
                String[] items = word[FEATS].split("\\|");
                for (String item : items) {
                    String[] keyValue = item.split("=");
                    StringBuilder key = new StringBuilder(keyValue[0]);
                    key.setCharAt(0, Character.toLowerCase(key.charAt(0)));
                    String value = keyValue[1];

                    Feature feat = morphType.getFeatureByBaseName(key.toString());
                    if (feat != null) {
                        morphtag.setStringValue(feat, value);
                    }
                }
            }

            // Read surface form
            if (tokenIdx == surfaceEnd) {
                int begin = tokens.get(surfaceBegin).getBegin();
                int end = tokens.get(surfaceEnd).getEnd();
                SurfaceForm surfaceForm = new SurfaceForm(aJCas, begin, end);
                surfaceForm.setValue(surfaceString);
                surfaceForm.addToIndexes();
                surfaceBegin = -1;
                surfaceEnd = -1;
                surfaceString = null;
            }

            sentenceEnd = token.getEnd();
        }

        // Dependencies
        if (readDependency) {
            for (String[] word : words) {
                if (!UNUSED.equals(word[DEPREL])) {
                    int depId = Integer.valueOf(word[ID]);
                    int govId = Integer.valueOf(word[HEAD]);

                    // Model the root as a loop onto itself
                    makeDependency(aJCas, govId, depId, word[DEPREL], DependencyFlavor.BASIC, tokens, word);
                }

                if (!UNUSED.equals(word[DEPS])) {
                    // list items separated by vertical bar
                    String[] items = word[DEPS].split("\\|");
                    for (String item : items) {
                        String[] sItem = item.split(":");

                        int depId = Integer.valueOf(word[ID]);
                        int govId = Integer.valueOf(sItem[0]);

                        makeDependency(aJCas, govId, depId, sItem[1], DependencyFlavor.ENHANCED, tokens, word);
                    }
                }
            }
        }

        // Sentence
        Sentence sentence = new Sentence(aJCas, sentenceBegin, sentenceEnd);
        sentence.addToIndexes();

        // Once sentence per line.
        doc.add("\n");
    }

    doc.close();
}

From source file:edu.ku.brc.specify.datamodel.busrules.BaseTreeBusRules.java

@SuppressWarnings("unchecked")
@Override//from   w w w  .  j a  v  a  2s.  c  o m
public boolean okToEnableDelete(Object dataObj) {
    // This is a little weak and chessey, but it gets the job done.
    // Becase both the Tree and Definition want/need to share Business Rules.
    String viewName = formViewObj.getView().getName();
    if (StringUtils.contains(viewName, "TreeDef")) {
        final I treeDefItem = (I) dataObj;
        if (treeDefItem != null && treeDefItem.getTreeDef() != null) {
            return treeDefItem.getTreeDef().isRequiredLevel(treeDefItem.getRankId());
        }
    }
    return super.okToEnableDelete(dataObj);
}

From source file:de.faustedition.maven.OddSchemaDeployMojo.java

/**
 * <p>//  www.  j  a  v a 2  s  . c o m
 * Get the <code>ProxyInfo</code> of the proxy associated with the
 * <code>host</code> and the <code>protocol</code> of the given
 * <code>repository</code>.
 * </p>
 * <p>
 * Extract from <a href=
 * "http://java.sun.com/j2se/1.5.0/docs/guide/net/properties.html"> J2SE
 * Doc : Networking Properties - nonProxyHosts</a> : "The value can be a
 * list of hosts, each separated by a |, and in addition a wildcard
 * character (*) can be used for matching"
 * </p>
 * <p>
 * Defensively support for comma (",") and semi colon (";") in addition
 * to pipe ("|") as separator.
 * </p>
 * 
 * @param repository
 *                the Repository to extract the ProxyInfo from.
 * @param wagonManager
 *                the WagonManager used to connect to the Repository.
 * @return a ProxyInfo object instantiated or <code>null</code> if no
 *         matching proxy is found
 */
public static ProxyInfo getProxyInfo(Repository repository, WagonManager wagonManager) {
    ProxyInfo proxyInfo = wagonManager.getProxy(repository.getProtocol());

    if (proxyInfo == null) {
        return null;
    }

    String host = repository.getHost();
    String nonProxyHostsAsString = proxyInfo.getNonProxyHosts();
    String[] nonProxyHosts = StringUtils.split(nonProxyHostsAsString, ",;|");
    for (int i = 0; i < nonProxyHosts.length; i++) {
        String nonProxyHost = nonProxyHosts[i];
        if (StringUtils.contains(nonProxyHost, "*")) {
            // Handle wildcard at the end, beginning or
            // middle of the nonProxyHost
            String nonProxyHostPrefix = StringUtils.substringBefore(nonProxyHost, "*");
            String nonProxyHostSuffix = StringUtils.substringAfter(nonProxyHost, "*");
            // prefix*
            if (StringUtils.isNotEmpty(nonProxyHostPrefix) && host.startsWith(nonProxyHostPrefix)
                    && StringUtils.isEmpty(nonProxyHostSuffix)) {
                return null;
            }
            // *suffix
            if (StringUtils.isEmpty(nonProxyHostPrefix) && StringUtils.isNotEmpty(nonProxyHostSuffix)
                    && host.endsWith(nonProxyHostSuffix)) {
                return null;
            }
            // prefix*suffix
            if (StringUtils.isNotEmpty(nonProxyHostPrefix) && host.startsWith(nonProxyHostPrefix)
                    && StringUtils.isNotEmpty(nonProxyHostSuffix) && host.endsWith(nonProxyHostSuffix)) {
                return null;
            }
        } else if (host.equals(nonProxyHost)) {
            return null;
        }
    }
    return proxyInfo;
}

From source file:de.tudarmstadt.ukp.clarin.webanno.conllu.ConllUReader.java

public void convert(JCas aJCas, BufferedReader aReader) throws IOException {
    if (readPos) {
        try {/* www  .  j  a  va2 s.  co  m*/
            posMappingProvider.configure(aJCas.getCas());
        } catch (AnalysisEngineProcessException e) {
            throw new IOException(e);
        }
    }

    JCasBuilder doc = new JCasBuilder(aJCas);

    List<String[]> words;
    while ((words = readSentence(aReader)) != null) {
        if (words.isEmpty()) {
            // Ignore empty sentences. This can happen when there are multiple end-of-sentence
            // markers following each other.
            continue;
        }

        int sentenceBegin = doc.getPosition();
        int sentenceEnd = sentenceBegin;

        int surfaceBegin = -1;
        int surfaceEnd = -1;
        String surfaceString = null;

        // Tokens, Lemma, POS
        Int2ObjectMap<Token> tokens = new Int2ObjectOpenHashMap<>();
        for (String[] word : words) {
            if (word[ID].contains("-")) {
                String[] fragments = word[ID].split("-");
                surfaceBegin = Integer.valueOf(fragments[0]);
                surfaceEnd = Integer.valueOf(fragments[1]);
                surfaceString = word[FORM];
                continue;
            }

            // Read token
            int tokenIdx = Integer.valueOf(word[ID]);
            Token token = doc.add(word[FORM], Token.class);
            tokens.put(tokenIdx, token);
            if (!StringUtils.contains(word[MISC], "SpaceAfter=No")) {
                doc.add(" ");
            }

            // Read lemma
            if (!UNUSED.equals(word[LEMMA]) && readLemma) {
                Lemma lemma = new Lemma(aJCas, token.getBegin(), token.getEnd());
                lemma.setValue(word[LEMMA]);
                lemma.addToIndexes();
                token.setLemma(lemma);
            }

            // Read part-of-speech tag
            if (!UNUSED.equals(word[POSTAG]) && readPos) {
                Type posTag = posMappingProvider.getTagType(word[POSTAG]);
                POS pos = (POS) aJCas.getCas().createAnnotation(posTag, token.getBegin(), token.getEnd());
                pos.setPosValue(word[POSTAG]);
                pos.addToIndexes();
                token.setPos(pos);
            }

            // Read morphological features
            if (!UNUSED.equals(word[FEATS]) && readMorph) {
                MorphologicalFeatures morphtag = new MorphologicalFeatures(aJCas, token.getBegin(),
                        token.getEnd());
                morphtag.setValue(word[FEATS]);
                morphtag.addToIndexes();
                token.setMorph(morphtag);

                // Try parsing out individual feature values. Since the DKPro Core
                // MorphologicalFeatures type is based on the definition from the UD project,
                // we can do this rather straightforwardly.
                Type morphType = morphtag.getType();
                String[] items = word[FEATS].split("\\|");
                for (String item : items) {
                    String[] keyValue = item.split("=");
                    StringBuilder key = new StringBuilder(keyValue[0]);
                    key.setCharAt(0, Character.toLowerCase(key.charAt(0)));
                    String value = keyValue[1];

                    Feature feat = morphType.getFeatureByBaseName(key.toString());
                    if (feat != null) {
                        morphtag.setStringValue(feat, value);
                    }
                }
            }

            // Read surface form
            if (tokenIdx == surfaceEnd) {
                int begin = tokens.get(surfaceBegin).getBegin();
                int end = tokens.get(surfaceEnd).getEnd();
                SurfaceForm surfaceForm = new SurfaceForm(aJCas, begin, end);
                surfaceForm.setValue(surfaceString);
                surfaceForm.addToIndexes();
                surfaceBegin = -1;
                surfaceEnd = -1;
                surfaceString = null;
            }

            sentenceEnd = token.getEnd();
        }

        // Dependencies
        if (readDependency) {
            for (String[] word : words) {
                if (!UNUSED.equals(word[DEPREL])) {
                    int depId = Integer.valueOf(word[ID]);
                    int govId = Integer.valueOf(word[HEAD]);

                    // Model the root as a loop onto itself
                    makeDependency(aJCas, govId, depId, word[DEPREL], DependencyFlavor.BASIC, tokens, word);
                }

                if (!UNUSED.equals(word[DEPS])) {
                    // list items separated by vertical bar
                    String[] items = word[DEPS].split("\\|");
                    for (String item : items) {
                        String[] sItem = item.split(":");

                        int depId = Integer.valueOf(word[ID]);
                        int govId = Integer.valueOf(sItem[0]);

                        makeDependency(aJCas, govId, depId, sItem[1], DependencyFlavor.ENHANCED, tokens, word);
                    }
                }
            }
        }

        // Sentence
        Sentence sentence = new Sentence(aJCas, sentenceBegin, sentenceEnd);
        sentence.addToIndexes();

        // Once sentence per line.
        doc.add("\n");
    }

    doc.close();
}

From source file:com.tesora.dve.sql.CurrentTimestampDefaultValueTest.java

@Test
public void testSimpleQueriesForTimestampVariable() throws Throwable {

    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.ENGLISH);

    int i = 0;/*w w w .  ja va 2s.c o m*/
    for (Object[] objects : TimestampVariableTestUtils.getTestValues()) {
        String value = (String) objects[0];
        Boolean nullable = BooleanUtils.toBoolean((Integer) objects[1]);
        String defaultValue = (String) objects[2];
        Boolean onUpdate = BooleanUtils.toBoolean((Integer) objects[3]);
        Boolean expectedInsertTSVarSet = BooleanUtils.toBoolean((Integer) objects[4]);
        Boolean expectedUpdateTSVarSet = BooleanUtils.toBoolean((Integer) objects[5]);
        Boolean ignoreTest = BooleanUtils.toBoolean((Integer) objects[6]);

        if (ignoreTest) {
            continue;
        }

        String tableName = "ts" + i;

        String createTableSQL = TimestampVariableTestUtils.buildCreateTableSQL(tableName, nullable,
                defaultValue, onUpdate);
        String insertSQL = TimestampVariableTestUtils.buildInsertTestSQL(tableName, value, 1,
                Integer.toString(i));
        String updateSQL = TimestampVariableTestUtils.buildUpdateTestSQL(tableName, value, 1,
                Integer.toString(i) + Integer.toString(i));

        ++i;

        conn.execute(createTableSQL);

        long preTestTime = TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis());

        conn.execute(insertSQL);

        ResourceResponse resp = conn.fetch("select ts from " + tableName + " where id=1");
        List<ResultRow> rows = resp.getResults();
        assertEquals("Expected one row only", 1, rows.size());
        ResultColumn rc = rows.get(0).getResultColumn(1);
        if (expectedInsertTSVarSet) {
            // if we expected to set the timestamp variable then the ts column must contain the current time
            Timestamp ts = (Timestamp) (rc.getColumnValue());
            assertTrue("Inserted time must be >= starting time",
                    preTestTime <= TimeUnit.MILLISECONDS.toSeconds(ts.getTime()));
        } else {
            boolean isNull = rc.isNull();
            if (!isNull) {
                // ts column is not null so let's see if the column value was specified and if it was it should match the ts value
                Timestamp ts = (Timestamp) (rc.getColumnValue());
                if (StringUtils.contains(value, "2000-01-01 01:02:03")) {
                    assertTrue(TimeUnit.MILLISECONDS.toSeconds(ts.getTime()) == TimeUnit.MILLISECONDS
                            .toSeconds(formatter.parse("2000-01-01 01:02:03").getTime()));
                } else if (StringUtils.equals("0", value)) {
                    assertTrue(TimeUnit.MILLISECONDS.toSeconds(ts.getTime()) == TimeUnit.MILLISECONDS
                            .toSeconds(formatter.parse("0000-00-00 00:00:00").getTime()));
                } else if (StringUtils.equals("current_timestamp", value)) {
                    assertTrue("Inserted time must be >= starting time",
                            preTestTime <= TimeUnit.MILLISECONDS.toSeconds(ts.getTime()));
                } else {
                    // if we get here column value is not specified so figure out what default value we need
                    if (StringUtils.contains(defaultValue, "2000-01-01 01:02:03")) {
                        assertTrue(TimeUnit.MILLISECONDS.toSeconds(ts.getTime()) == TimeUnit.MILLISECONDS
                                .toSeconds(formatter.parse("2000-01-01 01:02:03").getTime()));
                    } else if (StringUtils.equals("0", defaultValue)) {
                        assertTrue(TimeUnit.MILLISECONDS.toSeconds(ts.getTime()) == TimeUnit.MILLISECONDS
                                .toSeconds(formatter.parse("0000-00-00 00:00:00").getTime()));
                    } else if (StringUtils.equals("current_timestamp", defaultValue)) {
                        assertTrue("Inserted time must be >= starting time",
                                preTestTime <= TimeUnit.MILLISECONDS.toSeconds(ts.getTime()));
                    }
                }
            } else {
                // column better be nullable
                assertTrue(nullable);
                if (StringUtils.isBlank(value)) {
                    // column not specified better validate the default value
                    assertTrue(StringUtils.equals("null", defaultValue) || StringUtils.isBlank(defaultValue));
                } else {
                    // column value was specified as null
                    assertEquals("null", value);
                }
            }
        }

        long updatePreTestTime = TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis());

        conn.execute(updateSQL);
        resp = conn.fetch("select ts from " + tableName + " where id=1");
        rows = resp.getResults();
        assertEquals("Expected one row only", 1, rows.size());
        rc = rows.get(0).getResultColumn(1);
        if (expectedUpdateTSVarSet) {
            // if we expected to set the timestamp variable then the ts column must contain the current time
            Timestamp ts = (Timestamp) (rc.getColumnValue());
            assertTrue("Update time must be >= starting time",
                    updatePreTestTime <= TimeUnit.MILLISECONDS.toSeconds(ts.getTime()));
        } else {
            boolean isNull = rc.isNull();
            if (!isNull) {
                // ts column is not null so let's see if the column value was specified and if it was it should match the ts value
                Timestamp ts = (Timestamp) (rc.getColumnValue());
                if (StringUtils.contains(value, "2000-01-01 01:02:03")) {
                    assertTrue(TimeUnit.MILLISECONDS.toSeconds(ts.getTime()) == TimeUnit.MILLISECONDS
                            .toSeconds(formatter.parse("2000-01-01 01:02:03").getTime()));
                } else if (StringUtils.equals("0", value)) {
                    assertTrue(TimeUnit.MILLISECONDS.toSeconds(ts.getTime()) == TimeUnit.MILLISECONDS
                            .toSeconds(formatter.parse("0000-00-00 00:00:00").getTime()));
                } else if (StringUtils.equals("current_timestamp", value)) {
                    assertTrue("Inserted time must be >= starting time",
                            preTestTime <= TimeUnit.MILLISECONDS.toSeconds(ts.getTime()));
                } else {
                    // if we get here column value is not specified so figure out what default value we need
                    if (StringUtils.contains(defaultValue, "2000-01-01 01:02:03")) {
                        assertTrue(TimeUnit.MILLISECONDS.toSeconds(ts.getTime()) == TimeUnit.MILLISECONDS
                                .toSeconds(formatter.parse("2000-01-01 01:02:03").getTime()));
                    } else if (StringUtils.equals("0", defaultValue)) {
                        assertTrue(TimeUnit.MILLISECONDS.toSeconds(ts.getTime()) == TimeUnit.MILLISECONDS
                                .toSeconds(formatter.parse("0000-00-00 00:00:00").getTime()));
                    } else if (StringUtils.equals("current_timestamp", defaultValue)) {
                        assertTrue("Inserted time must be >= starting time",
                                preTestTime <= TimeUnit.MILLISECONDS.toSeconds(ts.getTime()));
                    }
                }
            } else {
                // column better be nullable
                assertTrue(nullable);
                if (StringUtils.isBlank(value)) {
                    // column not specified better validate the default value
                    // note in one case the default is not specified and no value was specified for the column
                    // then the column value is null so the blank default is ok
                    assertTrue(StringUtils.equals("null", defaultValue) || StringUtils.isBlank(defaultValue));
                } else {
                    // column value was specified as null
                    assertEquals("null", value);
                }
            }
        }

    }
}

From source file:gda.device.detector.addetector.filewriter.FileWriterBase.java

private String substituteScan(String template) {

    if (StringUtils.contains(template, "$scan$")) {
        long scanNumber;
        try {// w w w.  ja v  a  2  s.  c  o  m
            scanNumber = getScanNumber();
        } catch (Exception e) {
            throw new IllegalStateException("Could not determine current scan number", e);
        }
        template = StringUtils.replace(template, "$scan$", String.valueOf(scanNumber));
    }
    return template;
}

From source file:com.adobe.acs.commons.wcm.notifications.impl.SystemNotificationsImpl.java

private boolean isDismissed(final SlingHttpServletRequest request, final Page notificationPage) {
    final Cookie cookie = CookieUtil.getCookie(request, COOKIE_NAME);
    if (cookie != null) {
        return StringUtils.contains(cookie.getValue(), this.getNotificationId(notificationPage));
    } else {/*from w ww . j  a  va 2s  .c o  m*/
        // No cookie has been set, so nothing has been dismissed
        return false;
    }
}