Skip to content

Commit

Permalink
Fixes Java/Groovy dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanue1 committed May 26, 2015
1 parent 7cca499 commit bf1bce9
Show file tree
Hide file tree
Showing 8 changed files with 216 additions and 180 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright (c) 2008-2015 Emmanuel Dupuy
* This program is made available under the terms of the GPLv3 License.
*/

package jd.gui.service.indexer;

import jd.gui.spi.Indexer;

import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;
import java.util.regex.Pattern;

public abstract class AbstractIndexerProvider implements Indexer {

protected List<String> externalSelectors;
protected Pattern externalPathPattern;

/**
* Initialize "selectors" and "pathPattern" with optional external properties file
*/
AbstractIndexerProvider() {
Properties properties = new Properties();
Class clazz = this.getClass();

try (InputStream is = clazz.getClassLoader().getResourceAsStream(clazz.getName().replace('.', '/') + ".properties")) {
if (is != null) {
properties.load(is);
}
} catch (IOException ignore) {
}

init(properties);
}

protected void init(Properties properties) {
String selectors = properties.getProperty("selectors");
externalSelectors = (selectors == null) ? null : Arrays.asList(selectors.split(","));

String pathRegExp = properties.getProperty("pathRegExp");
externalPathPattern = (pathRegExp == null) ? null : Pattern.compile(pathRegExp);
}

protected List<String> getExternalSelectors() { return externalSelectors; }
protected Pattern getExternalPathPattern() { return externalPathPattern; }

public String[] getSelectors() {
return (externalSelectors==null) ? null : externalSelectors.toArray(new String[externalSelectors.size()]);
}
public Pattern getPathPattern() { return externalPathPattern; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright (c) 2008-2015 Emmanuel Dupuy
* This program is made available under the terms of the GPLv3 License.
*/

package jd.gui.service.sourcesaver;

import jd.gui.spi.SourceSaver;

import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;
import java.util.regex.Pattern;

public abstract class AbstractSourceSaverProvider implements SourceSaver {

protected List<String> externalSelectors;
protected Pattern externalPathPattern;

/**
* Initialize "selectors" and "pathPattern" with optional external properties file
*/
AbstractSourceSaverProvider() {
Properties properties = new Properties();
Class clazz = this.getClass();

try (InputStream is = clazz.getClassLoader().getResourceAsStream(clazz.getName().replace('.', '/') + ".properties")) {
if (is != null) {
properties.load(is);
}
} catch (IOException ignore) {
}

init(properties);
}

protected void init(Properties properties) {
String selectors = properties.getProperty("selectors");
externalSelectors = (selectors == null) ? null : Arrays.asList(selectors.split(","));

String pathRegExp = properties.getProperty("pathRegExp");
externalPathPattern = (pathRegExp == null) ? null : Pattern.compile(pathRegExp);
}

protected List<String> getExternalSelectors() { return externalSelectors; }
protected Pattern getExternalPathPattern() { return externalPathPattern; }

public String[] getSelectors() {
return (externalSelectors==null) ? null : externalSelectors.toArray(new String[externalSelectors.size()]);
}
public Pattern getPathPattern() { return externalPathPattern; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright (c) 2008-2015 Emmanuel Dupuy
* This program is made available under the terms of the GPLv3 License.
*/

package jd.gui.service.treenode;

import jd.gui.spi.TreeNodeFactory;

import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;
import java.util.regex.Pattern;

public abstract class AbstractTreeNodeFactoryProvider implements TreeNodeFactory {

protected List<String> externalSelectors;
protected Pattern externalPathPattern;

/**
* Initialize "selectors" and "pathPattern" with optional external properties file
*/
AbstractTreeNodeFactoryProvider() {
Properties properties = new Properties();
Class clazz = this.getClass();

try (InputStream is = clazz.getClassLoader().getResourceAsStream(clazz.getName().replace('.', '/') + ".properties")) {
if (is != null) {
properties.load(is);
}
} catch (IOException ignore) {
}

init(properties);
}

protected void init(Properties properties) {
String selectors = properties.getProperty("selectors");
externalSelectors = (selectors == null) ? null : Arrays.asList(selectors.split(","));

String pathRegExp = properties.getProperty("pathRegExp");
externalPathPattern = (pathRegExp == null) ? null : Pattern.compile(pathRegExp);
}

protected List<String> getExternalSelectors() { return externalSelectors; }
protected Pattern getExternalPathPattern() { return externalPathPattern; }

public String[] getSelectors() {
return (externalSelectors==null) ? null : externalSelectors.toArray(new String[externalSelectors.size()]);
}
public Pattern getPathPattern() { return externalPathPattern; }
}
Loading

0 comments on commit bf1bce9

Please sign in to comment.