Commit 6da86905 authored by Tom Evans's avatar Tom Evans

Archive legacy sources for Jive tools

These sources were added to support the pending Maven refactor (PR
#361). However the classes are not needed for the core compile/build.
Moved into separate archive for safekeeping.
parent 7190277e
package com.jivesoftware.tools.selector;
import com.thoughtworks.qdox.JavaDocBuilder;
import com.thoughtworks.qdox.model.ClassLibrary;
import com.thoughtworks.qdox.model.DefaultDocletTagFactory;
import com.thoughtworks.qdox.model.DocletTag;
import com.thoughtworks.qdox.model.JavaClass;
import com.thoughtworks.qdox.model.JavaSource;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.types.selectors.BaseSelectorContainer;
public abstract class BaseSelector
extends BaseSelectorContainer
{
private static Map sourcesMap = new HashMap();
private static Map packagesMap = new HashMap();
private String packages;
public boolean isSelected(File paramFile1, String paramString, File paramFile2)
throws BuildException
{
if (paramString.endsWith(".java"))
{
JavaSource[] arrayOfJavaSource = getSources(paramFile1);
for (int i = 0; i < arrayOfJavaSource.length; i++)
{
JavaSource localJavaSource = arrayOfJavaSource[i];
File localFile = new File(localJavaSource.getURL().getFile());
if ((localFile.equals(paramFile2)) && (localJavaSource.getClasses().length > 0))
{
JavaClass localJavaClass = localJavaSource.getClasses()[0];
String str = getTagName();
DocletTag localDocletTag = localJavaClass.getTagByName(str);
if (localDocletTag == null) {
return handleNoTag(localJavaClass, paramFile2);
}
System.out.println("Checking '" + str + "' tag for " + paramString);
return shouldCopy(localDocletTag.getValue());
}
}
}
else if ("javadocs.properties".equals(paramFile2.getName()))
{
return false;
}
return true;
}
private boolean handleNoTag(JavaClass paramJavaClass, File paramFile)
{
File localFile1 = paramFile.getParentFile();
String str1 = paramJavaClass.getPackage();
int i = str1.split("\\.").length;
for (int j = 0; j < i; j++)
{
File localFile2 = new File(localFile1, "javadocs.properties");
if (localFile2.exists())
{
Properties localProperties = new Properties();
try
{
localProperties.load(new FileInputStream(localFile2));
}
catch (IOException localIOException)
{
localIOException.printStackTrace();
}
String str2 = getTagName();
String str3 = localProperties.getProperty(str2);
if (str3 != null) {
return shouldCopy(str3);
}
}
localFile1 = localFile1.getParentFile();
}
return shouldCopyWithNoTag();
}
protected JavaSource[] getSources(File paramFile)
{
JavaSource[] arrayOfJavaSource = (JavaSource[])sourcesMap.get(paramFile.toString());
if (arrayOfJavaSource == null)
{
JavaDocBuilder localJavaDocBuilder = new JavaDocBuilder(new DefaultDocletTagFactory());
localJavaDocBuilder.getClassLibrary().addClassLoader(getClass().getClassLoader());
localJavaDocBuilder.addSourceTree(paramFile);
arrayOfJavaSource = localJavaDocBuilder.getSources();
sourcesMap.put(paramFile.toString(), arrayOfJavaSource);
}
return arrayOfJavaSource;
}
public void setPackages(String paramString)
{
this.packages = paramString;
}
protected abstract String getTagName();
protected abstract boolean shouldCopyWithNoTag();
protected abstract boolean shouldCopy(String paramString);
}
package com.jivesoftware.tools.selector;
public class EditionSelector
extends BaseSelector
{
public static final String EDITION_PRO = "professional";
public static final String EDITION_SILVER = "silver";
public static final String EDITION_GOLD = "gold";
String edition = "gold";
protected String getTagName()
{
return "edition";
}
protected boolean shouldCopyWithNoTag()
{
return true;
}
protected boolean shouldCopy(String paramString)
{
if ("gold".equals(this.edition)) {
return true;
}
if ("silver".equals(this.edition)) {
return !"gold".equals(paramString);
}
if ("professional".equals(this.edition))
{
if ("gold".equals(paramString)) {
return false;
}
return !"silver".equals(paramString);
}
setError("Unknown selector: " + this.edition);
return false;
}
public void setEdition(String paramString)
{
this.edition = paramString;
}
}
package com.jivesoftware.tools.selector;
public class IncludeSourceSelector
extends BaseSelector
{
protected String getTagName()
{
return "src.include";
}
protected boolean shouldCopyWithNoTag()
{
return true;
}
protected boolean shouldCopy(String paramString)
{
return !"false".equals(paramString);
}
}
package com.jivesoftware.tools.selector;
public class JavaDocSelector
extends BaseSelector
{
public static final String VERSION_API = "api";
public static final String VERSION_DEV = "dev";
public static final String VERSION_NONE = "none";
String version = "dev";
protected String getTagName()
{
return "javadoc";
}
protected boolean shouldCopyWithNoTag()
{
return "dev".equals(this.version);
}
protected boolean shouldCopy(String paramString)
{
if ("none".equals(paramString)) {
return false;
}
if ("dev".equals(this.version)) {
return true;
}
if ("api".equals(this.version)) {
return "api".equals(paramString);
}
setError("Unknown selector: " + this.version);
return false;
}
public void setVersion(String paramString)
{
this.version = paramString;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment