krysalis-update/src/java/org/krysalis/depot/update/artifact/select ConstraintSet.java,NONE,1.1 VersionSelector.java,NONE,1.1 FilenameSelector.java,NONE,1.1 NameSelector.java,NONE,1.1 AbstractArtifactSelector.java,NONE,1.1 ReleaseLevelSelector.java,NONE,1.1 TypeSelector.java,NONE,1.1 ConstraintResultSet.java,NONE,1.1 StandardSelections.java,NONE,1.1 ConstraintEvaluator.java,NONE,1.1 VersionConstraintsSelector.java,NONE,1.1
Nick Chalko <[email protected]> Wed, 08 Dec 2004 09:07:13 +0000
| Newsgroups | gmane.comp.krysalis.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/krysalis/krysalis-update/src/java/org/krysalis/depot/update/artifact/select
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24726/src/java/org/krysalis/depot/update/artifact/select
Added Files:
ConstraintSet.java VersionSelector.java FilenameSelector.java
NameSelector.java AbstractArtifactSelector.java
ReleaseLevelSelector.java TypeSelector.java
ConstraintResultSet.java StandardSelections.java
ConstraintEvaluator.java VersionConstraintsSelector.java
Log Message:
Copied from the apache incubator.
--- NEW FILE: VersionSelector.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.artifact.select;
import org.krysalis.depot.update.ArtifactInstance;
import org.krysalis.depot.update.util.text.MessageConstants;
import org.krysalis.depot.update.util.text.Messages;
import org.krysalis.version.Version;
/**
* @author arb_jack
*/
public class VersionSelector extends AbstractArtifactSelector {
Version m_comparisonVersion = null;
/**
* @param expression
*/
public VersionSelector(Version comparisonVersion) {
super(Messages.getString(MessageConstants.VERSION_SELECTOR));
m_comparisonVersion = comparisonVersion;
}
public boolean selectArtifact(ArtifactInstance artifact) {
boolean selected = false;
Version version = artifact.getArtifact().getVersion();
if (null != version) {
//:TODO: More features...
selected = version.isCompatible(m_comparisonVersion);
}
return selected;
}
public String toString() {
return super.toString() + ":" + m_comparisonVersion.toString();
}
}
--- NEW FILE: VersionConstraintsSelector.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.artifact.select;
import org.krysalis.depot.common.log.Logger;
import org.krysalis.depot.update.ArtifactInstance;
import org.krysalis.depot.update.util.text.MessageConstants;
import org.krysalis.depot.update.util.text.Messages;
import org.krysalis.version.Version;
import org.krysalis.version.impl.apache.ApacheVersion;
/**
* @author arb_jack
*/
public class VersionConstraintsSelector extends AbstractArtifactSelector {
ConstraintSet m_constraints = null;
/**
* @param expression
*/
public VersionConstraintsSelector(ConstraintSet constraints) {
super(Messages.getString(MessageConstants.VERSION_SELECTOR));
m_constraints = constraints;
}
public boolean selectArtifact(ArtifactInstance artifact) {
boolean selected = false;
Logger log = Logger.g_loggingOn ? Logger.getLogger() : null;
Version version = artifact.getArtifact().getVersion();
if (null != version) {
//:TODO: More features...
if (version instanceof ApacheVersion) {
ConstraintResultSet resultSet =
ConstraintEvaluator.evaluate(
((ApacheVersion) version),
m_constraints);
selected = !resultSet.hasErrors();
log.debug(
"Selected ["
+ m_constraints.getName()
+ "] ["
+ ((ApacheVersion) version)
+ "] ["
+ selected
+ "]");
}
else
log.debug(
"Non-ApacheVersion " + version.getClass().getName());
}
else
log.debug("No Version on " + artifact);
return selected;
}
public String toString() {
return super.toString()
+ ": [Leval= "
+ m_constraints.toString()
+ "]";
}
}
--- NEW FILE: NameSelector.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.artifact.select;
import org.krysalis.depot.update.ArtifactInstance;
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 NameSelector extends AbstractArtifactSelector {
RegularExpressionSelector m_regexp = null;
/**
* @param expression
*/
public NameSelector(String expression) {
super(Messages.getString(MessageConstants.NAME_SELECTOR));
m_regexp = new RegularExpressionSelector(expression);
}
/**
* @param expression
*/
public NameSelector(RegularExpression expression) {
super(Messages.getString(MessageConstants.NAME_SELECTOR));
m_regexp = new RegularExpressionSelector(expression);
}
public boolean selectArtifact(ArtifactInstance artifact) {
return m_regexp.select(artifact.getIdentifier().getId());
}
public String toString() {
return super.toString() + ":" + m_regexp;
}
}
--- NEW FILE: StandardSelections.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.artifact.select;
import org.krysalis.depot.update.Artifact;
import org.krysalis.depot.update.util.select.ISelector;
import org.krysalis.depot.update.util.select.logic.AndSelector;
/**
* @author arb_jack
*/
public class StandardSelections {
/**
* @param resource - -a specifier
* @return
*/
public static ISelector getNamedTypedVersion(Artifact artifact) {
AndSelector set = new AndSelector();
set.addSelector(new NameSelector(artifact.getIdentifier().getId()));
set.addSelector(new TypeSelector(artifact.getType()));
if (null != artifact.getVersion()) {
set.addSelector(new VersionSelector(artifact.getVersion()));
}
return set;
}
}
--- NEW FILE: ConstraintSet.java ---
/*
* Created on Dec 8, 2004
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package org.krysalis.depot.update.artifact.select;
/**
* @author nick
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class ConstraintSet {
/**
* @return
*/
public String getName() {
// TODO Auto-generated method stub
return null;
}
}
--- NEW FILE: TypeSelector.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.artifact.select;
import org.krysalis.depot.update.ArtifactInstance;
import org.krysalis.depot.update.artifact.ArtifactType;
import org.krysalis.depot.update.util.text.MessageConstants;
import org.krysalis.depot.update.util.text.Messages;
/**
* @author arb_jack
*/
public class TypeSelector extends AbstractArtifactSelector {
ArtifactType m_comparisonType = null;
/**
* @param expression
*/
public TypeSelector(ArtifactType comparisonType) {
super(Messages.getString(MessageConstants.TYPE_SELECTOR));
m_comparisonType = comparisonType;
}
public boolean selectArtifact(ArtifactInstance artifact) {
boolean selected = false;
ArtifactType type = artifact.getArtifact().getType();
if (null != type) {
//:TODO: More features...
selected = m_comparisonType.equals(type);
}
return selected;
}
public String toString() {
return super.toString() + ":" + m_comparisonType.toString();
}
}
--- NEW FILE: AbstractArtifactSelector.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.artifact.select;
import org.krysalis.depot.common.util.SystemUtils;
import org.krysalis.depot.update.ArtifactInstance;
import org.krysalis.depot.update.util.select.ISelector;
import org.krysalis.depot.update.util.text.MessageConstants;
import org.krysalis.depot.update.util.text.Messages;
/**
* @author arb_jack
*/
public abstract class AbstractArtifactSelector implements ISelector {
private String m_description = null;
protected AbstractArtifactSelector(String description) {
m_description = description;
}
public boolean select(final Object object) {
boolean selected = false;
if (object instanceof ArtifactInstance) {
selected = selectArtifact((ArtifactInstance) object);
}
else {
throw new IllegalArgumentException(
Messages.getString(
MessageConstants.WRONG_TYPE,
object.getClass().getName(),
ArtifactInstance.class.getName()));
}
return selected;
}
public String toString() {
return SystemUtils.getShortName(getClass());
}
public abstract boolean selectArtifact(final ArtifactInstance artifact);
}
--- NEW FILE: ConstraintResultSet.java ---
/*
* Created on Dec 8, 2004
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package org.krysalis.depot.update.artifact.select;
/**
* @author nick
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class ConstraintResultSet {
/**
* @return
*/
public boolean hasErrors() {
// TODO Auto-generated method stub
return false;
}
}
--- NEW FILE: ConstraintEvaluator.java ---
/*
* Created on Dec 8, 2004
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package org.krysalis.depot.update.artifact.select;
import org.krysalis.version.impl.apache.ApacheVersion;
/**
* @author nick
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class ConstraintEvaluator {
/**
* @param version
* @param m_constraints
* @return
*/
public static ConstraintResultSet evaluate(ApacheVersion version, ConstraintSet m_constraints) {
// TODO Auto-generated method stub
return null;
}
}
--- NEW FILE: ReleaseLevelSelector.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.artifact.select;
import org.krysalis.depot.common.log.Logger;
import org.krysalis.depot.update.ArtifactInstance;
import org.krysalis.depot.update.util.text.MessageConstants;
import org.krysalis.depot.update.util.text.Messages;
import org.krysalis.version.Version;
import org.krysalis.version.impl.apache.ApacheVersion;
import org.krysalis.version.impl.data.ReleaseLevel;
/**
* @author arb_jack
*/
public class ReleaseLevelSelector extends AbstractArtifactSelector {
ReleaseLevel m_comparisonLevel = null;
/**
* @param expression
*/
public ReleaseLevelSelector(org.krysalis.version.impl.data.ReleaseLevel comparisonLevel) {
super(Messages.getString(MessageConstants.VERSION_SELECTOR));
m_comparisonLevel = comparisonLevel;
}
public boolean selectArtifact(ArtifactInstance artifact) {
boolean selected = false;
Logger log = Logger.g_loggingOn ? Logger.getLogger() : null;
Version version = artifact.getArtifact().getVersion();
if (null != version) {
//:TODO: More features...
if (version instanceof ApacheVersion) {
selected =
m_comparisonLevel.compareTo(
((ApacheVersion) version).getReleaseLevelObject())
>= 0;
log.debug(
"Selected ["
+ m_comparisonLevel
+ "] ["
+ ((ApacheVersion) version).getReleaseLevel()
+ "] ["
+ selected
+ "]");
}
else
log.debug(
"Non-ApacheVersion " + version.getClass().getName());
}
else
log.debug("No Version on " + artifact);
return selected;
}
public String toString() {
return super.toString()
+ ": [Leval= "
+ m_comparisonLevel.toString()
+ "]";
}
}
--- NEW FILE: FilenameSelector.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.artifact.select;
import org.krysalis.depot.update.ArtifactInstance;
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 FilenameSelector extends AbstractArtifactSelector {
RegularExpressionSelector m_regexp = null;
/**
* @param expression
*/
public FilenameSelector(String expression) {
super(Messages.getString(MessageConstants.FILENAME_SELECTOR));
m_regexp = new RegularExpressionSelector(expression);
}
/**
* @param expression
*/
public FilenameSelector(RegularExpression expression) {
super(Messages.getString(MessageConstants.FILENAME_SELECTOR));
m_regexp = new RegularExpressionSelector(expression);
}
public boolean selectArtifact(ArtifactInstance artifact) {
return m_regexp.select(artifact.getLocator().getFilename());
}
public String toString() {
return super.toString() + ":" + m_regexp;
}
}
-------------------------------------------------------
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/