hebdobot/src/org/april/hebdobot/cli/HebdobotConfigFile.java

265 lines
5.4 KiB
Java
Raw Normal View History

/**
* Copyright (C) 2017 Christian Pierre MOMON <cmomon@april.org>
*
* This file is part of (April) Hebdobot.
*
* Hebdobot 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.
*
* Hebdobot 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 Hebdobot. If not, see <http://www.gnu.org/licenses/>
*/
package org.april.hebdobot.cli;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;
import org.april.hebdobot.HebdobotException;
import org.april.hebdobot.util.HebdobotUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The Class Launcher.
*/
public class HebdobotConfigFile extends Properties
{
private static final long serialVersionUID = 5954809202666104536L;
private static final Logger logger = LoggerFactory.getLogger(HebdobotConfigFile.class);
/**
* Instantiates a new launcher.
*
* @param source
* the source
* @throws HebdobotException
* the hebdobot exception
*/
public HebdobotConfigFile(final File source) throws HebdobotException
{
super();
try
{
Properties config = HebdobotUtils.loadProperties(source);
for (String key : config.stringPropertyNames())
{
put(key, config.getProperty(key));
}
}
catch (FileNotFoundException exception)
{
throw new HebdobotException("File not found.", exception);
}
catch (IOException exception)
{
throw new HebdobotException("IO error.", exception);
}
}
/**
* Gets the identica api key.
*
* @return the identica api key
*/
public String getIdenticaApiKey()
{
String result;
result = getProperty("hebdobot.identica.apiKey");
//
return result;
}
/**
* Gets the identica api secret.
*
* @return the identica api secret
*/
public String getIdenticaApiSecret()
{
String result;
result = getProperty("hebdobot.identica.apiSecret");
//
return result;
}
/**
* Gets the irc channel.
*
* @return the irc channel
*/
public String getIrcChannel()
{
String result;
result = getProperty("hebdobot.irc.channel");
//
return result;
}
/**
* Gets the irc host.
*
* @return the irc host
*/
public String getIrcHost()
{
String result;
result = getProperty("hebdobot.irc.host");
//
return result;
}
/**
* Gets the name.
*
* @return the name
*/
public String getIrcName()
{
String result;
result = getProperty("hebdobot.irc.name");
//
return result;
}
/**
* Gets the irc port.
*
* @return the irc port
*/
public Integer getIrcPort()
{
Integer result;
result = HebdobotUtils.toInteger(getProperty("hebdobot.irc.port"));
//
return result;
}
/**
* Gets the pastebin api key.
*
* @return the pastebin api key
*/
public String getPastebinApiKey()
{
String result;
result = getProperty("hebdobot.pastebin.apiKey");
//
return result;
}
/**
* Gets the review file suffix.
*
* @return the review file suffix
*/
public String getReviewFileSuffix()
{
String result;
result = getProperty("hebdobot.review.file.suffix");
//
return result;
}
/**
* Gets the twitter access token.
*
* @return the twitter access token
*/
public String getTwitterAccessToken()
{
String result;
result = getProperty("hebdobot.twitter.accessToken");
//
return result;
}
/**
* Gets the twitter access token secret.
*
* @return the twitter access token secret
*/
public String getTwitterAccessTokenSecret()
{
String result;
result = getProperty("hebdobot.twitter.accessTokenSecret");
//
return result;
}
/**
* Gets the twitter consumer key.
*
* @return the twitter consumer key
*/
public String getTwitterConsumerKey()
{
String result;
result = getProperty("hebdobot.twitter.consumerKey");
//
return result;
}
/**
* Gets the twitter consumer secret.
*
* @return the twitter consumer secret
*/
public String getTwitterConsumerSecret()
{
String result;
result = getProperty("hebdobot.twitter.consumerSecret");
//
return result;
}
/**
* Checks if is valid.
*
* @return true, if is valid
*/
public boolean isValid()
{
boolean result;
result = true;
//
return result;
}
}