Java tutorial
/** * This file is part of PaxmlCore. * * PaxmlCore is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * PaxmlCore is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with PaxmlCore. If not, see <http://www.gnu.org/licenses/>. */ package org.paxml.launch; import org.apache.commons.io.FilenameUtils; /** * Matcher class. * * @author Xuetao Niu * */ public class Matcher { private volatile boolean matchPath; private volatile String pattern; public boolean isMatchPath() { return matchPath; } public void setMatchPath(boolean matchPath) { this.matchPath = matchPath; } public String getPattern() { return pattern; } public void setPattern(String pattern) { this.pattern = pattern; } /** * Match path with wildcard pattern. * * @param str * the path or name * @return true if matches, false if not */ public boolean match(String str) { return FilenameUtils.wildcardMatch(str, pattern); } /** * {@inheritDoc} */ @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((pattern == null) ? 0 : pattern.hashCode()); return result; } /** * {@inheritDoc} */ @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } Matcher other = (Matcher) obj; if (pattern == null) { if (other.pattern != null) { return false; } } else if (!pattern.equals(other.pattern)) { return false; } return true; } /** * {@inheritDoc} */ @Override public String toString() { return "Matcher [matchPath=" + matchPath + ", pattern=" + pattern + "]"; } }