id stringlengths 36 36 | text stringlengths 1 1.25M |
|---|---|
e9b1be05-8c22-4a2f-b365-24e7db727b7e | public Metrics(final Plugin plugin) throws IOException {
if (plugin == null) {
throw new IllegalArgumentException("Plugin cannot be null");
}
this.plugin = plugin;
// load the config
configurationFile = getConfigFile();
configuration = YamlConfiguration.load... |
aa45e1c3-a378-407f-a9e4-84c2fa6754e7 | public Graph createGraph(final String name) {
if (name == null) {
throw new IllegalArgumentException("Graph name cannot be null");
}
// Construct the graph object
final Graph graph = new Graph(name);
// Now we can add our graph
graphs.add(graph);
//... |
cd7864f8-4730-4611-8f45-1d73a1aec8ca | public void addGraph(final Graph graph) {
if (graph == null) {
throw new IllegalArgumentException("Graph cannot be null");
}
graphs.add(graph);
} |
224816b6-3a87-45ff-9d02-7b81763dd25e | public boolean start() {
synchronized (optOutLock) {
// Did we opt out?
if (isOptOut()) {
return false;
}
// Is metrics already running?
if (task != null) {
return true;
}
// Begin hitting the s... |
56d845ff-558f-49e5-a21f-45fd60ed216f | public void run() {
try {
// This has to be synchronized or it can collide with the disable method.
synchronized (optOutLock) {
// Disable Task, if it is running and the server owner decided to opt-out
... |
20784703-3a1c-4711-8e7a-7c539b76cbab | public boolean isOptOut() {
synchronized (optOutLock) {
try {
// Reload the metrics file
configuration.load(getConfigFile());
} catch (IOException ex) {
if (debug) {
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.g... |
38130bf7-a4e4-43d2-9815-dbcf823782a8 | public void enable() throws IOException {
// This has to be synchronized or it can collide with the check in the task.
synchronized (optOutLock) {
// Check if the server owner has already set opt-out, if not, set it.
if (isOptOut()) {
configuration.set("opt-out", ... |
e52ac769-f117-442c-b846-f8b4bc6e1d7f | public void disable() throws IOException {
// This has to be synchronized or it can collide with the check in the task.
synchronized (optOutLock) {
// Check if the server owner has already set opt-out, if not, set it.
if (!isOptOut()) {
configuration.set("opt-out"... |
ddf62d23-7090-46bb-95aa-5a4e7f2a9868 | public File getConfigFile() {
// I believe the easiest way to get the base folder (e.g craftbukkit set via -P) for plugins to use
// is to abuse the plugin object we already have
// plugin.getDataFolder() => base/plugins/PluginA/
// pluginsFolder => base/plugins/
// The base is n... |
ccec443b-796f-4586-aadb-4e58b4039d1c | private void postPlugin(final boolean isPing) throws IOException {
// Server software specific section
PluginDescriptionFile description = plugin.getDescription();
String pluginName = description.getName();
boolean onlineMode = Bukkit.getServer().getOnlineMode(); // TRUE if online mode i... |
2611a598-cb48-4428-8bbb-5b9da6ca4a85 | public static byte[] gzip(String input) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
GZIPOutputStream gzos = null;
try {
gzos = new GZIPOutputStream(baos);
gzos.write(input.getBytes("UTF-8"));
} catch (IOException e) {
e.printStackTrace... |
7141ea81-b6cf-4942-84d5-26b6fc1f3254 | private boolean isMineshafterPresent() {
try {
Class.forName("mineshafter.MineServer");
return true;
} catch (Exception e) {
return false;
}
} |
ad0f0c5c-d8ef-4bf9-94a2-c10504d4ad4d | private static void appendJSONPair(StringBuilder json, String key, String value) throws UnsupportedEncodingException {
boolean isValueNumeric = false;
try {
if (value.equals("0") || !value.endsWith("0")) {
Double.parseDouble(value);
isValueNumeric = true;
... |
c7093e73-0889-427d-80a9-3a9c70104b3a | private static String escapeJSON(String text) {
StringBuilder builder = new StringBuilder();
builder.append('"');
for (int index = 0; index < text.length(); index++) {
char chr = text.charAt(index);
switch (chr) {
case '"':
case '\\':
... |
9d9214c3-d5a4-4824-be4f-7b41b171a1e9 | private static String urlEncode(final String text) throws UnsupportedEncodingException {
return URLEncoder.encode(text, "UTF-8");
} |
5f37ed68-f6d6-4e3d-90e8-a15cacedb7d5 | private Graph(final String name) {
this.name = name;
} |
3ecbb797-c6f2-4c4b-92a5-7ce3f09e98f9 | public String getName() {
return name;
} |
a488d710-4f9a-455b-9853-cf3c41e3279b | public void addPlotter(final Plotter plotter) {
plotters.add(plotter);
} |
9d756d6a-6d9d-4a25-b9af-69c4587ca070 | public void removePlotter(final Plotter plotter) {
plotters.remove(plotter);
} |
597a992c-a534-4417-aa4d-655d0a404e27 | public Set<Plotter> getPlotters() {
return Collections.unmodifiableSet(plotters);
} |
f6ff9fbe-8d1b-4b6d-8898-105532917258 | @Override
public int hashCode() {
return name.hashCode();
} |
f5347f26-3790-4fa9-b1a0-545312f5ab4c | @Override
public boolean equals(final Object object) {
if (!(object instanceof Graph)) {
return false;
}
final Graph graph = (Graph) object;
return graph.name.equals(name);
} |
f8671c9e-07f6-4997-8b0b-f68dde95e07d | protected void onOptOut() {
} |
ab03338f-4ac2-4559-aba9-0534894490e8 | public Plotter() {
this("Default");
} |
75bb036d-ae35-45a6-98c9-26c8e3060026 | public Plotter(final String name) {
this.name = name;
} |
a806bfc1-98fb-4b2d-a1c3-57cdfb2d46a2 | public abstract int getValue(); |
c9fccc22-d290-4c9c-b176-08caa4658b70 | public String getColumnName() {
return name;
} |
10066a3e-9d00-4d60-a362-1af2f590368b | public void reset() {
} |
ede48afa-da7f-49fa-b8e5-05327e6e4c3e | @Override
public int hashCode() {
return getColumnName().hashCode();
} |
7a99b7bc-a572-49cb-ac51-d4f421240854 | @Override
public boolean equals(final Object object) {
if (!(object instanceof Plotter)) {
return false;
}
final Plotter plotter = (Plotter) object;
return plotter.name.equals(name) && plotter.getValue() == getValue();
} |
1e056834-7911-426a-ac4e-ee66ef3d43f7 | public Configuration(ButtonWarpRandom plugin){
Configuration.plugin = plugin;
plugin.getConfig().options().copyDefaults(true);
plugin.getLogger().info("Configuration loaded!");
List<?> biomesInc = plugin.getConfig().getList("included-biomes");
for (Object b : biomesInc){
String biome = ((... |
83f5acda-e17b-4fcf-8fe7-9f9e733b8b14 | public static void reloadConfig(){
BiomesExcluded = new ArrayList<Biome>(); // Reset
BiomesIncluded = new ArrayList<Biome>(); // Reset
plugin.reloadConfig();
List<?> biomesInc = plugin.getConfig().getList("included-biomes");
for (Object b : biomesInc){
String biome = ((String)b).toUpperCase(); ... |
6f24fa49-151e-41e9-884a-9e3dbf468afe | public Converter(){
Collection<Warp> warps = ButtonWarp.getWarps();
for (Warp warp : warps){
// Check if warp contains bwr
if (warp.commands.size() != 0){
String cmd = warp.commands.getFirst();
if (cmd.startsWith("bwr") && !cmd.contains("-")){
String args[] = cmd.split("\\s+");
// Try to par... |
05ce576c-8e1e-4471-80b0-5213eb7bda89 | public Updater(Plugin plugin, int id, File file, UpdateType type, boolean announce) {
this.plugin = plugin;
this.type = type;
this.announce = announce;
this.file = file;
this.id = id;
this.updateFolder = plugin.getServer().getUpdateFolder();
final File pluginFile... |
814933b1-51eb-443a-a4c5-9a16d81972b4 | public Updater.UpdateResult getResult() {
this.waitForThread();
return this.result;
} |
14af42d6-56dc-4f5b-b503-4ab26b637214 | public String getLatestType() {
this.waitForThread();
return this.versionType;
} |
43404b2a-1e8c-4c6e-b359-e46ed84ac3f7 | public String getLatestGameVersion() {
this.waitForThread();
return this.versionGameVersion;
} |
4ab57723-46a7-4ebd-ac09-815a2d486122 | public String getLatestName() {
this.waitForThread();
return this.versionName;
} |
74081386-58c0-44d8-8d55-ab2c8490d7ed | public String getLatestFileLink() {
this.waitForThread();
return this.versionLink;
} |
bf80b321-9a7c-4ad6-91be-81beed0c415c | private void waitForThread() {
if ((this.thread != null) && this.thread.isAlive()) {
try {
this.thread.join();
} catch (final InterruptedException e) {
e.printStackTrace();
}
}
} |
4a73ae1b-02a7-449b-92fb-4a3aaca55698 | private void saveFile(File folder, String file, String u) {
if (!folder.exists()) {
folder.mkdir();
}
BufferedInputStream in = null;
FileOutputStream fout = null;
try {
// Download the file
final URL url = new URL(u);
final int file... |
492ffade-b93a-4a27-9579-18b8bebcc99b | private void unzip(String file) {
try {
final File fSourceZip = new File(file);
final String zipPath = file.substring(0, file.length() - 4);
ZipFile zipFile = new ZipFile(fSourceZip);
Enumeration<? extends ZipEntry> e = zipFile.entries();
while (e.hasM... |
6233f11d-3953-4077-b0aa-4a8274e92110 | private boolean pluginFile(String name) {
for (final File file : new File("plugins").listFiles()) {
if (file.getName().equals(name)) {
return true;
}
}
return false;
} |
13577885-9682-4084-b952-5d8e2da94efe | private boolean versionCheck(String title) {
if (this.type != UpdateType.NO_VERSION_CHECK) {
final String version = this.plugin.getDescription().getVersion();
if (title.split(" v").length == 2) {
final String remoteVersion = title.split(" v")[1].split(" ")[0]; // Get the ... |
f533d3b0-cb05-4e34-aaed-00bd62c7aa0f | private boolean hasTag(String version) {
for (final String string : Updater.NO_UPDATE_TAG) {
if (version.contains(string)) {
return true;
}
}
return false;
} |
7379f53b-3668-4b6d-a7e9-669405ceccaf | private boolean read() {
try {
final URLConnection conn = this.url.openConnection();
conn.setConnectTimeout(5000);
if (this.apiKey != null) {
conn.addRequestProperty("X-API-Key", this.apiKey);
}
conn.addRequestProperty("User-Agent", "U... |
15e6772b-0d90-4d98-91d3-d9ab4f5c02fb | @Override
public void run() {
if (Updater.this.url != null) {
// Obtain the results of the project's file feed
if (Updater.this.read()) {
if (Updater.this.versionCheck(Updater.this.versionName)) {
if ((Updater.this.versionLi... |
751d0f0e-5f8e-4fdc-902b-1fc156b0a33a | Board(int boardSize, int boxHight, int boxLength, int[] boardLine, SudokuBuffer buffer) {
board = new Square[boardSize][boardSize];
Column[] column = new Column[boardSize];
Row[] row = new Row[boardSize];
Box[][] box = new Box[boxLength][boxHight];
this.boardSize = boardSize;
this.boardLine = boardLine;
... |
71b66aff-ce13-4222-9974-cf8034c7400d | public void saveSolution() {
solCount++;
if (solCount > 1) {
return;
}
solution = new int[81];
int counter = 0;
for(int i = 0; i < board.length; i++) {
for (int j = 0; j < board.length; j++) {
solution[counter++] = board[i][j].value;
//System.out.print(b... |
ccff3d7c-0966-403a-9dcf-1ca3e2132775 | Column(int size) {
super(size);
} |
46640142-823d-49ed-a618-f0bc6ab3af97 | Box(int size) {
super(size);
} |
3a7b2d44-4bdd-4786-840e-cae380e82a5f | Row(int size) {
super(size);
} |
670771b4-e983-45b1-bd13-68f1cb0ca92e | Container(int size) {
number = new boolean[size];
} |
1dedf0c5-4bd6-46c5-956c-5f61a59d02e1 | public boolean checkNumber(int i) {
return !number[i-1];
} |
f143effd-1c0e-4eac-a47d-9689b311185e | public void setValue(int i, boolean take) {
if (i != 0 && i != -1) {
number[i-1] = take;
}
} |
23755a89-064f-4413-a747-e1732797770d | SudokuBuffer() {
solutionBuffer = new ArrayList<int[]>();
} |
00596791-a4ab-4dd1-bd67-0c6498f08079 | public void add(int[] solution) {
solutionBuffer.add(solution);
} |
3719622f-4485-49cd-b445-f8b0bc87950b | public int[] get(int index) {
return solutionBuffer.get(index);
} |
7f8137de-cff9-4583-a4ab-69135562fdbe | public static void main(String[] args) {
String infile = args[0];
String outfile = args[1];
ScannerReadFile read = new ScannerReadFile();
read.readFile(infile, outfile);
} |
25a1de57-7b1d-4799-a2de-11c3055d45fe | public void readFile(String infile, String outfile) {
filename = infile;
outfilename = outfile;
// Location of file to read and write
File file = new File(filename);
File out = new File(outfilename);
SudokuBuffer buffer = new SudokuBuffer();
try {
System.out.println("---CSP Solver---");
... |
19993c7d-f74f-48ce-9379-643b7b8f7f64 | public int[] splitLine(String line) {
int[] board = new int[line.length()];
char[] temp = new char[line.length()];
temp = line.toCharArray();
for (int i = 0; i < temp.length; i++) {
if (temp[i] == '.') {
board[i] = 0;
} else {
board[i] = Character.getNumericValue(temp[i]);
}
//System.... |
c19e705a-eafd-4923-8e81-f854f55003b0 | public void writeFile(SudokuBuffer buffer, File out) {
String print;
try {
Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(out), "utf-8"));
//DataOutputStream writer = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(out)));
//System.out.println("in writ... |
21e7f619-4b6f-445d-a150-54c73f68683a | Square(int value, Row r, Column c, Box b, Board board) {
this.value = value;
this.r = r;
this.c = c;
this.b = b;
this.board = board;
this.setValue(value);
} |
0b01210c-ea91-4c1b-b90d-64c10fc55b43 | Square(Row r, Column c, Box b, Board board) {
this.r = r;
this.c = c;
this.b = b;
this.board = board;
} |
bc4e81bc-03bf-4c90-809a-ad5976eb555d | public void setNumber() {
/*if (solutionCounter > 1) {
if (solutionFound == true) {
System.out.println("sol found square");
return;
}
}*/
if (value > 0) {
if (next == null) {
foundSolution();
} else {
next.setNumber();
}
} else {
... |
6800bc1e-2ad1-44f1-989e-2345890eb5be | public boolean legal(int number) {
if (r.checkNumber(number) && b.checkNumber(number)
&& c.checkNumber(number)) {
return true;
}
return false;
} |
02a5c1f8-33be-4ae5-94ab-f9b5b514fe7c | public void foundSolution() {
//System.out.println("solfound square");
solutionCounter++;
solutionFound = true;
if (solutionCounter > 1) {
return;
}
board.saveSolution();
//return;
} |
fc24da6d-98cb-432a-bb6c-3475e4026191 | public void setValue(int i) {
r.setValue(i, true);
c.setValue(i, true);
b.setValue(i, true);
value = i;
} |
4bf9a5a8-3f82-47ef-9fdb-e7d04994c2bf | public void releaseValue() {
r.setValue(value, false);
c.setValue(value, false);
b.setValue(value, false);
value = 0;
} |
e0fb8e20-38bf-4c91-8791-b4f51196a30d | @RequestMapping(value = {"/", "/welcome**"},method = RequestMethod.GET)
public ModelAndView defaultPage(){
ModelAndView model = new ModelAndView();
model.addObject("title","My Call Sheet Login");
model.addObject("message"," This is default page");
model.setViewName("hello");
return model;
} |
f00805c2-12a5-4fae-a510-e097940f68ee | @RequestMapping(value="/admin**", method=RequestMethod.GET)
public ModelAndView adminPage(){
ModelAndView model = new ModelAndView();
model.addObject("title","My Call Sheet Login");
model.addObject("message","This is for ROLE_ADMIN only");
return model;
} |
c0bdab31-aae6-48fc-9506-b14e26f74c71 | @RequestMapping(value="/login", method=RequestMethod.GET)
public ModelAndView login(@RequestParam(value="error",required=false) String error,
@RequestParam(value="logout",required=false) String logout,
HttpServletRequest request){
ModelAndView model = new ModelAndView();
if(error != null){
model.add... |
1bfe7c4a-698c-4e4b-95e3-0005ddd29570 | private String getErrorMessage(HttpServletRequest request,String key){
Exception exception = (Exception) request.getSession().getAttribute(key);
String error=null;
if(exception instanceof BadCredentialsException){
error = "Invalid Username or Password !";
}else if(exception instanceof LockedException){
er... |
e728f3b8-66ff-49eb-aa51-0108000e819f | @RequestMapping(value="/403")
public ModelAndView accessDenied(){
ModelAndView model = new ModelAndView();
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
if(!(auth instanceof AnonymousAuthenticationToken)){
UserDetails userDetail = (UserDetails) auth.getPrincipal();
System... |
42e2da33-eb21-41b0-b104-93fa5f10796a | @Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException{
try{
Authentication auth = super.authenticate(authentication);
userDetailsDao.resetFailAttempts(authentication.getName());
return auth;
}catch(BadCredentialsException e){
userDetailsDao.updateFai... |
a6f92b85-e3e8-4968-825c-0db14933ce76 | public UserDetailsDao getUserDetailsDao() {
return userDetailsDao;
} |
eb528981-9f2d-4cde-a4c8-5b23a81dc831 | public void setUserDetailsDao(UserDetailsDao userDetailsDao) {
this.userDetailsDao = userDetailsDao;
} |
e8409e8f-0f26-4323-a2e8-5e5ed22a9bf5 | public int getId() {
return id;
} |
5603071e-a196-43bc-87e5-fe1965043e52 | public void setId(int id) {
this.id = id;
} |
eb778b5d-6011-4360-b405-d3f7f621c703 | public String getUserName() {
return userName;
} |
973a5669-0d63-40ed-9efa-dbbbf71b5ddd | public void setUserName(String userName) {
this.userName = userName;
} |
fb3abc74-3bf0-40f9-b9b3-f9409dbb7dc9 | public int getAttempts() {
return attempts;
} |
f532793b-cb0e-4c77-94d0-bb4922f22b0d | public void setAttempts(int attempts) {
this.attempts = attempts;
} |
eee0672b-eea8-4a50-9975-1987f78b5ce7 | public Date getLastModified() {
return lastModified;
} |
413394b9-5f11-44bb-a0db-c5171c169032 | public void setLastModified(Date lastModified) {
this.lastModified = lastModified;
} |
190518ff-a829-44b6-9a68-5f85c8d73ace | void updateFailAttempts(String userName); |
44aa12f5-78d0-4e5f-8341-ac8549475d89 | void resetFailAttempts(String userName); |
6cffa87d-e565-45d1-b276-4321a0953d67 | UserAttempts getUserAttempts(String userName); |
1ae2e1fc-3da0-4084-a6d7-3750c2a65e3d | @PostConstruct
private void initialize(){
setDataSource(dataSource);
} |
c9bea7ee-b5aa-4ea8-abf1-ce874a9f9c99 | @Override
public void updateFailAttempts(String userName) {
UserAttempts user = getUserAttempts(userName);
if(user == null){
if(isUserExists(userName)){
//If no record insert a new record
getJdbcTemplate().update(SQL_USER_ATTEMPTS_INSERT,new Object[] {userName,1,new Date()});
}
} else {
if(isUse... |
5d5560fd-ab02-4db4-b734-198d600308e2 | @Override
public void resetFailAttempts(String userName) {
getJdbcTemplate().update(SQL_USER_ATTEMPTS_RESET_ATTEMPTS,new Object[]{userName});
} |
c2ac99ee-801f-491c-af10-01a13c9e4db4 | @Override
public UserAttempts getUserAttempts(String userName) {
try{
UserAttempts userAttempts = getJdbcTemplate().queryForObject(
SQL_USER_ATTEMPTS_GET,
new Object[]{userName},
new RowMapper<UserAttempts> (){
@Override
public UserAttempts mapRow(ResultSet rs, int rowNum)
thr... |
99ebf755-5d14-4239-b3e2-9a2ad51179ab | @Override
public UserAttempts mapRow(ResultSet rs, int rowNum)
throws SQLException {
UserAttempts user = new UserAttempts();
user.setId(rs.getInt("id"));
user.setUserName(rs.getString("username"));
user.setAttempts(rs.getInt("attempts"));
user.setLastModified(rs.getDate(... |
424cd05c-696c-4619-a7d8-2f93330fef9f | public boolean isUserExists(String userName){
boolean result = false;
int count = getJdbcTemplate().queryForObject(SQL_USERS_COUNT,
new Object[] {userName}, Integer.class );
if(count > 0 ){
result = true;
}
return result;
} |
074d6be1-2656-4794-b332-13a0defa8096 | @Override
public void setUsersByUsernameQuery(String usersByUsernameQueryString){
super.setUsersByUsernameQuery(usersByUsernameQueryString);
} |
eb6be77e-4662-4946-8a6c-c6619067b7b8 | @Override
public void setAuthoritiesByUsernameQuery(String queryString){
super.setAuthoritiesByUsernameQuery(queryString);
} |
e0489d90-08dc-4b0a-8d5f-50fd1facddda | @Override
public List<UserDetails> loadUsersByUsername(String userName){
return getJdbcTemplate().query(super.getUsersByUsernameQuery(),
new String[]{userName},
new RowMapper<UserDetails>(){
@Override
public UserDetails mapRow(ResultSet rs, int rowNum)
throws SQLException {
String userName =... |
25b25f7d-39b2-4f12-816f-b6467da2428b | @Override
public UserDetails mapRow(ResultSet rs, int rowNum)
throws SQLException {
String userName = rs.getString("username");
String password = rs.getString("password");
boolean enabled = rs.getBoolean("enabled");
boolean accountNonExpired = rs.getBoolean("accountNonExpired");
boole... |
d88bdd91-a141-42d5-98f6-955a576068a0 | @Override
public UserDetails createUserDetails(String userName,UserDetails userFromUserQuery,
List<GrantedAuthority> combinedAuthorities){
String returnUserName = userFromUserQuery.getUsername();
if(super.isUsernameBasedPrimaryKey()){
returnUserName = userName;
}
return new User(returnUserName, userFr... |
9c06e3f0-049a-41a0-9cc2-d2e52f8e004c | public static void first() {
int[] array = new int[SIZE];
for (int i = 0; i < SIZE; i++) {
array[i] = i;
}
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.