krysalis-update/src/java/org/krysalis/depot/update/util/net/select AbstractVrlSelector.java,NONE,1.1 MatchingVrlSelector.java,NONE,1.1 ProtocolVrlSelector.java,NONE,1.1 ChildVrlSelector.java,NONE,1.1
Nick Chalko <[email protected]> Wed, 08 Dec 2004 09:06:53 +0000
| Newsgroups | gmane.comp.krysalis.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/krysalis/krysalis-update/src/java/org/krysalis/depot/update/util/net/select
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24726/src/java/org/krysalis/depot/update/util/net/select
Added Files:
AbstractVrlSelector.java MatchingVrlSelector.java
ProtocolVrlSelector.java ChildVrlSelector.java
Log Message:
Copied from the apache incubator.
--- NEW FILE: ChildVrlSelector.java ---
/*
* Copyright 2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.krysalis.depot.update.util.net.select;
import org.krysalis.depot.update.util.net.VirtualResourceLocator;
import org.krysalis.depot.update.util.text.MessageConstants;
import org.krysalis.depot.update.util.text.Messages;
/**
* @author arb_jack
*/
public class ChildVrlSelector extends AbstractVrlSelector {
private VirtualResourceLocator m_parent = null;
/**
* @param expression
*/
public ChildVrlSelector(VirtualResourceLocator parent) {
super(Messages.getString(MessageConstants.NAME_SELECTOR));
m_parent = parent;
}
public boolean selectVrl(VirtualResourceLocator vrl) {
final VirtualResourceLocator parent = vrl.getParent();
return (parent.equals(m_parent));
}
public String toString() {
return super.toString() + ":" + m_parent;
}
}
--- NEW FILE: MatchingVrlSelector.java ---
/*
* Copyright 2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.krysalis.depot.update.util.net.select;
import org.krysalis.depot.update.util.net.VirtualResourceLocator;
import org.krysalis.depot.update.util.regexp.RegularExpression;
import org.krysalis.depot.update.util.regexp.RegularExpressionSelector;
import org.krysalis.depot.update.util.text.MessageConstants;
import org.krysalis.depot.update.util.text.Messages;
/**
* @author arb_jack
*/
public class MatchingVrlSelector extends AbstractVrlSelector {
private RegularExpressionSelector m_regexp = null;
/**
* @param expression
*/
public MatchingVrlSelector(String expression) {
this(new RegularExpressionSelector(expression));
}
/**
* @param expression
*/
public MatchingVrlSelector(RegularExpression expression) {
super(Messages.getString(MessageConstants.MATCHING_VRL_SELECTOR));
m_regexp = new RegularExpressionSelector(expression);
}
/**
* @param expression
*/
public MatchingVrlSelector(RegularExpressionSelector selector) {
super(Messages.getString(MessageConstants.MATCHING_VRL_SELECTOR));
m_regexp = selector;
}
public boolean selectVrl(VirtualResourceLocator vrl) {
return m_regexp.select(vrl.toExternalForm());
}
public String toString() {
return super.toString() + ":" + m_regexp;
}
}
--- NEW FILE: ProtocolVrlSelector.java ---
/*
* Copyright 2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.krysalis.depot.update.util.net.select;
import java.util.Set;
import org.krysalis.depot.update.util.net.VirtualResourceLocator;
import org.krysalis.depot.update.util.text.MessageConstants;
import org.krysalis.depot.update.util.text.Messages;
/**
* @author arb_jack
*/
public class ProtocolVrlSelector extends AbstractVrlSelector {
private Set m_protocols = null;
/**
* @param expression
*/
public ProtocolVrlSelector(Set protocols) {
super(Messages.getString(MessageConstants.PROTOCOL_VRL_SELECTOR));
m_protocols = protocols;
}
public boolean selectVrl(VirtualResourceLocator vrl) {
return m_protocols.contains(vrl.getProtocol());
}
public String toString() {
return super.toString() + ":" + m_protocols;
}
}
--- NEW FILE: AbstractVrlSelector.java ---
/*
* Copyright 2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.krysalis.depot.update.util.net.select;
import org.krysalis.depot.update.util.net.VirtualResourceLocator;
import org.krysalis.depot.update.util.select.ISelector;
import org.krysalis.depot.update.util.text.MessageConstants;
import org.krysalis.depot.update.util.text.Messages;
import org.krysalis.depot.common.util.SystemUtils;
/**
* @author arb_jack
*/
public abstract class AbstractVrlSelector implements ISelector {
private String m_description = null;
protected AbstractVrlSelector(String description) {
m_description = description;
}
public boolean select(final Object object) {
boolean selected = false;
if (object instanceof VirtualResourceLocator) {
selected = selectVrl((VirtualResourceLocator) object);
}
else {
throw new IllegalArgumentException(
Messages.getString(
MessageConstants.WRONG_TYPE,
object.getClass().getName(),
VirtualResourceLocator.class.getName()));
}
return selected;
}
public String toString() {
return SystemUtils.getShortName(getClass()) + ":" + m_description;
}
public abstract boolean selectVrl(final VirtualResourceLocator resource);
}
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://productguide.itmanagersjournal.com/