repo_name stringlengths 7 104 | file_path stringlengths 13 198 | context stringlengths 67 7.15k | import_statement stringlengths 16 4.43k | code stringlengths 40 6.98k | prompt stringlengths 227 8.27k | next_line stringlengths 8 795 |
|---|---|---|---|---|---|---|
WonderBeat/vasilich | alice-src/bitoflife/chatterbean/util/SequenceMother.java | // Path: alice-src/bitoflife/chatterbean/util/Sequence.java
// public class Sequence
// {
// /*
// Attributes
// */
//
// private File backup, file;
//
// /*
// Constructor
// */
//
// public Sequence(File file)
// {
// this.file = file;
// backup = new File(file.getAbsolutePath() + ".backup");
// }
//
// public Sequence(String path)
// {
// file = new File(path);
// backup = new File(path + ".backup");
// }
//
// /*
// Methods
// */
//
// private long loadNext(File file) throws IOException
// {
// String line = "";
//
// try
// {
// BufferedReader reader = new BufferedReader(new FileReader(file));
//
// line = reader.readLine();
//
// long next = Long.parseLong(line);
//
// reader.close();
//
// return next;
// }
// catch (NumberFormatException e)
// {
// throw new IOException("Illegal value on persistence file: " + line);
// }
// catch (FileNotFoundException e)
// {
// return 0;
// }
// }
//
// private void saveNext(File file, long next) throws IOException
// {
// PrintWriter writer = new PrintWriter(new FileWriter(file, false), true);
//
// writer.println(Long.toString(next + 1));
//
// writer.close();
// }
//
// /**
// Return the next number in the sequence.
// */
// public synchronized long getNext() throws IOException
// {
// long next = 0;
//
// try
// {
// next = loadNext(file.exists() ? file : backup);
// }
// catch (IOException e)
// {
// next = loadNext(backup);
// }
//
// saveNext(backup, next);
// saveNext(file, next);
//
// return next;
// }
// }
| import java.io.File;
import bitoflife.chatterbean.util.Sequence; | /*
Copyleft (C) 2005 Hio Perroni Filho
xperroni@yahoo.com
ICQ: 2490863
This file is part of ChatterBean.
ChatterBean is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
ChatterBean 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with ChatterBean (look at the Documents/ directory); if not, either write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA, or visit (http://www.gnu.org/licenses/gpl.txt).
*/
package bitoflife.chatterbean.util;
public class SequenceMother
{
/*
Attributes
*/
public static final File file = new File("Logs/sequence.txt");
/*
Methods
*/
| // Path: alice-src/bitoflife/chatterbean/util/Sequence.java
// public class Sequence
// {
// /*
// Attributes
// */
//
// private File backup, file;
//
// /*
// Constructor
// */
//
// public Sequence(File file)
// {
// this.file = file;
// backup = new File(file.getAbsolutePath() + ".backup");
// }
//
// public Sequence(String path)
// {
// file = new File(path);
// backup = new File(path + ".backup");
// }
//
// /*
// Methods
// */
//
// private long loadNext(File file) throws IOException
// {
// String line = "";
//
// try
// {
// BufferedReader reader = new BufferedReader(new FileReader(file));
//
// line = reader.readLine();
//
// long next = Long.parseLong(line);
//
// reader.close();
//
// return next;
// }
// catch (NumberFormatException e)
// {
// throw new IOException("Illegal value on persistence file: " + line);
// }
// catch (FileNotFoundException e)
// {
// return 0;
// }
// }
//
// private void saveNext(File file, long next) throws IOException
// {
// PrintWriter writer = new PrintWriter(new FileWriter(file, false), true);
//
// writer.println(Long.toString(next + 1));
//
// writer.close();
// }
//
// /**
// Return the next number in the sequence.
// */
// public synchronized long getNext() throws IOException
// {
// long next = 0;
//
// try
// {
// next = loadNext(file.exists() ? file : backup);
// }
// catch (IOException e)
// {
// next = loadNext(backup);
// }
//
// saveNext(backup, next);
// saveNext(file, next);
//
// return next;
// }
// }
// Path: alice-src/bitoflife/chatterbean/util/SequenceMother.java
import java.io.File;
import bitoflife.chatterbean.util.Sequence;
/*
Copyleft (C) 2005 Hio Perroni Filho
xperroni@yahoo.com
ICQ: 2490863
This file is part of ChatterBean.
ChatterBean is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
ChatterBean 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with ChatterBean (look at the Documents/ directory); if not, either write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA, or visit (http://www.gnu.org/licenses/gpl.txt).
*/
package bitoflife.chatterbean.util;
public class SequenceMother
{
/*
Attributes
*/
public static final File file = new File("Logs/sequence.txt");
/*
Methods
*/
| public Sequence newInstance() |
WonderBeat/vasilich | alice-src/bitoflife/chatterbean/aiml/Lowercase.java | // Path: alice-src/bitoflife/chatterbean/Match.java
// public class Match implements Serializable
// {
// /*
// Inner Classes
// */
//
// public enum Section {PATTERN, THAT, TOPIC;}
//
// /*
// Attributes
// */
//
// /** Version class identifier for the serialization engine. Matches the number of the last revision where the class was created / modified. */
// private static final long serialVersionUID = 8L;
//
// private final Map<Section, List<String>> sections = new HashMap<Section, List<String>>();
//
// private AliceBot callback;
//
// private Sentence input;
//
// private Sentence that;
//
// private Sentence topic;
//
// private String[] matchPath;
//
// {
// sections.put(Section.PATTERN, new ArrayList<String>(2)); // Pattern wildcards
// sections.put(Section.THAT, new ArrayList<String>(2)); // That wildcards
// sections.put(Section.TOPIC, new ArrayList<String>(2)); // Topic wildcards
// }
//
// /*
// Constructor
// */
//
// public Match()
// {
// }
//
// public Match(AliceBot callback, Sentence input, Sentence that, Sentence topic)
// {
// this.callback = callback;
// this.input = input;
// this.that = that;
// this.topic = topic;
// setUpMatchPath(input.normalized(), that.normalized(), topic.normalized());
// }
//
// public Match(Sentence input)
// {
// this(null, input, ASTERISK, ASTERISK);
// }
//
// /*
// Methods
// */
//
// private void appendWildcard(List<String> section, Sentence source, int beginIndex, int endIndex)
// {
// if (beginIndex == endIndex)
// section.add(0, "");
// else try
// {
// section.add(0, source.original(beginIndex, endIndex));
// }
// catch (Exception e)
// {
// // throw new RuntimeException("Source: {\"" + source.getOriginal() + "\", \"" + source.getNormalized() + "\"}\n" +
// // "Begin Index: " + beginIndex + "\n" +
// // "End Index: " + endIndex, e);
// }
// }
//
// private void setUpMatchPath(String[] pattern, String[] that, String[] topic)
// {
// int m = pattern.length, n = that.length, o = topic.length;
// matchPath = new String[m + 1 + n + 1 + o];
// matchPath[m] = "<THAT>";
// matchPath[m + 1 + n] = "<TOPIC>";
//
// System.arraycopy(pattern, 0, matchPath, 0, m);
// System.arraycopy(that, 0, matchPath, m + 1, n);
// System.arraycopy(topic, 0, matchPath, m + 1 + n + 1, o);
// }
//
// public void appendWildcard(int beginIndex, int endIndex)
// {
// int inputLength = input.length();
// if (beginIndex <= inputLength)
// {
// appendWildcard(sections.get(Section.PATTERN), input, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (inputLength + 1);
// endIndex = endIndex - (inputLength + 1);
//
// int thatLength = that.length();
// if (beginIndex <= thatLength)
// {
// appendWildcard(sections.get(Section.THAT), that, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (thatLength + 1);
// endIndex = endIndex - (thatLength + 1);
//
// int topicLength = topic.length();
// if (beginIndex < topicLength)
// appendWildcard(sections.get(Section.TOPIC), topic, beginIndex, endIndex);
// }
//
// /**
// Gets the contents for the (index)th wildcard in the matched section.
// */
// public String wildcard(Section section, int index)
// {
// List<String> wildcards = sections.get(section);
// //fixed by lcl
// if(wildcards.size() == 0)
// return "";
// int i = index - 1;
// if(i < wildcards.size() && i > -1)
// return wildcards.get(i);
// else
// return "";
// }
//
// /*
// Properties
// */
//
// public AliceBot getCallback()
// {
// return callback;
// }
//
// public void setCallback(AliceBot callback)
// {
// this.callback = callback;
// }
//
// public String[] getMatchPath()
// {
// return matchPath;
// }
//
// public String getMatchPath(int index)
// {
// return matchPath[index];
// }
//
// public int getMatchPathLength()
// {
// return matchPath.length;
// }
// }
| import org.xml.sax.Attributes;
import bitoflife.chatterbean.Match; | /*
Copyleft (C) 2005 Hio Perroni Filho
xperroni@yahoo.com
ICQ: 2490863
This file is part of ChatterBean.
ChatterBean is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
ChatterBean 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with ChatterBean (look at the Documents/ directory); if not, either write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA, or visit (http://www.gnu.org/licenses/gpl.txt).
*/
package bitoflife.chatterbean.aiml;
public class Lowercase extends TemplateElement
{
/*
Constructors
*/
public Lowercase(Attributes attributes)
{
}
public Lowercase(Object... children)
{
super(children);
}
/*
Methods
*/
| // Path: alice-src/bitoflife/chatterbean/Match.java
// public class Match implements Serializable
// {
// /*
// Inner Classes
// */
//
// public enum Section {PATTERN, THAT, TOPIC;}
//
// /*
// Attributes
// */
//
// /** Version class identifier for the serialization engine. Matches the number of the last revision where the class was created / modified. */
// private static final long serialVersionUID = 8L;
//
// private final Map<Section, List<String>> sections = new HashMap<Section, List<String>>();
//
// private AliceBot callback;
//
// private Sentence input;
//
// private Sentence that;
//
// private Sentence topic;
//
// private String[] matchPath;
//
// {
// sections.put(Section.PATTERN, new ArrayList<String>(2)); // Pattern wildcards
// sections.put(Section.THAT, new ArrayList<String>(2)); // That wildcards
// sections.put(Section.TOPIC, new ArrayList<String>(2)); // Topic wildcards
// }
//
// /*
// Constructor
// */
//
// public Match()
// {
// }
//
// public Match(AliceBot callback, Sentence input, Sentence that, Sentence topic)
// {
// this.callback = callback;
// this.input = input;
// this.that = that;
// this.topic = topic;
// setUpMatchPath(input.normalized(), that.normalized(), topic.normalized());
// }
//
// public Match(Sentence input)
// {
// this(null, input, ASTERISK, ASTERISK);
// }
//
// /*
// Methods
// */
//
// private void appendWildcard(List<String> section, Sentence source, int beginIndex, int endIndex)
// {
// if (beginIndex == endIndex)
// section.add(0, "");
// else try
// {
// section.add(0, source.original(beginIndex, endIndex));
// }
// catch (Exception e)
// {
// // throw new RuntimeException("Source: {\"" + source.getOriginal() + "\", \"" + source.getNormalized() + "\"}\n" +
// // "Begin Index: " + beginIndex + "\n" +
// // "End Index: " + endIndex, e);
// }
// }
//
// private void setUpMatchPath(String[] pattern, String[] that, String[] topic)
// {
// int m = pattern.length, n = that.length, o = topic.length;
// matchPath = new String[m + 1 + n + 1 + o];
// matchPath[m] = "<THAT>";
// matchPath[m + 1 + n] = "<TOPIC>";
//
// System.arraycopy(pattern, 0, matchPath, 0, m);
// System.arraycopy(that, 0, matchPath, m + 1, n);
// System.arraycopy(topic, 0, matchPath, m + 1 + n + 1, o);
// }
//
// public void appendWildcard(int beginIndex, int endIndex)
// {
// int inputLength = input.length();
// if (beginIndex <= inputLength)
// {
// appendWildcard(sections.get(Section.PATTERN), input, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (inputLength + 1);
// endIndex = endIndex - (inputLength + 1);
//
// int thatLength = that.length();
// if (beginIndex <= thatLength)
// {
// appendWildcard(sections.get(Section.THAT), that, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (thatLength + 1);
// endIndex = endIndex - (thatLength + 1);
//
// int topicLength = topic.length();
// if (beginIndex < topicLength)
// appendWildcard(sections.get(Section.TOPIC), topic, beginIndex, endIndex);
// }
//
// /**
// Gets the contents for the (index)th wildcard in the matched section.
// */
// public String wildcard(Section section, int index)
// {
// List<String> wildcards = sections.get(section);
// //fixed by lcl
// if(wildcards.size() == 0)
// return "";
// int i = index - 1;
// if(i < wildcards.size() && i > -1)
// return wildcards.get(i);
// else
// return "";
// }
//
// /*
// Properties
// */
//
// public AliceBot getCallback()
// {
// return callback;
// }
//
// public void setCallback(AliceBot callback)
// {
// this.callback = callback;
// }
//
// public String[] getMatchPath()
// {
// return matchPath;
// }
//
// public String getMatchPath(int index)
// {
// return matchPath[index];
// }
//
// public int getMatchPathLength()
// {
// return matchPath.length;
// }
// }
// Path: alice-src/bitoflife/chatterbean/aiml/Lowercase.java
import org.xml.sax.Attributes;
import bitoflife.chatterbean.Match;
/*
Copyleft (C) 2005 Hio Perroni Filho
xperroni@yahoo.com
ICQ: 2490863
This file is part of ChatterBean.
ChatterBean is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
ChatterBean 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with ChatterBean (look at the Documents/ directory); if not, either write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA, or visit (http://www.gnu.org/licenses/gpl.txt).
*/
package bitoflife.chatterbean.aiml;
public class Lowercase extends TemplateElement
{
/*
Constructors
*/
public Lowercase(Attributes attributes)
{
}
public Lowercase(Object... children)
{
super(children);
}
/*
Methods
*/
| public String process(Match match) |
WonderBeat/vasilich | alice-src/bitoflife/chatterbean/aiml/Size.java | // Path: alice-src/bitoflife/chatterbean/Match.java
// public class Match implements Serializable
// {
// /*
// Inner Classes
// */
//
// public enum Section {PATTERN, THAT, TOPIC;}
//
// /*
// Attributes
// */
//
// /** Version class identifier for the serialization engine. Matches the number of the last revision where the class was created / modified. */
// private static final long serialVersionUID = 8L;
//
// private final Map<Section, List<String>> sections = new HashMap<Section, List<String>>();
//
// private AliceBot callback;
//
// private Sentence input;
//
// private Sentence that;
//
// private Sentence topic;
//
// private String[] matchPath;
//
// {
// sections.put(Section.PATTERN, new ArrayList<String>(2)); // Pattern wildcards
// sections.put(Section.THAT, new ArrayList<String>(2)); // That wildcards
// sections.put(Section.TOPIC, new ArrayList<String>(2)); // Topic wildcards
// }
//
// /*
// Constructor
// */
//
// public Match()
// {
// }
//
// public Match(AliceBot callback, Sentence input, Sentence that, Sentence topic)
// {
// this.callback = callback;
// this.input = input;
// this.that = that;
// this.topic = topic;
// setUpMatchPath(input.normalized(), that.normalized(), topic.normalized());
// }
//
// public Match(Sentence input)
// {
// this(null, input, ASTERISK, ASTERISK);
// }
//
// /*
// Methods
// */
//
// private void appendWildcard(List<String> section, Sentence source, int beginIndex, int endIndex)
// {
// if (beginIndex == endIndex)
// section.add(0, "");
// else try
// {
// section.add(0, source.original(beginIndex, endIndex));
// }
// catch (Exception e)
// {
// // throw new RuntimeException("Source: {\"" + source.getOriginal() + "\", \"" + source.getNormalized() + "\"}\n" +
// // "Begin Index: " + beginIndex + "\n" +
// // "End Index: " + endIndex, e);
// }
// }
//
// private void setUpMatchPath(String[] pattern, String[] that, String[] topic)
// {
// int m = pattern.length, n = that.length, o = topic.length;
// matchPath = new String[m + 1 + n + 1 + o];
// matchPath[m] = "<THAT>";
// matchPath[m + 1 + n] = "<TOPIC>";
//
// System.arraycopy(pattern, 0, matchPath, 0, m);
// System.arraycopy(that, 0, matchPath, m + 1, n);
// System.arraycopy(topic, 0, matchPath, m + 1 + n + 1, o);
// }
//
// public void appendWildcard(int beginIndex, int endIndex)
// {
// int inputLength = input.length();
// if (beginIndex <= inputLength)
// {
// appendWildcard(sections.get(Section.PATTERN), input, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (inputLength + 1);
// endIndex = endIndex - (inputLength + 1);
//
// int thatLength = that.length();
// if (beginIndex <= thatLength)
// {
// appendWildcard(sections.get(Section.THAT), that, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (thatLength + 1);
// endIndex = endIndex - (thatLength + 1);
//
// int topicLength = topic.length();
// if (beginIndex < topicLength)
// appendWildcard(sections.get(Section.TOPIC), topic, beginIndex, endIndex);
// }
//
// /**
// Gets the contents for the (index)th wildcard in the matched section.
// */
// public String wildcard(Section section, int index)
// {
// List<String> wildcards = sections.get(section);
// //fixed by lcl
// if(wildcards.size() == 0)
// return "";
// int i = index - 1;
// if(i < wildcards.size() && i > -1)
// return wildcards.get(i);
// else
// return "";
// }
//
// /*
// Properties
// */
//
// public AliceBot getCallback()
// {
// return callback;
// }
//
// public void setCallback(AliceBot callback)
// {
// this.callback = callback;
// }
//
// public String[] getMatchPath()
// {
// return matchPath;
// }
//
// public String getMatchPath(int index)
// {
// return matchPath[index];
// }
//
// public int getMatchPathLength()
// {
// return matchPath.length;
// }
// }
| import org.xml.sax.Attributes;
import bitoflife.chatterbean.Match; | /*
Copyleft (C) 2005 Hio Perroni Filho
xperroni@yahoo.com
ICQ: 2490863
This file is part of ChatterBean.
ChatterBean is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
ChatterBean 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with ChatterBean (look at the Documents/ directory); if not, either write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA, or visit (http://www.gnu.org/licenses/gpl.txt).
*/
package bitoflife.chatterbean.aiml;
public class Size extends TemplateElement
{
/*
Constructors
*/
public Size()
{
}
public Size(Attributes attributes)
{
}
/*
Methods
*/
| // Path: alice-src/bitoflife/chatterbean/Match.java
// public class Match implements Serializable
// {
// /*
// Inner Classes
// */
//
// public enum Section {PATTERN, THAT, TOPIC;}
//
// /*
// Attributes
// */
//
// /** Version class identifier for the serialization engine. Matches the number of the last revision where the class was created / modified. */
// private static final long serialVersionUID = 8L;
//
// private final Map<Section, List<String>> sections = new HashMap<Section, List<String>>();
//
// private AliceBot callback;
//
// private Sentence input;
//
// private Sentence that;
//
// private Sentence topic;
//
// private String[] matchPath;
//
// {
// sections.put(Section.PATTERN, new ArrayList<String>(2)); // Pattern wildcards
// sections.put(Section.THAT, new ArrayList<String>(2)); // That wildcards
// sections.put(Section.TOPIC, new ArrayList<String>(2)); // Topic wildcards
// }
//
// /*
// Constructor
// */
//
// public Match()
// {
// }
//
// public Match(AliceBot callback, Sentence input, Sentence that, Sentence topic)
// {
// this.callback = callback;
// this.input = input;
// this.that = that;
// this.topic = topic;
// setUpMatchPath(input.normalized(), that.normalized(), topic.normalized());
// }
//
// public Match(Sentence input)
// {
// this(null, input, ASTERISK, ASTERISK);
// }
//
// /*
// Methods
// */
//
// private void appendWildcard(List<String> section, Sentence source, int beginIndex, int endIndex)
// {
// if (beginIndex == endIndex)
// section.add(0, "");
// else try
// {
// section.add(0, source.original(beginIndex, endIndex));
// }
// catch (Exception e)
// {
// // throw new RuntimeException("Source: {\"" + source.getOriginal() + "\", \"" + source.getNormalized() + "\"}\n" +
// // "Begin Index: " + beginIndex + "\n" +
// // "End Index: " + endIndex, e);
// }
// }
//
// private void setUpMatchPath(String[] pattern, String[] that, String[] topic)
// {
// int m = pattern.length, n = that.length, o = topic.length;
// matchPath = new String[m + 1 + n + 1 + o];
// matchPath[m] = "<THAT>";
// matchPath[m + 1 + n] = "<TOPIC>";
//
// System.arraycopy(pattern, 0, matchPath, 0, m);
// System.arraycopy(that, 0, matchPath, m + 1, n);
// System.arraycopy(topic, 0, matchPath, m + 1 + n + 1, o);
// }
//
// public void appendWildcard(int beginIndex, int endIndex)
// {
// int inputLength = input.length();
// if (beginIndex <= inputLength)
// {
// appendWildcard(sections.get(Section.PATTERN), input, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (inputLength + 1);
// endIndex = endIndex - (inputLength + 1);
//
// int thatLength = that.length();
// if (beginIndex <= thatLength)
// {
// appendWildcard(sections.get(Section.THAT), that, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (thatLength + 1);
// endIndex = endIndex - (thatLength + 1);
//
// int topicLength = topic.length();
// if (beginIndex < topicLength)
// appendWildcard(sections.get(Section.TOPIC), topic, beginIndex, endIndex);
// }
//
// /**
// Gets the contents for the (index)th wildcard in the matched section.
// */
// public String wildcard(Section section, int index)
// {
// List<String> wildcards = sections.get(section);
// //fixed by lcl
// if(wildcards.size() == 0)
// return "";
// int i = index - 1;
// if(i < wildcards.size() && i > -1)
// return wildcards.get(i);
// else
// return "";
// }
//
// /*
// Properties
// */
//
// public AliceBot getCallback()
// {
// return callback;
// }
//
// public void setCallback(AliceBot callback)
// {
// this.callback = callback;
// }
//
// public String[] getMatchPath()
// {
// return matchPath;
// }
//
// public String getMatchPath(int index)
// {
// return matchPath[index];
// }
//
// public int getMatchPathLength()
// {
// return matchPath.length;
// }
// }
// Path: alice-src/bitoflife/chatterbean/aiml/Size.java
import org.xml.sax.Attributes;
import bitoflife.chatterbean.Match;
/*
Copyleft (C) 2005 Hio Perroni Filho
xperroni@yahoo.com
ICQ: 2490863
This file is part of ChatterBean.
ChatterBean is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
ChatterBean 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with ChatterBean (look at the Documents/ directory); if not, either write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA, or visit (http://www.gnu.org/licenses/gpl.txt).
*/
package bitoflife.chatterbean.aiml;
public class Size extends TemplateElement
{
/*
Constructors
*/
public Size()
{
}
public Size(Attributes attributes)
{
}
/*
Methods
*/
| public String process(Match match) |
WonderBeat/vasilich | alice-src/bitoflife/chatterbean/config/TokenizerConfigStream.java | // Path: alice-src/bitoflife/chatterbean/text/Tokenizer.java
// public class Tokenizer
// {
// /*
// Attribute Section
// */
//
// private Boolean ignoreWhitespace;
//
// private String[] splitters;
//
// private Pattern pattern;
//
// /*
// Constructor Section
// */
//
// public Tokenizer()
// {
// }
//
// public Tokenizer(String... splitters)
// {
// setIgnoreWhitespace(true);
// setSplitters(splitters);
// }
//
// public Tokenizer(TokenizerConfig config)
// {
// this(config.splitters());
// }
//
// /*
// Event Section
// */
//
// private void afterSetProperty()
// {
// if (splitters == null || ignoreWhitespace == null)
// return;
//
// String expression = "";
// for (int i = 0, n = splitters.length;;)
// {
// expression += escapeRegex(splitters[i]);
// if (++i >= n) break;
// expression += '|';
// }
//
// if (ignoreWhitespace)
// expression = "(" + expression + ")\\s*|\\s+";
// else
// expression = "(" + expression + "|\\s+)";
//
// pattern = Pattern.compile(expression);
// }
//
// /*
// Method Section
// */
//
// public List<String> tokenize(String input)
// {
// List<String> output = new ArrayList<String>();
// Matcher matcher = pattern.matcher(input);
// int beginIndex = 0;
//
// while (matcher.find())
// {
// int endIndex = matcher.start();
// String token = input.substring(beginIndex, endIndex);
// if (token.length() > 0)
// output.add(token);
//
// String symbol = matcher.group(1);
// if (symbol != null)
// output.add(symbol);
//
// String breaker = matcher.group();
// beginIndex = endIndex + breaker.length();
// }
//
// if (beginIndex < input.length())
// {
// String token = input.substring(beginIndex);
// output.add(token);
// }
//
// return output;
// }
//
// public String toString(List<String> tokens)
// {
// String output = "";
// int i = 0, n = tokens.size();
// String next = tokens.get(0);
//
// for (;;)
// {
// output += next;
// if (++i >= n) break;
// next = tokens.get(i);
// Matcher matcher = pattern.matcher(next);
// if (!matcher.matches()) output += ' ';
// }
//
// return output;
// }
//
// /*
// Property Section
// */
//
// public boolean getIgnoreWhitespace()
// {
// return ignoreWhitespace;
// }
//
// public void setIgnoreWhitespace(boolean ignore)
// {
// ignoreWhitespace = ignore;
// afterSetProperty();
// }
//
// public String[] getSplitters()
// {
// return splitters;
// }
//
// public void setSplitters(String[] splitters)
// {
// this.splitters = splitters;
// afterSetProperty();
// }
// }
| import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
import bitoflife.chatterbean.text.Tokenizer; | try
{
SAXParserFactory factory = SAXParserFactory.newInstance();
parser = factory.newSAXParser();
parse(input);
}
catch (ConfigException e)
{
throw e;
}
catch (Exception e)
{
throw new ConfigException(e);
}
}
/*
Event Section
*/
public void startElement(String namespace, String name, String qname, Attributes attributes) throws SAXException
{
if ("splitter".equals(qname))
splitters.add(attributes.getValue(0));
}
/*
Method Section
*/
| // Path: alice-src/bitoflife/chatterbean/text/Tokenizer.java
// public class Tokenizer
// {
// /*
// Attribute Section
// */
//
// private Boolean ignoreWhitespace;
//
// private String[] splitters;
//
// private Pattern pattern;
//
// /*
// Constructor Section
// */
//
// public Tokenizer()
// {
// }
//
// public Tokenizer(String... splitters)
// {
// setIgnoreWhitespace(true);
// setSplitters(splitters);
// }
//
// public Tokenizer(TokenizerConfig config)
// {
// this(config.splitters());
// }
//
// /*
// Event Section
// */
//
// private void afterSetProperty()
// {
// if (splitters == null || ignoreWhitespace == null)
// return;
//
// String expression = "";
// for (int i = 0, n = splitters.length;;)
// {
// expression += escapeRegex(splitters[i]);
// if (++i >= n) break;
// expression += '|';
// }
//
// if (ignoreWhitespace)
// expression = "(" + expression + ")\\s*|\\s+";
// else
// expression = "(" + expression + "|\\s+)";
//
// pattern = Pattern.compile(expression);
// }
//
// /*
// Method Section
// */
//
// public List<String> tokenize(String input)
// {
// List<String> output = new ArrayList<String>();
// Matcher matcher = pattern.matcher(input);
// int beginIndex = 0;
//
// while (matcher.find())
// {
// int endIndex = matcher.start();
// String token = input.substring(beginIndex, endIndex);
// if (token.length() > 0)
// output.add(token);
//
// String symbol = matcher.group(1);
// if (symbol != null)
// output.add(symbol);
//
// String breaker = matcher.group();
// beginIndex = endIndex + breaker.length();
// }
//
// if (beginIndex < input.length())
// {
// String token = input.substring(beginIndex);
// output.add(token);
// }
//
// return output;
// }
//
// public String toString(List<String> tokens)
// {
// String output = "";
// int i = 0, n = tokens.size();
// String next = tokens.get(0);
//
// for (;;)
// {
// output += next;
// if (++i >= n) break;
// next = tokens.get(i);
// Matcher matcher = pattern.matcher(next);
// if (!matcher.matches()) output += ' ';
// }
//
// return output;
// }
//
// /*
// Property Section
// */
//
// public boolean getIgnoreWhitespace()
// {
// return ignoreWhitespace;
// }
//
// public void setIgnoreWhitespace(boolean ignore)
// {
// ignoreWhitespace = ignore;
// afterSetProperty();
// }
//
// public String[] getSplitters()
// {
// return splitters;
// }
//
// public void setSplitters(String[] splitters)
// {
// this.splitters = splitters;
// afterSetProperty();
// }
// }
// Path: alice-src/bitoflife/chatterbean/config/TokenizerConfigStream.java
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
import bitoflife.chatterbean.text.Tokenizer;
try
{
SAXParserFactory factory = SAXParserFactory.newInstance();
parser = factory.newSAXParser();
parse(input);
}
catch (ConfigException e)
{
throw e;
}
catch (Exception e)
{
throw new ConfigException(e);
}
}
/*
Event Section
*/
public void startElement(String namespace, String name, String qname, Attributes attributes) throws SAXException
{
if ("splitter".equals(qname))
splitters.add(attributes.getValue(0));
}
/*
Method Section
*/
| public Tokenizer newInstance() |
WonderBeat/vasilich | alice-src/bitoflife/chatterbean/aiml/Formal.java | // Path: alice-src/bitoflife/chatterbean/Match.java
// public class Match implements Serializable
// {
// /*
// Inner Classes
// */
//
// public enum Section {PATTERN, THAT, TOPIC;}
//
// /*
// Attributes
// */
//
// /** Version class identifier for the serialization engine. Matches the number of the last revision where the class was created / modified. */
// private static final long serialVersionUID = 8L;
//
// private final Map<Section, List<String>> sections = new HashMap<Section, List<String>>();
//
// private AliceBot callback;
//
// private Sentence input;
//
// private Sentence that;
//
// private Sentence topic;
//
// private String[] matchPath;
//
// {
// sections.put(Section.PATTERN, new ArrayList<String>(2)); // Pattern wildcards
// sections.put(Section.THAT, new ArrayList<String>(2)); // That wildcards
// sections.put(Section.TOPIC, new ArrayList<String>(2)); // Topic wildcards
// }
//
// /*
// Constructor
// */
//
// public Match()
// {
// }
//
// public Match(AliceBot callback, Sentence input, Sentence that, Sentence topic)
// {
// this.callback = callback;
// this.input = input;
// this.that = that;
// this.topic = topic;
// setUpMatchPath(input.normalized(), that.normalized(), topic.normalized());
// }
//
// public Match(Sentence input)
// {
// this(null, input, ASTERISK, ASTERISK);
// }
//
// /*
// Methods
// */
//
// private void appendWildcard(List<String> section, Sentence source, int beginIndex, int endIndex)
// {
// if (beginIndex == endIndex)
// section.add(0, "");
// else try
// {
// section.add(0, source.original(beginIndex, endIndex));
// }
// catch (Exception e)
// {
// // throw new RuntimeException("Source: {\"" + source.getOriginal() + "\", \"" + source.getNormalized() + "\"}\n" +
// // "Begin Index: " + beginIndex + "\n" +
// // "End Index: " + endIndex, e);
// }
// }
//
// private void setUpMatchPath(String[] pattern, String[] that, String[] topic)
// {
// int m = pattern.length, n = that.length, o = topic.length;
// matchPath = new String[m + 1 + n + 1 + o];
// matchPath[m] = "<THAT>";
// matchPath[m + 1 + n] = "<TOPIC>";
//
// System.arraycopy(pattern, 0, matchPath, 0, m);
// System.arraycopy(that, 0, matchPath, m + 1, n);
// System.arraycopy(topic, 0, matchPath, m + 1 + n + 1, o);
// }
//
// public void appendWildcard(int beginIndex, int endIndex)
// {
// int inputLength = input.length();
// if (beginIndex <= inputLength)
// {
// appendWildcard(sections.get(Section.PATTERN), input, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (inputLength + 1);
// endIndex = endIndex - (inputLength + 1);
//
// int thatLength = that.length();
// if (beginIndex <= thatLength)
// {
// appendWildcard(sections.get(Section.THAT), that, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (thatLength + 1);
// endIndex = endIndex - (thatLength + 1);
//
// int topicLength = topic.length();
// if (beginIndex < topicLength)
// appendWildcard(sections.get(Section.TOPIC), topic, beginIndex, endIndex);
// }
//
// /**
// Gets the contents for the (index)th wildcard in the matched section.
// */
// public String wildcard(Section section, int index)
// {
// List<String> wildcards = sections.get(section);
// //fixed by lcl
// if(wildcards.size() == 0)
// return "";
// int i = index - 1;
// if(i < wildcards.size() && i > -1)
// return wildcards.get(i);
// else
// return "";
// }
//
// /*
// Properties
// */
//
// public AliceBot getCallback()
// {
// return callback;
// }
//
// public void setCallback(AliceBot callback)
// {
// this.callback = callback;
// }
//
// public String[] getMatchPath()
// {
// return matchPath;
// }
//
// public String getMatchPath(int index)
// {
// return matchPath[index];
// }
//
// public int getMatchPathLength()
// {
// return matchPath.length;
// }
// }
| import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.xml.sax.Attributes;
import bitoflife.chatterbean.Match; | /*
Copyleft (C) 2005 Hio Perroni Filho
xperroni@yahoo.com
ICQ: 2490863
This file is part of ChatterBean.
ChatterBean is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
ChatterBean 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with ChatterBean (look at the Documents/ directory); if not, either write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA, or visit (http://www.gnu.org/licenses/gpl.txt).
*/
package bitoflife.chatterbean.aiml;
public class Formal extends TemplateElement
{
/*
Constructors
*/
public Formal(Attributes attributes)
{
}
public Formal(Object... children)
{
super(children);
}
/*
Methods
*/
| // Path: alice-src/bitoflife/chatterbean/Match.java
// public class Match implements Serializable
// {
// /*
// Inner Classes
// */
//
// public enum Section {PATTERN, THAT, TOPIC;}
//
// /*
// Attributes
// */
//
// /** Version class identifier for the serialization engine. Matches the number of the last revision where the class was created / modified. */
// private static final long serialVersionUID = 8L;
//
// private final Map<Section, List<String>> sections = new HashMap<Section, List<String>>();
//
// private AliceBot callback;
//
// private Sentence input;
//
// private Sentence that;
//
// private Sentence topic;
//
// private String[] matchPath;
//
// {
// sections.put(Section.PATTERN, new ArrayList<String>(2)); // Pattern wildcards
// sections.put(Section.THAT, new ArrayList<String>(2)); // That wildcards
// sections.put(Section.TOPIC, new ArrayList<String>(2)); // Topic wildcards
// }
//
// /*
// Constructor
// */
//
// public Match()
// {
// }
//
// public Match(AliceBot callback, Sentence input, Sentence that, Sentence topic)
// {
// this.callback = callback;
// this.input = input;
// this.that = that;
// this.topic = topic;
// setUpMatchPath(input.normalized(), that.normalized(), topic.normalized());
// }
//
// public Match(Sentence input)
// {
// this(null, input, ASTERISK, ASTERISK);
// }
//
// /*
// Methods
// */
//
// private void appendWildcard(List<String> section, Sentence source, int beginIndex, int endIndex)
// {
// if (beginIndex == endIndex)
// section.add(0, "");
// else try
// {
// section.add(0, source.original(beginIndex, endIndex));
// }
// catch (Exception e)
// {
// // throw new RuntimeException("Source: {\"" + source.getOriginal() + "\", \"" + source.getNormalized() + "\"}\n" +
// // "Begin Index: " + beginIndex + "\n" +
// // "End Index: " + endIndex, e);
// }
// }
//
// private void setUpMatchPath(String[] pattern, String[] that, String[] topic)
// {
// int m = pattern.length, n = that.length, o = topic.length;
// matchPath = new String[m + 1 + n + 1 + o];
// matchPath[m] = "<THAT>";
// matchPath[m + 1 + n] = "<TOPIC>";
//
// System.arraycopy(pattern, 0, matchPath, 0, m);
// System.arraycopy(that, 0, matchPath, m + 1, n);
// System.arraycopy(topic, 0, matchPath, m + 1 + n + 1, o);
// }
//
// public void appendWildcard(int beginIndex, int endIndex)
// {
// int inputLength = input.length();
// if (beginIndex <= inputLength)
// {
// appendWildcard(sections.get(Section.PATTERN), input, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (inputLength + 1);
// endIndex = endIndex - (inputLength + 1);
//
// int thatLength = that.length();
// if (beginIndex <= thatLength)
// {
// appendWildcard(sections.get(Section.THAT), that, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (thatLength + 1);
// endIndex = endIndex - (thatLength + 1);
//
// int topicLength = topic.length();
// if (beginIndex < topicLength)
// appendWildcard(sections.get(Section.TOPIC), topic, beginIndex, endIndex);
// }
//
// /**
// Gets the contents for the (index)th wildcard in the matched section.
// */
// public String wildcard(Section section, int index)
// {
// List<String> wildcards = sections.get(section);
// //fixed by lcl
// if(wildcards.size() == 0)
// return "";
// int i = index - 1;
// if(i < wildcards.size() && i > -1)
// return wildcards.get(i);
// else
// return "";
// }
//
// /*
// Properties
// */
//
// public AliceBot getCallback()
// {
// return callback;
// }
//
// public void setCallback(AliceBot callback)
// {
// this.callback = callback;
// }
//
// public String[] getMatchPath()
// {
// return matchPath;
// }
//
// public String getMatchPath(int index)
// {
// return matchPath[index];
// }
//
// public int getMatchPathLength()
// {
// return matchPath.length;
// }
// }
// Path: alice-src/bitoflife/chatterbean/aiml/Formal.java
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.xml.sax.Attributes;
import bitoflife.chatterbean.Match;
/*
Copyleft (C) 2005 Hio Perroni Filho
xperroni@yahoo.com
ICQ: 2490863
This file is part of ChatterBean.
ChatterBean is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
ChatterBean 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with ChatterBean (look at the Documents/ directory); if not, either write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA, or visit (http://www.gnu.org/licenses/gpl.txt).
*/
package bitoflife.chatterbean.aiml;
public class Formal extends TemplateElement
{
/*
Constructors
*/
public Formal(Attributes attributes)
{
}
public Formal(Object... children)
{
super(children);
}
/*
Methods
*/
| public String process(Match match) |
WonderBeat/vasilich | alice-src/bitoflife/chatterbean/text/TokenizerMother.java | // Path: alice-src/bitoflife/chatterbean/config/TokenizerConfig.java
// public interface TokenizerConfig
// {
// public Tokenizer newInstance();
//
// public String[] splitters();
// }
//
// Path: alice-src/bitoflife/chatterbean/config/TokenizerConfigStream.java
// public class TokenizerConfigStream extends DefaultHandler implements TokenizerConfig
// {
// /*
// Attribute Section
// */
//
// private static final String[] STRING_ARRAY = new String[0];
//
// private final SAXParser parser;
//
// private final List<String> splitters = new ArrayList<String>(6);
//
// private boolean ignoreWhitespace;
//
// /*
// Constructor Section
// */
//
// public TokenizerConfigStream() throws ConfigException
// {
// try
// {
// SAXParserFactory factory = SAXParserFactory.newInstance();
// parser = factory.newSAXParser();
// }
// catch (Exception e)
// {
// throw new ConfigException(e);
// }
// }
//
// public TokenizerConfigStream(InputStream input) throws ConfigException
// {
// try
// {
// SAXParserFactory factory = SAXParserFactory.newInstance();
// parser = factory.newSAXParser();
// parse(input);
// }
// catch (ConfigException e)
// {
// throw e;
// }
// catch (Exception e)
// {
// throw new ConfigException(e);
// }
// }
//
// /*
// Event Section
// */
//
// public void startElement(String namespace, String name, String qname, Attributes attributes) throws SAXException
// {
// if ("splitter".equals(qname))
// splitters.add(attributes.getValue(0));
// }
//
// /*
// Method Section
// */
//
// public Tokenizer newInstance()
// {
// return new Tokenizer(splitters());
// }
//
// public void parse(InputStream input) throws ConfigException
// {
// try
// {
// splitters.clear();
// ignoreWhitespace = true;
// parser.parse(input, this);
// }
// catch (Exception e)
// {
// throw new ConfigException(e);
// }
// }
//
// /*
// Accessor Section
// */
//
// public String[] splitters()
// {
// return splitters.toArray(STRING_ARRAY);
// }
// }
| import java.io.FileInputStream;
import bitoflife.chatterbean.config.TokenizerConfig;
import bitoflife.chatterbean.config.TokenizerConfigStream; | /*
Copyleft (C) 2005 Hio Perroni Filho
xperroni@yahoo.com
ICQ: 2490863
This file is part of ChatterBean.
ChatterBean is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
ChatterBean 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with ChatterBean (look at the Documents/ directory); if not, either write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA, or visit (http://www.gnu.org/licenses/gpl.txt).
*/
package bitoflife.chatterbean.text;
public class TokenizerMother
{
/*
Method Section
*/
public static Tokenizer newInstance() throws Exception
{ | // Path: alice-src/bitoflife/chatterbean/config/TokenizerConfig.java
// public interface TokenizerConfig
// {
// public Tokenizer newInstance();
//
// public String[] splitters();
// }
//
// Path: alice-src/bitoflife/chatterbean/config/TokenizerConfigStream.java
// public class TokenizerConfigStream extends DefaultHandler implements TokenizerConfig
// {
// /*
// Attribute Section
// */
//
// private static final String[] STRING_ARRAY = new String[0];
//
// private final SAXParser parser;
//
// private final List<String> splitters = new ArrayList<String>(6);
//
// private boolean ignoreWhitespace;
//
// /*
// Constructor Section
// */
//
// public TokenizerConfigStream() throws ConfigException
// {
// try
// {
// SAXParserFactory factory = SAXParserFactory.newInstance();
// parser = factory.newSAXParser();
// }
// catch (Exception e)
// {
// throw new ConfigException(e);
// }
// }
//
// public TokenizerConfigStream(InputStream input) throws ConfigException
// {
// try
// {
// SAXParserFactory factory = SAXParserFactory.newInstance();
// parser = factory.newSAXParser();
// parse(input);
// }
// catch (ConfigException e)
// {
// throw e;
// }
// catch (Exception e)
// {
// throw new ConfigException(e);
// }
// }
//
// /*
// Event Section
// */
//
// public void startElement(String namespace, String name, String qname, Attributes attributes) throws SAXException
// {
// if ("splitter".equals(qname))
// splitters.add(attributes.getValue(0));
// }
//
// /*
// Method Section
// */
//
// public Tokenizer newInstance()
// {
// return new Tokenizer(splitters());
// }
//
// public void parse(InputStream input) throws ConfigException
// {
// try
// {
// splitters.clear();
// ignoreWhitespace = true;
// parser.parse(input, this);
// }
// catch (Exception e)
// {
// throw new ConfigException(e);
// }
// }
//
// /*
// Accessor Section
// */
//
// public String[] splitters()
// {
// return splitters.toArray(STRING_ARRAY);
// }
// }
// Path: alice-src/bitoflife/chatterbean/text/TokenizerMother.java
import java.io.FileInputStream;
import bitoflife.chatterbean.config.TokenizerConfig;
import bitoflife.chatterbean.config.TokenizerConfigStream;
/*
Copyleft (C) 2005 Hio Perroni Filho
xperroni@yahoo.com
ICQ: 2490863
This file is part of ChatterBean.
ChatterBean is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
ChatterBean 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with ChatterBean (look at the Documents/ directory); if not, either write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA, or visit (http://www.gnu.org/licenses/gpl.txt).
*/
package bitoflife.chatterbean.text;
public class TokenizerMother
{
/*
Method Section
*/
public static Tokenizer newInstance() throws Exception
{ | TokenizerConfig config = new TokenizerConfigStream(new FileInputStream("Bots/splitters.xml")); |
WonderBeat/vasilich | alice-src/bitoflife/chatterbean/text/TokenizerMother.java | // Path: alice-src/bitoflife/chatterbean/config/TokenizerConfig.java
// public interface TokenizerConfig
// {
// public Tokenizer newInstance();
//
// public String[] splitters();
// }
//
// Path: alice-src/bitoflife/chatterbean/config/TokenizerConfigStream.java
// public class TokenizerConfigStream extends DefaultHandler implements TokenizerConfig
// {
// /*
// Attribute Section
// */
//
// private static final String[] STRING_ARRAY = new String[0];
//
// private final SAXParser parser;
//
// private final List<String> splitters = new ArrayList<String>(6);
//
// private boolean ignoreWhitespace;
//
// /*
// Constructor Section
// */
//
// public TokenizerConfigStream() throws ConfigException
// {
// try
// {
// SAXParserFactory factory = SAXParserFactory.newInstance();
// parser = factory.newSAXParser();
// }
// catch (Exception e)
// {
// throw new ConfigException(e);
// }
// }
//
// public TokenizerConfigStream(InputStream input) throws ConfigException
// {
// try
// {
// SAXParserFactory factory = SAXParserFactory.newInstance();
// parser = factory.newSAXParser();
// parse(input);
// }
// catch (ConfigException e)
// {
// throw e;
// }
// catch (Exception e)
// {
// throw new ConfigException(e);
// }
// }
//
// /*
// Event Section
// */
//
// public void startElement(String namespace, String name, String qname, Attributes attributes) throws SAXException
// {
// if ("splitter".equals(qname))
// splitters.add(attributes.getValue(0));
// }
//
// /*
// Method Section
// */
//
// public Tokenizer newInstance()
// {
// return new Tokenizer(splitters());
// }
//
// public void parse(InputStream input) throws ConfigException
// {
// try
// {
// splitters.clear();
// ignoreWhitespace = true;
// parser.parse(input, this);
// }
// catch (Exception e)
// {
// throw new ConfigException(e);
// }
// }
//
// /*
// Accessor Section
// */
//
// public String[] splitters()
// {
// return splitters.toArray(STRING_ARRAY);
// }
// }
| import java.io.FileInputStream;
import bitoflife.chatterbean.config.TokenizerConfig;
import bitoflife.chatterbean.config.TokenizerConfigStream; | /*
Copyleft (C) 2005 Hio Perroni Filho
xperroni@yahoo.com
ICQ: 2490863
This file is part of ChatterBean.
ChatterBean is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
ChatterBean 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with ChatterBean (look at the Documents/ directory); if not, either write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA, or visit (http://www.gnu.org/licenses/gpl.txt).
*/
package bitoflife.chatterbean.text;
public class TokenizerMother
{
/*
Method Section
*/
public static Tokenizer newInstance() throws Exception
{ | // Path: alice-src/bitoflife/chatterbean/config/TokenizerConfig.java
// public interface TokenizerConfig
// {
// public Tokenizer newInstance();
//
// public String[] splitters();
// }
//
// Path: alice-src/bitoflife/chatterbean/config/TokenizerConfigStream.java
// public class TokenizerConfigStream extends DefaultHandler implements TokenizerConfig
// {
// /*
// Attribute Section
// */
//
// private static final String[] STRING_ARRAY = new String[0];
//
// private final SAXParser parser;
//
// private final List<String> splitters = new ArrayList<String>(6);
//
// private boolean ignoreWhitespace;
//
// /*
// Constructor Section
// */
//
// public TokenizerConfigStream() throws ConfigException
// {
// try
// {
// SAXParserFactory factory = SAXParserFactory.newInstance();
// parser = factory.newSAXParser();
// }
// catch (Exception e)
// {
// throw new ConfigException(e);
// }
// }
//
// public TokenizerConfigStream(InputStream input) throws ConfigException
// {
// try
// {
// SAXParserFactory factory = SAXParserFactory.newInstance();
// parser = factory.newSAXParser();
// parse(input);
// }
// catch (ConfigException e)
// {
// throw e;
// }
// catch (Exception e)
// {
// throw new ConfigException(e);
// }
// }
//
// /*
// Event Section
// */
//
// public void startElement(String namespace, String name, String qname, Attributes attributes) throws SAXException
// {
// if ("splitter".equals(qname))
// splitters.add(attributes.getValue(0));
// }
//
// /*
// Method Section
// */
//
// public Tokenizer newInstance()
// {
// return new Tokenizer(splitters());
// }
//
// public void parse(InputStream input) throws ConfigException
// {
// try
// {
// splitters.clear();
// ignoreWhitespace = true;
// parser.parse(input, this);
// }
// catch (Exception e)
// {
// throw new ConfigException(e);
// }
// }
//
// /*
// Accessor Section
// */
//
// public String[] splitters()
// {
// return splitters.toArray(STRING_ARRAY);
// }
// }
// Path: alice-src/bitoflife/chatterbean/text/TokenizerMother.java
import java.io.FileInputStream;
import bitoflife.chatterbean.config.TokenizerConfig;
import bitoflife.chatterbean.config.TokenizerConfigStream;
/*
Copyleft (C) 2005 Hio Perroni Filho
xperroni@yahoo.com
ICQ: 2490863
This file is part of ChatterBean.
ChatterBean is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
ChatterBean 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with ChatterBean (look at the Documents/ directory); if not, either write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA, or visit (http://www.gnu.org/licenses/gpl.txt).
*/
package bitoflife.chatterbean.text;
public class TokenizerMother
{
/*
Method Section
*/
public static Tokenizer newInstance() throws Exception
{ | TokenizerConfig config = new TokenizerConfigStream(new FileInputStream("Bots/splitters.xml")); |
WonderBeat/vasilich | alice-src/bitoflife/chatterbean/text/TransformationsMother.java | // Path: alice-src/bitoflife/chatterbean/parser/TransformationsParser.java
// public class TransformationsParser
// {
// /*
// Attribute Section
// */
//
// private final SubstitutionBuilder substBuilder = new SubstitutionBuilder();
// private final ReflectionHandler substHandler = new ReflectionHandler(substBuilder);
// private final SplitterHandler splitHandler = new SplitterHandler();
//
// private SAXParser parser;
//
// /*
// Constructor Section
// */
//
// public TransformationsParser() throws ParserConfigurationException, SAXException
// {
// parser = SAXParserFactory.newInstance().newSAXParser();
// }
//
// /*
// Method Section
// */
//
// private List<String> parseSplitters(InputStream splitters) throws IOException, SAXException
// {
// splitHandler.clear();
// parser.parse(splitters, splitHandler);
// return splitHandler.parsed();
// }
//
// private Map<String, Map<String, String>> parseSubstitutions(InputStream substitutions) throws IOException, SAXException
// {
// substBuilder.clear();
// parser.parse(substitutions, substHandler);
// return substBuilder.parsed();
// }
//
// private byte[] toByteArray(InputStream input) throws IOException
// {
// List<Byte> list = new LinkedList<Byte>();
// for (int i = 0; (i = input.read()) > -1;)
// list.add((byte) i);
//
// int i = 0;
// byte[] bytes = new byte[list.size()];
// for (byte b : list)
// bytes[i++] = b;
// return bytes;
// }
//
// public Transformations parse(InputStream splitters, InputStream substitutions)
// throws ConfigException, IOException, SAXException
// {
// byte[] bytes = toByteArray(splitters);
//
// TokenizerConfig config = new TokenizerConfigStream(new ByteArrayInputStream(bytes));
// Tokenizer tokenizer = new Tokenizer(config);
//
// List<String> splitChars = parseSplitters(new ByteArrayInputStream(bytes));
//
// Map<String, Map<String, String>> maps = parseSubstitutions(substitutions);
// return new Transformations(splitChars, maps, tokenizer);
// }
// }
| import java.io.FileInputStream;
import bitoflife.chatterbean.parser.TransformationsParser; | /*
Copyleft (C) 2005 Hio Perroni Filho
xperroni@yahoo.com
ICQ: 2490863
This file is part of ChatterBean.
ChatterBean is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
ChatterBean 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with ChatterBean (look at the Documents/ directory); if not, either write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA, or visit (http://www.gnu.org/licenses/gpl.txt).
*/
package bitoflife.chatterbean.text;
public class TransformationsMother
{
/*
Methods
*/
public Transformations newInstance() throws Exception
{ | // Path: alice-src/bitoflife/chatterbean/parser/TransformationsParser.java
// public class TransformationsParser
// {
// /*
// Attribute Section
// */
//
// private final SubstitutionBuilder substBuilder = new SubstitutionBuilder();
// private final ReflectionHandler substHandler = new ReflectionHandler(substBuilder);
// private final SplitterHandler splitHandler = new SplitterHandler();
//
// private SAXParser parser;
//
// /*
// Constructor Section
// */
//
// public TransformationsParser() throws ParserConfigurationException, SAXException
// {
// parser = SAXParserFactory.newInstance().newSAXParser();
// }
//
// /*
// Method Section
// */
//
// private List<String> parseSplitters(InputStream splitters) throws IOException, SAXException
// {
// splitHandler.clear();
// parser.parse(splitters, splitHandler);
// return splitHandler.parsed();
// }
//
// private Map<String, Map<String, String>> parseSubstitutions(InputStream substitutions) throws IOException, SAXException
// {
// substBuilder.clear();
// parser.parse(substitutions, substHandler);
// return substBuilder.parsed();
// }
//
// private byte[] toByteArray(InputStream input) throws IOException
// {
// List<Byte> list = new LinkedList<Byte>();
// for (int i = 0; (i = input.read()) > -1;)
// list.add((byte) i);
//
// int i = 0;
// byte[] bytes = new byte[list.size()];
// for (byte b : list)
// bytes[i++] = b;
// return bytes;
// }
//
// public Transformations parse(InputStream splitters, InputStream substitutions)
// throws ConfigException, IOException, SAXException
// {
// byte[] bytes = toByteArray(splitters);
//
// TokenizerConfig config = new TokenizerConfigStream(new ByteArrayInputStream(bytes));
// Tokenizer tokenizer = new Tokenizer(config);
//
// List<String> splitChars = parseSplitters(new ByteArrayInputStream(bytes));
//
// Map<String, Map<String, String>> maps = parseSubstitutions(substitutions);
// return new Transformations(splitChars, maps, tokenizer);
// }
// }
// Path: alice-src/bitoflife/chatterbean/text/TransformationsMother.java
import java.io.FileInputStream;
import bitoflife.chatterbean.parser.TransformationsParser;
/*
Copyleft (C) 2005 Hio Perroni Filho
xperroni@yahoo.com
ICQ: 2490863
This file is part of ChatterBean.
ChatterBean is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
ChatterBean 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with ChatterBean (look at the Documents/ directory); if not, either write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA, or visit (http://www.gnu.org/licenses/gpl.txt).
*/
package bitoflife.chatterbean.text;
public class TransformationsMother
{
/*
Methods
*/
public Transformations newInstance() throws Exception
{ | TransformationsParser parser = new TransformationsParser(); |
WonderBeat/vasilich | alice-src/bitoflife/chatterbean/text/SentenceSplitter.java | // Path: alice-src/bitoflife/chatterbean/util/Escaper.java
// public static String escapeRegex(String splitter)
// {
// String special = "";
// try
// {
// splitter = splitter.replaceAll("\\\\", "\\\\\\\\");
//
// for (int i = 0, n = regex.length; i < n; i++)
// {
// special = regex[i];
// splitter = splitter.replaceAll(special, "\\" + special);
// }
// }
// catch (RuntimeException e)
// {
// throw new RuntimeException(e.getMessage() + "\nWhen trying to escape \"" + special + "\" in \"" + splitter + "\"", e);
// }
//
// return splitter;
// }
| import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static java.util.regex.Pattern.CASE_INSENSITIVE;
import static java.util.regex.Pattern.UNICODE_CASE;
import static bitoflife.chatterbean.util.Escaper.escapeRegex; | /*
Copyleft (C) 2006 Hio Perroni Filho
xperroni@yahoo.com
ICQ: 2490863
This file is part of ChatterBean.
ChatterBean is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
ChatterBean 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with ChatterBean (look at the Documents/ directory); if not, either write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA, or visit (http://www.gnu.org/licenses/gpl.txt).
*/
package bitoflife.chatterbean.text;
public class SentenceSplitter
{
/*
Attribute Section
*/
/** Map of sentence-protection substitution patterns. */
private final Map<String, String> protection;
/** List of sentence-spliting patterns. */
private final List<String> splitters;
/** The regular expression which will split entries by sentence splitters. */
private final Pattern pattern;
/*
Constructor Section
*/
public SentenceSplitter(Map<String, String> protection, List<String> splitters)
{
this.protection = protection;
this.splitters = splitters;
String splitPattern = "\\s*(";
for (Iterator<String> i = splitters.iterator();;)
{ | // Path: alice-src/bitoflife/chatterbean/util/Escaper.java
// public static String escapeRegex(String splitter)
// {
// String special = "";
// try
// {
// splitter = splitter.replaceAll("\\\\", "\\\\\\\\");
//
// for (int i = 0, n = regex.length; i < n; i++)
// {
// special = regex[i];
// splitter = splitter.replaceAll(special, "\\" + special);
// }
// }
// catch (RuntimeException e)
// {
// throw new RuntimeException(e.getMessage() + "\nWhen trying to escape \"" + special + "\" in \"" + splitter + "\"", e);
// }
//
// return splitter;
// }
// Path: alice-src/bitoflife/chatterbean/text/SentenceSplitter.java
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static java.util.regex.Pattern.CASE_INSENSITIVE;
import static java.util.regex.Pattern.UNICODE_CASE;
import static bitoflife.chatterbean.util.Escaper.escapeRegex;
/*
Copyleft (C) 2006 Hio Perroni Filho
xperroni@yahoo.com
ICQ: 2490863
This file is part of ChatterBean.
ChatterBean is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
ChatterBean 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with ChatterBean (look at the Documents/ directory); if not, either write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA, or visit (http://www.gnu.org/licenses/gpl.txt).
*/
package bitoflife.chatterbean.text;
public class SentenceSplitter
{
/*
Attribute Section
*/
/** Map of sentence-protection substitution patterns. */
private final Map<String, String> protection;
/** List of sentence-spliting patterns. */
private final List<String> splitters;
/** The regular expression which will split entries by sentence splitters. */
private final Pattern pattern;
/*
Constructor Section
*/
public SentenceSplitter(Map<String, String> protection, List<String> splitters)
{
this.protection = protection;
this.splitters = splitters;
String splitPattern = "\\s*(";
for (Iterator<String> i = splitters.iterator();;)
{ | splitPattern += escapeRegex(i.next()); |
WonderBeat/vasilich | alice-src/bitoflife/chatterbean/aiml/Category.java | // Path: alice-src/bitoflife/chatterbean/Match.java
// public class Match implements Serializable
// {
// /*
// Inner Classes
// */
//
// public enum Section {PATTERN, THAT, TOPIC;}
//
// /*
// Attributes
// */
//
// /** Version class identifier for the serialization engine. Matches the number of the last revision where the class was created / modified. */
// private static final long serialVersionUID = 8L;
//
// private final Map<Section, List<String>> sections = new HashMap<Section, List<String>>();
//
// private AliceBot callback;
//
// private Sentence input;
//
// private Sentence that;
//
// private Sentence topic;
//
// private String[] matchPath;
//
// {
// sections.put(Section.PATTERN, new ArrayList<String>(2)); // Pattern wildcards
// sections.put(Section.THAT, new ArrayList<String>(2)); // That wildcards
// sections.put(Section.TOPIC, new ArrayList<String>(2)); // Topic wildcards
// }
//
// /*
// Constructor
// */
//
// public Match()
// {
// }
//
// public Match(AliceBot callback, Sentence input, Sentence that, Sentence topic)
// {
// this.callback = callback;
// this.input = input;
// this.that = that;
// this.topic = topic;
// setUpMatchPath(input.normalized(), that.normalized(), topic.normalized());
// }
//
// public Match(Sentence input)
// {
// this(null, input, ASTERISK, ASTERISK);
// }
//
// /*
// Methods
// */
//
// private void appendWildcard(List<String> section, Sentence source, int beginIndex, int endIndex)
// {
// if (beginIndex == endIndex)
// section.add(0, "");
// else try
// {
// section.add(0, source.original(beginIndex, endIndex));
// }
// catch (Exception e)
// {
// // throw new RuntimeException("Source: {\"" + source.getOriginal() + "\", \"" + source.getNormalized() + "\"}\n" +
// // "Begin Index: " + beginIndex + "\n" +
// // "End Index: " + endIndex, e);
// }
// }
//
// private void setUpMatchPath(String[] pattern, String[] that, String[] topic)
// {
// int m = pattern.length, n = that.length, o = topic.length;
// matchPath = new String[m + 1 + n + 1 + o];
// matchPath[m] = "<THAT>";
// matchPath[m + 1 + n] = "<TOPIC>";
//
// System.arraycopy(pattern, 0, matchPath, 0, m);
// System.arraycopy(that, 0, matchPath, m + 1, n);
// System.arraycopy(topic, 0, matchPath, m + 1 + n + 1, o);
// }
//
// public void appendWildcard(int beginIndex, int endIndex)
// {
// int inputLength = input.length();
// if (beginIndex <= inputLength)
// {
// appendWildcard(sections.get(Section.PATTERN), input, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (inputLength + 1);
// endIndex = endIndex - (inputLength + 1);
//
// int thatLength = that.length();
// if (beginIndex <= thatLength)
// {
// appendWildcard(sections.get(Section.THAT), that, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (thatLength + 1);
// endIndex = endIndex - (thatLength + 1);
//
// int topicLength = topic.length();
// if (beginIndex < topicLength)
// appendWildcard(sections.get(Section.TOPIC), topic, beginIndex, endIndex);
// }
//
// /**
// Gets the contents for the (index)th wildcard in the matched section.
// */
// public String wildcard(Section section, int index)
// {
// List<String> wildcards = sections.get(section);
// //fixed by lcl
// if(wildcards.size() == 0)
// return "";
// int i = index - 1;
// if(i < wildcards.size() && i > -1)
// return wildcards.get(i);
// else
// return "";
// }
//
// /*
// Properties
// */
//
// public AliceBot getCallback()
// {
// return callback;
// }
//
// public void setCallback(AliceBot callback)
// {
// this.callback = callback;
// }
//
// public String[] getMatchPath()
// {
// return matchPath;
// }
//
// public String getMatchPath(int index)
// {
// return matchPath[index];
// }
//
// public int getMatchPathLength()
// {
// return matchPath.length;
// }
// }
| import java.lang.System;
import java.util.List;
import org.xml.sax.Attributes;
import bitoflife.chatterbean.Match; | else if (child instanceof Template)
template = (Template) child;
else
throw new ClassCastException("Invalid element of type " + child.getClass().getName() + ": (" + child + ")");
}
public void appendChildren(List<AIMLElement> children)
{
for (AIMLElement child : children)
appendChild(child);
if (that == null)
that = new That("*");
}
public boolean equals(Object obj)
{
if (obj == null || !(obj instanceof Category)) return false;
Category compared = (Category) obj;
return (pattern.equals(compared.pattern) &&
template.equals(compared.template) &&
that.equals(compared.that));
}
public String toString()
{
return "[" + pattern.toString() + "][" + that.toString() + "][" + template.toString() + "]";
}
| // Path: alice-src/bitoflife/chatterbean/Match.java
// public class Match implements Serializable
// {
// /*
// Inner Classes
// */
//
// public enum Section {PATTERN, THAT, TOPIC;}
//
// /*
// Attributes
// */
//
// /** Version class identifier for the serialization engine. Matches the number of the last revision where the class was created / modified. */
// private static final long serialVersionUID = 8L;
//
// private final Map<Section, List<String>> sections = new HashMap<Section, List<String>>();
//
// private AliceBot callback;
//
// private Sentence input;
//
// private Sentence that;
//
// private Sentence topic;
//
// private String[] matchPath;
//
// {
// sections.put(Section.PATTERN, new ArrayList<String>(2)); // Pattern wildcards
// sections.put(Section.THAT, new ArrayList<String>(2)); // That wildcards
// sections.put(Section.TOPIC, new ArrayList<String>(2)); // Topic wildcards
// }
//
// /*
// Constructor
// */
//
// public Match()
// {
// }
//
// public Match(AliceBot callback, Sentence input, Sentence that, Sentence topic)
// {
// this.callback = callback;
// this.input = input;
// this.that = that;
// this.topic = topic;
// setUpMatchPath(input.normalized(), that.normalized(), topic.normalized());
// }
//
// public Match(Sentence input)
// {
// this(null, input, ASTERISK, ASTERISK);
// }
//
// /*
// Methods
// */
//
// private void appendWildcard(List<String> section, Sentence source, int beginIndex, int endIndex)
// {
// if (beginIndex == endIndex)
// section.add(0, "");
// else try
// {
// section.add(0, source.original(beginIndex, endIndex));
// }
// catch (Exception e)
// {
// // throw new RuntimeException("Source: {\"" + source.getOriginal() + "\", \"" + source.getNormalized() + "\"}\n" +
// // "Begin Index: " + beginIndex + "\n" +
// // "End Index: " + endIndex, e);
// }
// }
//
// private void setUpMatchPath(String[] pattern, String[] that, String[] topic)
// {
// int m = pattern.length, n = that.length, o = topic.length;
// matchPath = new String[m + 1 + n + 1 + o];
// matchPath[m] = "<THAT>";
// matchPath[m + 1 + n] = "<TOPIC>";
//
// System.arraycopy(pattern, 0, matchPath, 0, m);
// System.arraycopy(that, 0, matchPath, m + 1, n);
// System.arraycopy(topic, 0, matchPath, m + 1 + n + 1, o);
// }
//
// public void appendWildcard(int beginIndex, int endIndex)
// {
// int inputLength = input.length();
// if (beginIndex <= inputLength)
// {
// appendWildcard(sections.get(Section.PATTERN), input, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (inputLength + 1);
// endIndex = endIndex - (inputLength + 1);
//
// int thatLength = that.length();
// if (beginIndex <= thatLength)
// {
// appendWildcard(sections.get(Section.THAT), that, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (thatLength + 1);
// endIndex = endIndex - (thatLength + 1);
//
// int topicLength = topic.length();
// if (beginIndex < topicLength)
// appendWildcard(sections.get(Section.TOPIC), topic, beginIndex, endIndex);
// }
//
// /**
// Gets the contents for the (index)th wildcard in the matched section.
// */
// public String wildcard(Section section, int index)
// {
// List<String> wildcards = sections.get(section);
// //fixed by lcl
// if(wildcards.size() == 0)
// return "";
// int i = index - 1;
// if(i < wildcards.size() && i > -1)
// return wildcards.get(i);
// else
// return "";
// }
//
// /*
// Properties
// */
//
// public AliceBot getCallback()
// {
// return callback;
// }
//
// public void setCallback(AliceBot callback)
// {
// this.callback = callback;
// }
//
// public String[] getMatchPath()
// {
// return matchPath;
// }
//
// public String getMatchPath(int index)
// {
// return matchPath[index];
// }
//
// public int getMatchPathLength()
// {
// return matchPath.length;
// }
// }
// Path: alice-src/bitoflife/chatterbean/aiml/Category.java
import java.lang.System;
import java.util.List;
import org.xml.sax.Attributes;
import bitoflife.chatterbean.Match;
else if (child instanceof Template)
template = (Template) child;
else
throw new ClassCastException("Invalid element of type " + child.getClass().getName() + ": (" + child + ")");
}
public void appendChildren(List<AIMLElement> children)
{
for (AIMLElement child : children)
appendChild(child);
if (that == null)
that = new That("*");
}
public boolean equals(Object obj)
{
if (obj == null || !(obj instanceof Category)) return false;
Category compared = (Category) obj;
return (pattern.equals(compared.pattern) &&
template.equals(compared.template) &&
that.equals(compared.that));
}
public String toString()
{
return "[" + pattern.toString() + "][" + that.toString() + "][" + template.toString() + "]";
}
| public String process(Match match) |
WonderBeat/vasilich | alice-src/bitoflife/chatterbean/Match.java | // Path: alice-src/bitoflife/chatterbean/text/Sentence.java
// public class Sentence
// {
// /*
// Attributes
// */
//
// private String original;
// private Integer[] mappings; // The index mappings of normalized elements to original elements.
// private String normalized;
// private String[] splitted; // The normalized entry, splitted in an array of words.
//
// public static final Sentence ASTERISK = new Sentence(" * ", new Integer[] {0, 2}, " * ");
//
// /*
// Constructors
// */
//
// public Sentence(String original, Integer[] mappings, String normalized)
// {
// setOriginal(original);
// setMappings(mappings);
// setNormalized(normalized);
// }
//
// /**
// Constructs a Sentence out of a non-normalized input string.
// */
// public Sentence(String original)
// {
// this(original, null, null);
// }
//
// /*
// Methods
// */
//
// public boolean equals(Object obj)
// {
// if (obj == null || !(obj instanceof Sentence)) return false;
// Sentence compared = (Sentence) obj;
// return (original.equals(compared.original) &&
// Arrays.equals(mappings, compared.mappings) &&
// normalized.equals(compared.normalized));
// }
//
// /**
// Gets the number of individual words contained by the Sentence.
// */
// public int length()
// {
// return splitted.length;
// }
//
// /**
// Returns the normalized as an array of String words.
// */
// public String[] normalized()
// {
// return splitted;
// }
//
// /**
// Gets the (index)th word of the Sentence, in its normalized form.
// */
// public String normalized(int index)
// {
// return splitted[index];
// }
//
// public String original(int beginIndex, int endIndex)
// {
// if (beginIndex < 0)
// throw new ArrayIndexOutOfBoundsException(beginIndex);
//
// while (beginIndex >= 0 && mappings[beginIndex] == null)
// beginIndex--;
//
// int n = mappings.length;
// while (endIndex < n && mappings[endIndex] == null)
// endIndex++;
//
// if (endIndex >= n)
// endIndex = n - 1;
//
// String value = original.substring(mappings[beginIndex], mappings[endIndex] + 1);
//
// value = value.replaceAll("^[^A-Za-z0-9]+|[^A-Za-z0-9]+$", " ");
// return value;
// }
//
// /**
// Returns a string representation of the Sentence. This is useful for printing the state of Sentence objects during tests.
//
// @return A string formed of three bracket-separated sections: the original sentence string, the normalized-to-original word mapping array, and the normalized string.
// */
// public String toString()
// {
// return "[" + original + "]" + Arrays.toString(mappings) + "[" + normalized + "]";
// }
//
// /**
// Returns a trimmed version of the original Sentence string.
//
// @return A trimmed version of the original Sentence string.
// */
// public String trimOriginal()
// {
// return original.trim();
// }
//
// /*
// Properties
// */
//
// public Integer[] getMappings()
// {
// return mappings;
// }
//
// public void setMappings(Integer[] mappings)
// {
// this.mappings = mappings;
// }
//
// /**
// Gets the Sentence in its normalized form.
// */
// public String getNormalized()
// {
// return normalized;
// }
//
// public void setNormalized(String normalized)
// {
// this.normalized = normalized;
// if (normalized != null)
// splitted = normalized.trim().split(" ");
// }
//
// /**
// Gets the Sentence, in its original, unformatted form.
// */
// public String getOriginal()
// {
// return original;
// }
//
// public void setOriginal(String original)
// {
// this.original = original;
// }
// }
//
// Path: alice-src/bitoflife/chatterbean/text/Sentence.java
// public static final Sentence ASTERISK = new Sentence(" * ", new Integer[] {0, 2}, " * ");
| import java.io.Serializable;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import bitoflife.chatterbean.text.Sentence;
import static bitoflife.chatterbean.text.Sentence.ASTERISK; | /*
Copyleft (C) 2005 Hio Perroni Filho
xperroni@yahoo.com
ICQ: 2490863
This file is part of ChatterBean.
ChatterBean is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
ChatterBean 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with ChatterBean (look at the Documents/ directory); if not, either write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA, or visit (http://www.gnu.org/licenses/gpl.txt).
*/
package bitoflife.chatterbean;
/**
Contains information about a match operation, which is needed by the classes of the <code>bitoflife.chatterbean.aiml</code> to produce a proper response.
*/
public class Match implements Serializable
{
/*
Inner Classes
*/
public enum Section {PATTERN, THAT, TOPIC;}
/*
Attributes
*/
/** Version class identifier for the serialization engine. Matches the number of the last revision where the class was created / modified. */
private static final long serialVersionUID = 8L;
private final Map<Section, List<String>> sections = new HashMap<Section, List<String>>();
private AliceBot callback;
| // Path: alice-src/bitoflife/chatterbean/text/Sentence.java
// public class Sentence
// {
// /*
// Attributes
// */
//
// private String original;
// private Integer[] mappings; // The index mappings of normalized elements to original elements.
// private String normalized;
// private String[] splitted; // The normalized entry, splitted in an array of words.
//
// public static final Sentence ASTERISK = new Sentence(" * ", new Integer[] {0, 2}, " * ");
//
// /*
// Constructors
// */
//
// public Sentence(String original, Integer[] mappings, String normalized)
// {
// setOriginal(original);
// setMappings(mappings);
// setNormalized(normalized);
// }
//
// /**
// Constructs a Sentence out of a non-normalized input string.
// */
// public Sentence(String original)
// {
// this(original, null, null);
// }
//
// /*
// Methods
// */
//
// public boolean equals(Object obj)
// {
// if (obj == null || !(obj instanceof Sentence)) return false;
// Sentence compared = (Sentence) obj;
// return (original.equals(compared.original) &&
// Arrays.equals(mappings, compared.mappings) &&
// normalized.equals(compared.normalized));
// }
//
// /**
// Gets the number of individual words contained by the Sentence.
// */
// public int length()
// {
// return splitted.length;
// }
//
// /**
// Returns the normalized as an array of String words.
// */
// public String[] normalized()
// {
// return splitted;
// }
//
// /**
// Gets the (index)th word of the Sentence, in its normalized form.
// */
// public String normalized(int index)
// {
// return splitted[index];
// }
//
// public String original(int beginIndex, int endIndex)
// {
// if (beginIndex < 0)
// throw new ArrayIndexOutOfBoundsException(beginIndex);
//
// while (beginIndex >= 0 && mappings[beginIndex] == null)
// beginIndex--;
//
// int n = mappings.length;
// while (endIndex < n && mappings[endIndex] == null)
// endIndex++;
//
// if (endIndex >= n)
// endIndex = n - 1;
//
// String value = original.substring(mappings[beginIndex], mappings[endIndex] + 1);
//
// value = value.replaceAll("^[^A-Za-z0-9]+|[^A-Za-z0-9]+$", " ");
// return value;
// }
//
// /**
// Returns a string representation of the Sentence. This is useful for printing the state of Sentence objects during tests.
//
// @return A string formed of three bracket-separated sections: the original sentence string, the normalized-to-original word mapping array, and the normalized string.
// */
// public String toString()
// {
// return "[" + original + "]" + Arrays.toString(mappings) + "[" + normalized + "]";
// }
//
// /**
// Returns a trimmed version of the original Sentence string.
//
// @return A trimmed version of the original Sentence string.
// */
// public String trimOriginal()
// {
// return original.trim();
// }
//
// /*
// Properties
// */
//
// public Integer[] getMappings()
// {
// return mappings;
// }
//
// public void setMappings(Integer[] mappings)
// {
// this.mappings = mappings;
// }
//
// /**
// Gets the Sentence in its normalized form.
// */
// public String getNormalized()
// {
// return normalized;
// }
//
// public void setNormalized(String normalized)
// {
// this.normalized = normalized;
// if (normalized != null)
// splitted = normalized.trim().split(" ");
// }
//
// /**
// Gets the Sentence, in its original, unformatted form.
// */
// public String getOriginal()
// {
// return original;
// }
//
// public void setOriginal(String original)
// {
// this.original = original;
// }
// }
//
// Path: alice-src/bitoflife/chatterbean/text/Sentence.java
// public static final Sentence ASTERISK = new Sentence(" * ", new Integer[] {0, 2}, " * ");
// Path: alice-src/bitoflife/chatterbean/Match.java
import java.io.Serializable;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import bitoflife.chatterbean.text.Sentence;
import static bitoflife.chatterbean.text.Sentence.ASTERISK;
/*
Copyleft (C) 2005 Hio Perroni Filho
xperroni@yahoo.com
ICQ: 2490863
This file is part of ChatterBean.
ChatterBean is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
ChatterBean 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with ChatterBean (look at the Documents/ directory); if not, either write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA, or visit (http://www.gnu.org/licenses/gpl.txt).
*/
package bitoflife.chatterbean;
/**
Contains information about a match operation, which is needed by the classes of the <code>bitoflife.chatterbean.aiml</code> to produce a proper response.
*/
public class Match implements Serializable
{
/*
Inner Classes
*/
public enum Section {PATTERN, THAT, TOPIC;}
/*
Attributes
*/
/** Version class identifier for the serialization engine. Matches the number of the last revision where the class was created / modified. */
private static final long serialVersionUID = 8L;
private final Map<Section, List<String>> sections = new HashMap<Section, List<String>>();
private AliceBot callback;
| private Sentence input; |
WonderBeat/vasilich | alice-src/bitoflife/chatterbean/aiml/B.java | // Path: alice-src/bitoflife/chatterbean/Match.java
// public class Match implements Serializable
// {
// /*
// Inner Classes
// */
//
// public enum Section {PATTERN, THAT, TOPIC;}
//
// /*
// Attributes
// */
//
// /** Version class identifier for the serialization engine. Matches the number of the last revision where the class was created / modified. */
// private static final long serialVersionUID = 8L;
//
// private final Map<Section, List<String>> sections = new HashMap<Section, List<String>>();
//
// private AliceBot callback;
//
// private Sentence input;
//
// private Sentence that;
//
// private Sentence topic;
//
// private String[] matchPath;
//
// {
// sections.put(Section.PATTERN, new ArrayList<String>(2)); // Pattern wildcards
// sections.put(Section.THAT, new ArrayList<String>(2)); // That wildcards
// sections.put(Section.TOPIC, new ArrayList<String>(2)); // Topic wildcards
// }
//
// /*
// Constructor
// */
//
// public Match()
// {
// }
//
// public Match(AliceBot callback, Sentence input, Sentence that, Sentence topic)
// {
// this.callback = callback;
// this.input = input;
// this.that = that;
// this.topic = topic;
// setUpMatchPath(input.normalized(), that.normalized(), topic.normalized());
// }
//
// public Match(Sentence input)
// {
// this(null, input, ASTERISK, ASTERISK);
// }
//
// /*
// Methods
// */
//
// private void appendWildcard(List<String> section, Sentence source, int beginIndex, int endIndex)
// {
// if (beginIndex == endIndex)
// section.add(0, "");
// else try
// {
// section.add(0, source.original(beginIndex, endIndex));
// }
// catch (Exception e)
// {
// // throw new RuntimeException("Source: {\"" + source.getOriginal() + "\", \"" + source.getNormalized() + "\"}\n" +
// // "Begin Index: " + beginIndex + "\n" +
// // "End Index: " + endIndex, e);
// }
// }
//
// private void setUpMatchPath(String[] pattern, String[] that, String[] topic)
// {
// int m = pattern.length, n = that.length, o = topic.length;
// matchPath = new String[m + 1 + n + 1 + o];
// matchPath[m] = "<THAT>";
// matchPath[m + 1 + n] = "<TOPIC>";
//
// System.arraycopy(pattern, 0, matchPath, 0, m);
// System.arraycopy(that, 0, matchPath, m + 1, n);
// System.arraycopy(topic, 0, matchPath, m + 1 + n + 1, o);
// }
//
// public void appendWildcard(int beginIndex, int endIndex)
// {
// int inputLength = input.length();
// if (beginIndex <= inputLength)
// {
// appendWildcard(sections.get(Section.PATTERN), input, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (inputLength + 1);
// endIndex = endIndex - (inputLength + 1);
//
// int thatLength = that.length();
// if (beginIndex <= thatLength)
// {
// appendWildcard(sections.get(Section.THAT), that, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (thatLength + 1);
// endIndex = endIndex - (thatLength + 1);
//
// int topicLength = topic.length();
// if (beginIndex < topicLength)
// appendWildcard(sections.get(Section.TOPIC), topic, beginIndex, endIndex);
// }
//
// /**
// Gets the contents for the (index)th wildcard in the matched section.
// */
// public String wildcard(Section section, int index)
// {
// List<String> wildcards = sections.get(section);
// //fixed by lcl
// if(wildcards.size() == 0)
// return "";
// int i = index - 1;
// if(i < wildcards.size() && i > -1)
// return wildcards.get(i);
// else
// return "";
// }
//
// /*
// Properties
// */
//
// public AliceBot getCallback()
// {
// return callback;
// }
//
// public void setCallback(AliceBot callback)
// {
// this.callback = callback;
// }
//
// public String[] getMatchPath()
// {
// return matchPath;
// }
//
// public String getMatchPath(int index)
// {
// return matchPath[index];
// }
//
// public int getMatchPathLength()
// {
// return matchPath.length;
// }
// }
| import org.xml.sax.Attributes;
import bitoflife.chatterbean.Match; | package bitoflife.chatterbean.aiml;
public class B extends TemplateElement
{
/*
Constructors
*/
public B(Attributes attributes)
{
}
public B(Object... children)
{
super(children);
}
/*
Methods
*/
| // Path: alice-src/bitoflife/chatterbean/Match.java
// public class Match implements Serializable
// {
// /*
// Inner Classes
// */
//
// public enum Section {PATTERN, THAT, TOPIC;}
//
// /*
// Attributes
// */
//
// /** Version class identifier for the serialization engine. Matches the number of the last revision where the class was created / modified. */
// private static final long serialVersionUID = 8L;
//
// private final Map<Section, List<String>> sections = new HashMap<Section, List<String>>();
//
// private AliceBot callback;
//
// private Sentence input;
//
// private Sentence that;
//
// private Sentence topic;
//
// private String[] matchPath;
//
// {
// sections.put(Section.PATTERN, new ArrayList<String>(2)); // Pattern wildcards
// sections.put(Section.THAT, new ArrayList<String>(2)); // That wildcards
// sections.put(Section.TOPIC, new ArrayList<String>(2)); // Topic wildcards
// }
//
// /*
// Constructor
// */
//
// public Match()
// {
// }
//
// public Match(AliceBot callback, Sentence input, Sentence that, Sentence topic)
// {
// this.callback = callback;
// this.input = input;
// this.that = that;
// this.topic = topic;
// setUpMatchPath(input.normalized(), that.normalized(), topic.normalized());
// }
//
// public Match(Sentence input)
// {
// this(null, input, ASTERISK, ASTERISK);
// }
//
// /*
// Methods
// */
//
// private void appendWildcard(List<String> section, Sentence source, int beginIndex, int endIndex)
// {
// if (beginIndex == endIndex)
// section.add(0, "");
// else try
// {
// section.add(0, source.original(beginIndex, endIndex));
// }
// catch (Exception e)
// {
// // throw new RuntimeException("Source: {\"" + source.getOriginal() + "\", \"" + source.getNormalized() + "\"}\n" +
// // "Begin Index: " + beginIndex + "\n" +
// // "End Index: " + endIndex, e);
// }
// }
//
// private void setUpMatchPath(String[] pattern, String[] that, String[] topic)
// {
// int m = pattern.length, n = that.length, o = topic.length;
// matchPath = new String[m + 1 + n + 1 + o];
// matchPath[m] = "<THAT>";
// matchPath[m + 1 + n] = "<TOPIC>";
//
// System.arraycopy(pattern, 0, matchPath, 0, m);
// System.arraycopy(that, 0, matchPath, m + 1, n);
// System.arraycopy(topic, 0, matchPath, m + 1 + n + 1, o);
// }
//
// public void appendWildcard(int beginIndex, int endIndex)
// {
// int inputLength = input.length();
// if (beginIndex <= inputLength)
// {
// appendWildcard(sections.get(Section.PATTERN), input, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (inputLength + 1);
// endIndex = endIndex - (inputLength + 1);
//
// int thatLength = that.length();
// if (beginIndex <= thatLength)
// {
// appendWildcard(sections.get(Section.THAT), that, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (thatLength + 1);
// endIndex = endIndex - (thatLength + 1);
//
// int topicLength = topic.length();
// if (beginIndex < topicLength)
// appendWildcard(sections.get(Section.TOPIC), topic, beginIndex, endIndex);
// }
//
// /**
// Gets the contents for the (index)th wildcard in the matched section.
// */
// public String wildcard(Section section, int index)
// {
// List<String> wildcards = sections.get(section);
// //fixed by lcl
// if(wildcards.size() == 0)
// return "";
// int i = index - 1;
// if(i < wildcards.size() && i > -1)
// return wildcards.get(i);
// else
// return "";
// }
//
// /*
// Properties
// */
//
// public AliceBot getCallback()
// {
// return callback;
// }
//
// public void setCallback(AliceBot callback)
// {
// this.callback = callback;
// }
//
// public String[] getMatchPath()
// {
// return matchPath;
// }
//
// public String getMatchPath(int index)
// {
// return matchPath[index];
// }
//
// public int getMatchPathLength()
// {
// return matchPath.length;
// }
// }
// Path: alice-src/bitoflife/chatterbean/aiml/B.java
import org.xml.sax.Attributes;
import bitoflife.chatterbean.Match;
package bitoflife.chatterbean.aiml;
public class B extends TemplateElement
{
/*
Constructors
*/
public B(Attributes attributes)
{
}
public B(Object... children)
{
super(children);
}
/*
Methods
*/
| public String process(Match match) |
WonderBeat/vasilich | alice-src/bitoflife/chatterbean/aiml/Sentence.java | // Path: alice-src/bitoflife/chatterbean/Match.java
// public class Match implements Serializable
// {
// /*
// Inner Classes
// */
//
// public enum Section {PATTERN, THAT, TOPIC;}
//
// /*
// Attributes
// */
//
// /** Version class identifier for the serialization engine. Matches the number of the last revision where the class was created / modified. */
// private static final long serialVersionUID = 8L;
//
// private final Map<Section, List<String>> sections = new HashMap<Section, List<String>>();
//
// private AliceBot callback;
//
// private Sentence input;
//
// private Sentence that;
//
// private Sentence topic;
//
// private String[] matchPath;
//
// {
// sections.put(Section.PATTERN, new ArrayList<String>(2)); // Pattern wildcards
// sections.put(Section.THAT, new ArrayList<String>(2)); // That wildcards
// sections.put(Section.TOPIC, new ArrayList<String>(2)); // Topic wildcards
// }
//
// /*
// Constructor
// */
//
// public Match()
// {
// }
//
// public Match(AliceBot callback, Sentence input, Sentence that, Sentence topic)
// {
// this.callback = callback;
// this.input = input;
// this.that = that;
// this.topic = topic;
// setUpMatchPath(input.normalized(), that.normalized(), topic.normalized());
// }
//
// public Match(Sentence input)
// {
// this(null, input, ASTERISK, ASTERISK);
// }
//
// /*
// Methods
// */
//
// private void appendWildcard(List<String> section, Sentence source, int beginIndex, int endIndex)
// {
// if (beginIndex == endIndex)
// section.add(0, "");
// else try
// {
// section.add(0, source.original(beginIndex, endIndex));
// }
// catch (Exception e)
// {
// // throw new RuntimeException("Source: {\"" + source.getOriginal() + "\", \"" + source.getNormalized() + "\"}\n" +
// // "Begin Index: " + beginIndex + "\n" +
// // "End Index: " + endIndex, e);
// }
// }
//
// private void setUpMatchPath(String[] pattern, String[] that, String[] topic)
// {
// int m = pattern.length, n = that.length, o = topic.length;
// matchPath = new String[m + 1 + n + 1 + o];
// matchPath[m] = "<THAT>";
// matchPath[m + 1 + n] = "<TOPIC>";
//
// System.arraycopy(pattern, 0, matchPath, 0, m);
// System.arraycopy(that, 0, matchPath, m + 1, n);
// System.arraycopy(topic, 0, matchPath, m + 1 + n + 1, o);
// }
//
// public void appendWildcard(int beginIndex, int endIndex)
// {
// int inputLength = input.length();
// if (beginIndex <= inputLength)
// {
// appendWildcard(sections.get(Section.PATTERN), input, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (inputLength + 1);
// endIndex = endIndex - (inputLength + 1);
//
// int thatLength = that.length();
// if (beginIndex <= thatLength)
// {
// appendWildcard(sections.get(Section.THAT), that, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (thatLength + 1);
// endIndex = endIndex - (thatLength + 1);
//
// int topicLength = topic.length();
// if (beginIndex < topicLength)
// appendWildcard(sections.get(Section.TOPIC), topic, beginIndex, endIndex);
// }
//
// /**
// Gets the contents for the (index)th wildcard in the matched section.
// */
// public String wildcard(Section section, int index)
// {
// List<String> wildcards = sections.get(section);
// //fixed by lcl
// if(wildcards.size() == 0)
// return "";
// int i = index - 1;
// if(i < wildcards.size() && i > -1)
// return wildcards.get(i);
// else
// return "";
// }
//
// /*
// Properties
// */
//
// public AliceBot getCallback()
// {
// return callback;
// }
//
// public void setCallback(AliceBot callback)
// {
// this.callback = callback;
// }
//
// public String[] getMatchPath()
// {
// return matchPath;
// }
//
// public String getMatchPath(int index)
// {
// return matchPath[index];
// }
//
// public int getMatchPathLength()
// {
// return matchPath.length;
// }
// }
| import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.xml.sax.Attributes;
import bitoflife.chatterbean.Match; | /*
Copyleft (C) 2005 Hio Perroni Filho
xperroni@yahoo.com
ICQ: 2490863
This file is part of ChatterBean.
ChatterBean is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
ChatterBean 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with ChatterBean (look at the Documents/ directory); if not, either write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA, or visit (http://www.gnu.org/licenses/gpl.txt).
*/
package bitoflife.chatterbean.aiml;
public class Sentence extends TemplateElement
{
/*
Constructors
*/
public Sentence(Attributes attributes)
{
}
public Sentence(Object... children)
{
super(children);
}
/*
Methods
*/
| // Path: alice-src/bitoflife/chatterbean/Match.java
// public class Match implements Serializable
// {
// /*
// Inner Classes
// */
//
// public enum Section {PATTERN, THAT, TOPIC;}
//
// /*
// Attributes
// */
//
// /** Version class identifier for the serialization engine. Matches the number of the last revision where the class was created / modified. */
// private static final long serialVersionUID = 8L;
//
// private final Map<Section, List<String>> sections = new HashMap<Section, List<String>>();
//
// private AliceBot callback;
//
// private Sentence input;
//
// private Sentence that;
//
// private Sentence topic;
//
// private String[] matchPath;
//
// {
// sections.put(Section.PATTERN, new ArrayList<String>(2)); // Pattern wildcards
// sections.put(Section.THAT, new ArrayList<String>(2)); // That wildcards
// sections.put(Section.TOPIC, new ArrayList<String>(2)); // Topic wildcards
// }
//
// /*
// Constructor
// */
//
// public Match()
// {
// }
//
// public Match(AliceBot callback, Sentence input, Sentence that, Sentence topic)
// {
// this.callback = callback;
// this.input = input;
// this.that = that;
// this.topic = topic;
// setUpMatchPath(input.normalized(), that.normalized(), topic.normalized());
// }
//
// public Match(Sentence input)
// {
// this(null, input, ASTERISK, ASTERISK);
// }
//
// /*
// Methods
// */
//
// private void appendWildcard(List<String> section, Sentence source, int beginIndex, int endIndex)
// {
// if (beginIndex == endIndex)
// section.add(0, "");
// else try
// {
// section.add(0, source.original(beginIndex, endIndex));
// }
// catch (Exception e)
// {
// // throw new RuntimeException("Source: {\"" + source.getOriginal() + "\", \"" + source.getNormalized() + "\"}\n" +
// // "Begin Index: " + beginIndex + "\n" +
// // "End Index: " + endIndex, e);
// }
// }
//
// private void setUpMatchPath(String[] pattern, String[] that, String[] topic)
// {
// int m = pattern.length, n = that.length, o = topic.length;
// matchPath = new String[m + 1 + n + 1 + o];
// matchPath[m] = "<THAT>";
// matchPath[m + 1 + n] = "<TOPIC>";
//
// System.arraycopy(pattern, 0, matchPath, 0, m);
// System.arraycopy(that, 0, matchPath, m + 1, n);
// System.arraycopy(topic, 0, matchPath, m + 1 + n + 1, o);
// }
//
// public void appendWildcard(int beginIndex, int endIndex)
// {
// int inputLength = input.length();
// if (beginIndex <= inputLength)
// {
// appendWildcard(sections.get(Section.PATTERN), input, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (inputLength + 1);
// endIndex = endIndex - (inputLength + 1);
//
// int thatLength = that.length();
// if (beginIndex <= thatLength)
// {
// appendWildcard(sections.get(Section.THAT), that, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (thatLength + 1);
// endIndex = endIndex - (thatLength + 1);
//
// int topicLength = topic.length();
// if (beginIndex < topicLength)
// appendWildcard(sections.get(Section.TOPIC), topic, beginIndex, endIndex);
// }
//
// /**
// Gets the contents for the (index)th wildcard in the matched section.
// */
// public String wildcard(Section section, int index)
// {
// List<String> wildcards = sections.get(section);
// //fixed by lcl
// if(wildcards.size() == 0)
// return "";
// int i = index - 1;
// if(i < wildcards.size() && i > -1)
// return wildcards.get(i);
// else
// return "";
// }
//
// /*
// Properties
// */
//
// public AliceBot getCallback()
// {
// return callback;
// }
//
// public void setCallback(AliceBot callback)
// {
// this.callback = callback;
// }
//
// public String[] getMatchPath()
// {
// return matchPath;
// }
//
// public String getMatchPath(int index)
// {
// return matchPath[index];
// }
//
// public int getMatchPathLength()
// {
// return matchPath.length;
// }
// }
// Path: alice-src/bitoflife/chatterbean/aiml/Sentence.java
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.xml.sax.Attributes;
import bitoflife.chatterbean.Match;
/*
Copyleft (C) 2005 Hio Perroni Filho
xperroni@yahoo.com
ICQ: 2490863
This file is part of ChatterBean.
ChatterBean is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
ChatterBean 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with ChatterBean (look at the Documents/ directory); if not, either write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA, or visit (http://www.gnu.org/licenses/gpl.txt).
*/
package bitoflife.chatterbean.aiml;
public class Sentence extends TemplateElement
{
/*
Constructors
*/
public Sentence(Attributes attributes)
{
}
public Sentence(Object... children)
{
super(children);
}
/*
Methods
*/
| public String process(Match match) |
WonderBeat/vasilich | alice-src/bitoflife/chatterbean/text/Tokenizer.java | // Path: alice-src/bitoflife/chatterbean/config/TokenizerConfig.java
// public interface TokenizerConfig
// {
// public Tokenizer newInstance();
//
// public String[] splitters();
// }
//
// Path: alice-src/bitoflife/chatterbean/util/Escaper.java
// public static String escapeRegex(String splitter)
// {
// String special = "";
// try
// {
// splitter = splitter.replaceAll("\\\\", "\\\\\\\\");
//
// for (int i = 0, n = regex.length; i < n; i++)
// {
// special = regex[i];
// splitter = splitter.replaceAll(special, "\\" + special);
// }
// }
// catch (RuntimeException e)
// {
// throw new RuntimeException(e.getMessage() + "\nWhen trying to escape \"" + special + "\" in \"" + splitter + "\"", e);
// }
//
// return splitter;
// }
| import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import bitoflife.chatterbean.config.TokenizerConfig;
import static bitoflife.chatterbean.util.Escaper.escapeRegex; | /*
Copyleft (C) 2005 Hio Perroni Filho
xperroni@yahoo.com
ICQ: 2490863
This file is part of ChatterBean.
ChatterBean is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
ChatterBean 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with ChatterBean (look at the Documents/ directory); if not, either write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA, or visit (http://www.gnu.org/licenses/gpl.txt).
*/
package bitoflife.chatterbean.text;
public class Tokenizer
{
/*
Attribute Section
*/
private Boolean ignoreWhitespace;
private String[] splitters;
private Pattern pattern;
/*
Constructor Section
*/
public Tokenizer()
{
}
public Tokenizer(String... splitters)
{
setIgnoreWhitespace(true);
setSplitters(splitters);
}
| // Path: alice-src/bitoflife/chatterbean/config/TokenizerConfig.java
// public interface TokenizerConfig
// {
// public Tokenizer newInstance();
//
// public String[] splitters();
// }
//
// Path: alice-src/bitoflife/chatterbean/util/Escaper.java
// public static String escapeRegex(String splitter)
// {
// String special = "";
// try
// {
// splitter = splitter.replaceAll("\\\\", "\\\\\\\\");
//
// for (int i = 0, n = regex.length; i < n; i++)
// {
// special = regex[i];
// splitter = splitter.replaceAll(special, "\\" + special);
// }
// }
// catch (RuntimeException e)
// {
// throw new RuntimeException(e.getMessage() + "\nWhen trying to escape \"" + special + "\" in \"" + splitter + "\"", e);
// }
//
// return splitter;
// }
// Path: alice-src/bitoflife/chatterbean/text/Tokenizer.java
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import bitoflife.chatterbean.config.TokenizerConfig;
import static bitoflife.chatterbean.util.Escaper.escapeRegex;
/*
Copyleft (C) 2005 Hio Perroni Filho
xperroni@yahoo.com
ICQ: 2490863
This file is part of ChatterBean.
ChatterBean is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
ChatterBean 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with ChatterBean (look at the Documents/ directory); if not, either write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA, or visit (http://www.gnu.org/licenses/gpl.txt).
*/
package bitoflife.chatterbean.text;
public class Tokenizer
{
/*
Attribute Section
*/
private Boolean ignoreWhitespace;
private String[] splitters;
private Pattern pattern;
/*
Constructor Section
*/
public Tokenizer()
{
}
public Tokenizer(String... splitters)
{
setIgnoreWhitespace(true);
setSplitters(splitters);
}
| public Tokenizer(TokenizerConfig config) |
WonderBeat/vasilich | alice-src/bitoflife/chatterbean/text/Tokenizer.java | // Path: alice-src/bitoflife/chatterbean/config/TokenizerConfig.java
// public interface TokenizerConfig
// {
// public Tokenizer newInstance();
//
// public String[] splitters();
// }
//
// Path: alice-src/bitoflife/chatterbean/util/Escaper.java
// public static String escapeRegex(String splitter)
// {
// String special = "";
// try
// {
// splitter = splitter.replaceAll("\\\\", "\\\\\\\\");
//
// for (int i = 0, n = regex.length; i < n; i++)
// {
// special = regex[i];
// splitter = splitter.replaceAll(special, "\\" + special);
// }
// }
// catch (RuntimeException e)
// {
// throw new RuntimeException(e.getMessage() + "\nWhen trying to escape \"" + special + "\" in \"" + splitter + "\"", e);
// }
//
// return splitter;
// }
| import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import bitoflife.chatterbean.config.TokenizerConfig;
import static bitoflife.chatterbean.util.Escaper.escapeRegex; | /*
Copyleft (C) 2005 Hio Perroni Filho
xperroni@yahoo.com
ICQ: 2490863
This file is part of ChatterBean.
ChatterBean is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
ChatterBean 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with ChatterBean (look at the Documents/ directory); if not, either write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA, or visit (http://www.gnu.org/licenses/gpl.txt).
*/
package bitoflife.chatterbean.text;
public class Tokenizer
{
/*
Attribute Section
*/
private Boolean ignoreWhitespace;
private String[] splitters;
private Pattern pattern;
/*
Constructor Section
*/
public Tokenizer()
{
}
public Tokenizer(String... splitters)
{
setIgnoreWhitespace(true);
setSplitters(splitters);
}
public Tokenizer(TokenizerConfig config)
{
this(config.splitters());
}
/*
Event Section
*/
private void afterSetProperty()
{
if (splitters == null || ignoreWhitespace == null)
return;
String expression = "";
for (int i = 0, n = splitters.length;;)
{ | // Path: alice-src/bitoflife/chatterbean/config/TokenizerConfig.java
// public interface TokenizerConfig
// {
// public Tokenizer newInstance();
//
// public String[] splitters();
// }
//
// Path: alice-src/bitoflife/chatterbean/util/Escaper.java
// public static String escapeRegex(String splitter)
// {
// String special = "";
// try
// {
// splitter = splitter.replaceAll("\\\\", "\\\\\\\\");
//
// for (int i = 0, n = regex.length; i < n; i++)
// {
// special = regex[i];
// splitter = splitter.replaceAll(special, "\\" + special);
// }
// }
// catch (RuntimeException e)
// {
// throw new RuntimeException(e.getMessage() + "\nWhen trying to escape \"" + special + "\" in \"" + splitter + "\"", e);
// }
//
// return splitter;
// }
// Path: alice-src/bitoflife/chatterbean/text/Tokenizer.java
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import bitoflife.chatterbean.config.TokenizerConfig;
import static bitoflife.chatterbean.util.Escaper.escapeRegex;
/*
Copyleft (C) 2005 Hio Perroni Filho
xperroni@yahoo.com
ICQ: 2490863
This file is part of ChatterBean.
ChatterBean is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
ChatterBean 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with ChatterBean (look at the Documents/ directory); if not, either write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA, or visit (http://www.gnu.org/licenses/gpl.txt).
*/
package bitoflife.chatterbean.text;
public class Tokenizer
{
/*
Attribute Section
*/
private Boolean ignoreWhitespace;
private String[] splitters;
private Pattern pattern;
/*
Constructor Section
*/
public Tokenizer()
{
}
public Tokenizer(String... splitters)
{
setIgnoreWhitespace(true);
setSplitters(splitters);
}
public Tokenizer(TokenizerConfig config)
{
this(config.splitters());
}
/*
Event Section
*/
private void afterSetProperty()
{
if (splitters == null || ignoreWhitespace == null)
return;
String expression = "";
for (int i = 0, n = splitters.length;;)
{ | expression += escapeRegex(splitters[i]); |
WonderBeat/vasilich | alice-src/bitoflife/chatterbean/aiml/Star.java | // Path: alice-src/bitoflife/chatterbean/Match.java
// public class Match implements Serializable
// {
// /*
// Inner Classes
// */
//
// public enum Section {PATTERN, THAT, TOPIC;}
//
// /*
// Attributes
// */
//
// /** Version class identifier for the serialization engine. Matches the number of the last revision where the class was created / modified. */
// private static final long serialVersionUID = 8L;
//
// private final Map<Section, List<String>> sections = new HashMap<Section, List<String>>();
//
// private AliceBot callback;
//
// private Sentence input;
//
// private Sentence that;
//
// private Sentence topic;
//
// private String[] matchPath;
//
// {
// sections.put(Section.PATTERN, new ArrayList<String>(2)); // Pattern wildcards
// sections.put(Section.THAT, new ArrayList<String>(2)); // That wildcards
// sections.put(Section.TOPIC, new ArrayList<String>(2)); // Topic wildcards
// }
//
// /*
// Constructor
// */
//
// public Match()
// {
// }
//
// public Match(AliceBot callback, Sentence input, Sentence that, Sentence topic)
// {
// this.callback = callback;
// this.input = input;
// this.that = that;
// this.topic = topic;
// setUpMatchPath(input.normalized(), that.normalized(), topic.normalized());
// }
//
// public Match(Sentence input)
// {
// this(null, input, ASTERISK, ASTERISK);
// }
//
// /*
// Methods
// */
//
// private void appendWildcard(List<String> section, Sentence source, int beginIndex, int endIndex)
// {
// if (beginIndex == endIndex)
// section.add(0, "");
// else try
// {
// section.add(0, source.original(beginIndex, endIndex));
// }
// catch (Exception e)
// {
// // throw new RuntimeException("Source: {\"" + source.getOriginal() + "\", \"" + source.getNormalized() + "\"}\n" +
// // "Begin Index: " + beginIndex + "\n" +
// // "End Index: " + endIndex, e);
// }
// }
//
// private void setUpMatchPath(String[] pattern, String[] that, String[] topic)
// {
// int m = pattern.length, n = that.length, o = topic.length;
// matchPath = new String[m + 1 + n + 1 + o];
// matchPath[m] = "<THAT>";
// matchPath[m + 1 + n] = "<TOPIC>";
//
// System.arraycopy(pattern, 0, matchPath, 0, m);
// System.arraycopy(that, 0, matchPath, m + 1, n);
// System.arraycopy(topic, 0, matchPath, m + 1 + n + 1, o);
// }
//
// public void appendWildcard(int beginIndex, int endIndex)
// {
// int inputLength = input.length();
// if (beginIndex <= inputLength)
// {
// appendWildcard(sections.get(Section.PATTERN), input, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (inputLength + 1);
// endIndex = endIndex - (inputLength + 1);
//
// int thatLength = that.length();
// if (beginIndex <= thatLength)
// {
// appendWildcard(sections.get(Section.THAT), that, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (thatLength + 1);
// endIndex = endIndex - (thatLength + 1);
//
// int topicLength = topic.length();
// if (beginIndex < topicLength)
// appendWildcard(sections.get(Section.TOPIC), topic, beginIndex, endIndex);
// }
//
// /**
// Gets the contents for the (index)th wildcard in the matched section.
// */
// public String wildcard(Section section, int index)
// {
// List<String> wildcards = sections.get(section);
// //fixed by lcl
// if(wildcards.size() == 0)
// return "";
// int i = index - 1;
// if(i < wildcards.size() && i > -1)
// return wildcards.get(i);
// else
// return "";
// }
//
// /*
// Properties
// */
//
// public AliceBot getCallback()
// {
// return callback;
// }
//
// public void setCallback(AliceBot callback)
// {
// this.callback = callback;
// }
//
// public String[] getMatchPath()
// {
// return matchPath;
// }
//
// public String getMatchPath(int index)
// {
// return matchPath[index];
// }
//
// public int getMatchPathLength()
// {
// return matchPath.length;
// }
// }
| import org.xml.sax.Attributes;
import bitoflife.chatterbean.Match;
import static bitoflife.chatterbean.Match.Section.PATTERN; | public Star(int index)
{
this.index = index;
}
/*
Methods
*/
public boolean equals(Object obj)
{
if (obj == null || !(obj instanceof Star))
return false;
else
{
Star star = (Star) obj;
return (index == star.index);
}
}
public int hashCode()
{
return index;
}
public String toString()
{
return "<star index=\"" + index + "\"/>";
}
| // Path: alice-src/bitoflife/chatterbean/Match.java
// public class Match implements Serializable
// {
// /*
// Inner Classes
// */
//
// public enum Section {PATTERN, THAT, TOPIC;}
//
// /*
// Attributes
// */
//
// /** Version class identifier for the serialization engine. Matches the number of the last revision where the class was created / modified. */
// private static final long serialVersionUID = 8L;
//
// private final Map<Section, List<String>> sections = new HashMap<Section, List<String>>();
//
// private AliceBot callback;
//
// private Sentence input;
//
// private Sentence that;
//
// private Sentence topic;
//
// private String[] matchPath;
//
// {
// sections.put(Section.PATTERN, new ArrayList<String>(2)); // Pattern wildcards
// sections.put(Section.THAT, new ArrayList<String>(2)); // That wildcards
// sections.put(Section.TOPIC, new ArrayList<String>(2)); // Topic wildcards
// }
//
// /*
// Constructor
// */
//
// public Match()
// {
// }
//
// public Match(AliceBot callback, Sentence input, Sentence that, Sentence topic)
// {
// this.callback = callback;
// this.input = input;
// this.that = that;
// this.topic = topic;
// setUpMatchPath(input.normalized(), that.normalized(), topic.normalized());
// }
//
// public Match(Sentence input)
// {
// this(null, input, ASTERISK, ASTERISK);
// }
//
// /*
// Methods
// */
//
// private void appendWildcard(List<String> section, Sentence source, int beginIndex, int endIndex)
// {
// if (beginIndex == endIndex)
// section.add(0, "");
// else try
// {
// section.add(0, source.original(beginIndex, endIndex));
// }
// catch (Exception e)
// {
// // throw new RuntimeException("Source: {\"" + source.getOriginal() + "\", \"" + source.getNormalized() + "\"}\n" +
// // "Begin Index: " + beginIndex + "\n" +
// // "End Index: " + endIndex, e);
// }
// }
//
// private void setUpMatchPath(String[] pattern, String[] that, String[] topic)
// {
// int m = pattern.length, n = that.length, o = topic.length;
// matchPath = new String[m + 1 + n + 1 + o];
// matchPath[m] = "<THAT>";
// matchPath[m + 1 + n] = "<TOPIC>";
//
// System.arraycopy(pattern, 0, matchPath, 0, m);
// System.arraycopy(that, 0, matchPath, m + 1, n);
// System.arraycopy(topic, 0, matchPath, m + 1 + n + 1, o);
// }
//
// public void appendWildcard(int beginIndex, int endIndex)
// {
// int inputLength = input.length();
// if (beginIndex <= inputLength)
// {
// appendWildcard(sections.get(Section.PATTERN), input, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (inputLength + 1);
// endIndex = endIndex - (inputLength + 1);
//
// int thatLength = that.length();
// if (beginIndex <= thatLength)
// {
// appendWildcard(sections.get(Section.THAT), that, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (thatLength + 1);
// endIndex = endIndex - (thatLength + 1);
//
// int topicLength = topic.length();
// if (beginIndex < topicLength)
// appendWildcard(sections.get(Section.TOPIC), topic, beginIndex, endIndex);
// }
//
// /**
// Gets the contents for the (index)th wildcard in the matched section.
// */
// public String wildcard(Section section, int index)
// {
// List<String> wildcards = sections.get(section);
// //fixed by lcl
// if(wildcards.size() == 0)
// return "";
// int i = index - 1;
// if(i < wildcards.size() && i > -1)
// return wildcards.get(i);
// else
// return "";
// }
//
// /*
// Properties
// */
//
// public AliceBot getCallback()
// {
// return callback;
// }
//
// public void setCallback(AliceBot callback)
// {
// this.callback = callback;
// }
//
// public String[] getMatchPath()
// {
// return matchPath;
// }
//
// public String getMatchPath(int index)
// {
// return matchPath[index];
// }
//
// public int getMatchPathLength()
// {
// return matchPath.length;
// }
// }
// Path: alice-src/bitoflife/chatterbean/aiml/Star.java
import org.xml.sax.Attributes;
import bitoflife.chatterbean.Match;
import static bitoflife.chatterbean.Match.Section.PATTERN;
public Star(int index)
{
this.index = index;
}
/*
Methods
*/
public boolean equals(Object obj)
{
if (obj == null || !(obj instanceof Star))
return false;
else
{
Star star = (Star) obj;
return (index == star.index);
}
}
public int hashCode()
{
return index;
}
public String toString()
{
return "<star index=\"" + index + "\"/>";
}
| public String process(Match match) |
WonderBeat/vasilich | alice-src/bitoflife/chatterbean/aiml/Think.java | // Path: alice-src/bitoflife/chatterbean/Match.java
// public class Match implements Serializable
// {
// /*
// Inner Classes
// */
//
// public enum Section {PATTERN, THAT, TOPIC;}
//
// /*
// Attributes
// */
//
// /** Version class identifier for the serialization engine. Matches the number of the last revision where the class was created / modified. */
// private static final long serialVersionUID = 8L;
//
// private final Map<Section, List<String>> sections = new HashMap<Section, List<String>>();
//
// private AliceBot callback;
//
// private Sentence input;
//
// private Sentence that;
//
// private Sentence topic;
//
// private String[] matchPath;
//
// {
// sections.put(Section.PATTERN, new ArrayList<String>(2)); // Pattern wildcards
// sections.put(Section.THAT, new ArrayList<String>(2)); // That wildcards
// sections.put(Section.TOPIC, new ArrayList<String>(2)); // Topic wildcards
// }
//
// /*
// Constructor
// */
//
// public Match()
// {
// }
//
// public Match(AliceBot callback, Sentence input, Sentence that, Sentence topic)
// {
// this.callback = callback;
// this.input = input;
// this.that = that;
// this.topic = topic;
// setUpMatchPath(input.normalized(), that.normalized(), topic.normalized());
// }
//
// public Match(Sentence input)
// {
// this(null, input, ASTERISK, ASTERISK);
// }
//
// /*
// Methods
// */
//
// private void appendWildcard(List<String> section, Sentence source, int beginIndex, int endIndex)
// {
// if (beginIndex == endIndex)
// section.add(0, "");
// else try
// {
// section.add(0, source.original(beginIndex, endIndex));
// }
// catch (Exception e)
// {
// // throw new RuntimeException("Source: {\"" + source.getOriginal() + "\", \"" + source.getNormalized() + "\"}\n" +
// // "Begin Index: " + beginIndex + "\n" +
// // "End Index: " + endIndex, e);
// }
// }
//
// private void setUpMatchPath(String[] pattern, String[] that, String[] topic)
// {
// int m = pattern.length, n = that.length, o = topic.length;
// matchPath = new String[m + 1 + n + 1 + o];
// matchPath[m] = "<THAT>";
// matchPath[m + 1 + n] = "<TOPIC>";
//
// System.arraycopy(pattern, 0, matchPath, 0, m);
// System.arraycopy(that, 0, matchPath, m + 1, n);
// System.arraycopy(topic, 0, matchPath, m + 1 + n + 1, o);
// }
//
// public void appendWildcard(int beginIndex, int endIndex)
// {
// int inputLength = input.length();
// if (beginIndex <= inputLength)
// {
// appendWildcard(sections.get(Section.PATTERN), input, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (inputLength + 1);
// endIndex = endIndex - (inputLength + 1);
//
// int thatLength = that.length();
// if (beginIndex <= thatLength)
// {
// appendWildcard(sections.get(Section.THAT), that, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (thatLength + 1);
// endIndex = endIndex - (thatLength + 1);
//
// int topicLength = topic.length();
// if (beginIndex < topicLength)
// appendWildcard(sections.get(Section.TOPIC), topic, beginIndex, endIndex);
// }
//
// /**
// Gets the contents for the (index)th wildcard in the matched section.
// */
// public String wildcard(Section section, int index)
// {
// List<String> wildcards = sections.get(section);
// //fixed by lcl
// if(wildcards.size() == 0)
// return "";
// int i = index - 1;
// if(i < wildcards.size() && i > -1)
// return wildcards.get(i);
// else
// return "";
// }
//
// /*
// Properties
// */
//
// public AliceBot getCallback()
// {
// return callback;
// }
//
// public void setCallback(AliceBot callback)
// {
// this.callback = callback;
// }
//
// public String[] getMatchPath()
// {
// return matchPath;
// }
//
// public String getMatchPath(int index)
// {
// return matchPath[index];
// }
//
// public int getMatchPathLength()
// {
// return matchPath.length;
// }
// }
| import org.xml.sax.Attributes;
import bitoflife.chatterbean.Match; | /*
Copyleft (C) 2005 Hio Perroni Filho
xperroni@yahoo.com
ICQ: 2490863
This file is part of ChatterBean.
ChatterBean is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
ChatterBean 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with ChatterBean (look at the Documents/ directory); if not, either write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA, or visit (http://www.gnu.org/licenses/gpl.txt).
*/
package bitoflife.chatterbean.aiml;
public class Think extends TemplateElement
{
/*
Constructors
*/
public Think(Attributes attributes)
{
}
public Think(Object... children)
{
super(children);
}
/*
Methods
*/
| // Path: alice-src/bitoflife/chatterbean/Match.java
// public class Match implements Serializable
// {
// /*
// Inner Classes
// */
//
// public enum Section {PATTERN, THAT, TOPIC;}
//
// /*
// Attributes
// */
//
// /** Version class identifier for the serialization engine. Matches the number of the last revision where the class was created / modified. */
// private static final long serialVersionUID = 8L;
//
// private final Map<Section, List<String>> sections = new HashMap<Section, List<String>>();
//
// private AliceBot callback;
//
// private Sentence input;
//
// private Sentence that;
//
// private Sentence topic;
//
// private String[] matchPath;
//
// {
// sections.put(Section.PATTERN, new ArrayList<String>(2)); // Pattern wildcards
// sections.put(Section.THAT, new ArrayList<String>(2)); // That wildcards
// sections.put(Section.TOPIC, new ArrayList<String>(2)); // Topic wildcards
// }
//
// /*
// Constructor
// */
//
// public Match()
// {
// }
//
// public Match(AliceBot callback, Sentence input, Sentence that, Sentence topic)
// {
// this.callback = callback;
// this.input = input;
// this.that = that;
// this.topic = topic;
// setUpMatchPath(input.normalized(), that.normalized(), topic.normalized());
// }
//
// public Match(Sentence input)
// {
// this(null, input, ASTERISK, ASTERISK);
// }
//
// /*
// Methods
// */
//
// private void appendWildcard(List<String> section, Sentence source, int beginIndex, int endIndex)
// {
// if (beginIndex == endIndex)
// section.add(0, "");
// else try
// {
// section.add(0, source.original(beginIndex, endIndex));
// }
// catch (Exception e)
// {
// // throw new RuntimeException("Source: {\"" + source.getOriginal() + "\", \"" + source.getNormalized() + "\"}\n" +
// // "Begin Index: " + beginIndex + "\n" +
// // "End Index: " + endIndex, e);
// }
// }
//
// private void setUpMatchPath(String[] pattern, String[] that, String[] topic)
// {
// int m = pattern.length, n = that.length, o = topic.length;
// matchPath = new String[m + 1 + n + 1 + o];
// matchPath[m] = "<THAT>";
// matchPath[m + 1 + n] = "<TOPIC>";
//
// System.arraycopy(pattern, 0, matchPath, 0, m);
// System.arraycopy(that, 0, matchPath, m + 1, n);
// System.arraycopy(topic, 0, matchPath, m + 1 + n + 1, o);
// }
//
// public void appendWildcard(int beginIndex, int endIndex)
// {
// int inputLength = input.length();
// if (beginIndex <= inputLength)
// {
// appendWildcard(sections.get(Section.PATTERN), input, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (inputLength + 1);
// endIndex = endIndex - (inputLength + 1);
//
// int thatLength = that.length();
// if (beginIndex <= thatLength)
// {
// appendWildcard(sections.get(Section.THAT), that, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (thatLength + 1);
// endIndex = endIndex - (thatLength + 1);
//
// int topicLength = topic.length();
// if (beginIndex < topicLength)
// appendWildcard(sections.get(Section.TOPIC), topic, beginIndex, endIndex);
// }
//
// /**
// Gets the contents for the (index)th wildcard in the matched section.
// */
// public String wildcard(Section section, int index)
// {
// List<String> wildcards = sections.get(section);
// //fixed by lcl
// if(wildcards.size() == 0)
// return "";
// int i = index - 1;
// if(i < wildcards.size() && i > -1)
// return wildcards.get(i);
// else
// return "";
// }
//
// /*
// Properties
// */
//
// public AliceBot getCallback()
// {
// return callback;
// }
//
// public void setCallback(AliceBot callback)
// {
// this.callback = callback;
// }
//
// public String[] getMatchPath()
// {
// return matchPath;
// }
//
// public String getMatchPath(int index)
// {
// return matchPath[index];
// }
//
// public int getMatchPathLength()
// {
// return matchPath.length;
// }
// }
// Path: alice-src/bitoflife/chatterbean/aiml/Think.java
import org.xml.sax.Attributes;
import bitoflife.chatterbean.Match;
/*
Copyleft (C) 2005 Hio Perroni Filho
xperroni@yahoo.com
ICQ: 2490863
This file is part of ChatterBean.
ChatterBean is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
ChatterBean 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with ChatterBean (look at the Documents/ directory); if not, either write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA, or visit (http://www.gnu.org/licenses/gpl.txt).
*/
package bitoflife.chatterbean.aiml;
public class Think extends TemplateElement
{
/*
Constructors
*/
public Think(Attributes attributes)
{
}
public Think(Object... children)
{
super(children);
}
/*
Methods
*/
| public String process(Match match) |
WonderBeat/vasilich | alice-src/bitoflife/chatterbean/aiml/A.java | // Path: alice-src/bitoflife/chatterbean/Match.java
// public class Match implements Serializable
// {
// /*
// Inner Classes
// */
//
// public enum Section {PATTERN, THAT, TOPIC;}
//
// /*
// Attributes
// */
//
// /** Version class identifier for the serialization engine. Matches the number of the last revision where the class was created / modified. */
// private static final long serialVersionUID = 8L;
//
// private final Map<Section, List<String>> sections = new HashMap<Section, List<String>>();
//
// private AliceBot callback;
//
// private Sentence input;
//
// private Sentence that;
//
// private Sentence topic;
//
// private String[] matchPath;
//
// {
// sections.put(Section.PATTERN, new ArrayList<String>(2)); // Pattern wildcards
// sections.put(Section.THAT, new ArrayList<String>(2)); // That wildcards
// sections.put(Section.TOPIC, new ArrayList<String>(2)); // Topic wildcards
// }
//
// /*
// Constructor
// */
//
// public Match()
// {
// }
//
// public Match(AliceBot callback, Sentence input, Sentence that, Sentence topic)
// {
// this.callback = callback;
// this.input = input;
// this.that = that;
// this.topic = topic;
// setUpMatchPath(input.normalized(), that.normalized(), topic.normalized());
// }
//
// public Match(Sentence input)
// {
// this(null, input, ASTERISK, ASTERISK);
// }
//
// /*
// Methods
// */
//
// private void appendWildcard(List<String> section, Sentence source, int beginIndex, int endIndex)
// {
// if (beginIndex == endIndex)
// section.add(0, "");
// else try
// {
// section.add(0, source.original(beginIndex, endIndex));
// }
// catch (Exception e)
// {
// // throw new RuntimeException("Source: {\"" + source.getOriginal() + "\", \"" + source.getNormalized() + "\"}\n" +
// // "Begin Index: " + beginIndex + "\n" +
// // "End Index: " + endIndex, e);
// }
// }
//
// private void setUpMatchPath(String[] pattern, String[] that, String[] topic)
// {
// int m = pattern.length, n = that.length, o = topic.length;
// matchPath = new String[m + 1 + n + 1 + o];
// matchPath[m] = "<THAT>";
// matchPath[m + 1 + n] = "<TOPIC>";
//
// System.arraycopy(pattern, 0, matchPath, 0, m);
// System.arraycopy(that, 0, matchPath, m + 1, n);
// System.arraycopy(topic, 0, matchPath, m + 1 + n + 1, o);
// }
//
// public void appendWildcard(int beginIndex, int endIndex)
// {
// int inputLength = input.length();
// if (beginIndex <= inputLength)
// {
// appendWildcard(sections.get(Section.PATTERN), input, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (inputLength + 1);
// endIndex = endIndex - (inputLength + 1);
//
// int thatLength = that.length();
// if (beginIndex <= thatLength)
// {
// appendWildcard(sections.get(Section.THAT), that, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (thatLength + 1);
// endIndex = endIndex - (thatLength + 1);
//
// int topicLength = topic.length();
// if (beginIndex < topicLength)
// appendWildcard(sections.get(Section.TOPIC), topic, beginIndex, endIndex);
// }
//
// /**
// Gets the contents for the (index)th wildcard in the matched section.
// */
// public String wildcard(Section section, int index)
// {
// List<String> wildcards = sections.get(section);
// //fixed by lcl
// if(wildcards.size() == 0)
// return "";
// int i = index - 1;
// if(i < wildcards.size() && i > -1)
// return wildcards.get(i);
// else
// return "";
// }
//
// /*
// Properties
// */
//
// public AliceBot getCallback()
// {
// return callback;
// }
//
// public void setCallback(AliceBot callback)
// {
// this.callback = callback;
// }
//
// public String[] getMatchPath()
// {
// return matchPath;
// }
//
// public String getMatchPath(int index)
// {
// return matchPath[index];
// }
//
// public int getMatchPathLength()
// {
// return matchPath.length;
// }
// }
| import org.xml.sax.Attributes;
import bitoflife.chatterbean.Match; | package bitoflife.chatterbean.aiml;
public class A extends TemplateElement
{
/*
Constructors
*/
public A(Attributes attributes)
{
}
public A(Object... children)
{
super(children);
}
/*
Methods
*/
| // Path: alice-src/bitoflife/chatterbean/Match.java
// public class Match implements Serializable
// {
// /*
// Inner Classes
// */
//
// public enum Section {PATTERN, THAT, TOPIC;}
//
// /*
// Attributes
// */
//
// /** Version class identifier for the serialization engine. Matches the number of the last revision where the class was created / modified. */
// private static final long serialVersionUID = 8L;
//
// private final Map<Section, List<String>> sections = new HashMap<Section, List<String>>();
//
// private AliceBot callback;
//
// private Sentence input;
//
// private Sentence that;
//
// private Sentence topic;
//
// private String[] matchPath;
//
// {
// sections.put(Section.PATTERN, new ArrayList<String>(2)); // Pattern wildcards
// sections.put(Section.THAT, new ArrayList<String>(2)); // That wildcards
// sections.put(Section.TOPIC, new ArrayList<String>(2)); // Topic wildcards
// }
//
// /*
// Constructor
// */
//
// public Match()
// {
// }
//
// public Match(AliceBot callback, Sentence input, Sentence that, Sentence topic)
// {
// this.callback = callback;
// this.input = input;
// this.that = that;
// this.topic = topic;
// setUpMatchPath(input.normalized(), that.normalized(), topic.normalized());
// }
//
// public Match(Sentence input)
// {
// this(null, input, ASTERISK, ASTERISK);
// }
//
// /*
// Methods
// */
//
// private void appendWildcard(List<String> section, Sentence source, int beginIndex, int endIndex)
// {
// if (beginIndex == endIndex)
// section.add(0, "");
// else try
// {
// section.add(0, source.original(beginIndex, endIndex));
// }
// catch (Exception e)
// {
// // throw new RuntimeException("Source: {\"" + source.getOriginal() + "\", \"" + source.getNormalized() + "\"}\n" +
// // "Begin Index: " + beginIndex + "\n" +
// // "End Index: " + endIndex, e);
// }
// }
//
// private void setUpMatchPath(String[] pattern, String[] that, String[] topic)
// {
// int m = pattern.length, n = that.length, o = topic.length;
// matchPath = new String[m + 1 + n + 1 + o];
// matchPath[m] = "<THAT>";
// matchPath[m + 1 + n] = "<TOPIC>";
//
// System.arraycopy(pattern, 0, matchPath, 0, m);
// System.arraycopy(that, 0, matchPath, m + 1, n);
// System.arraycopy(topic, 0, matchPath, m + 1 + n + 1, o);
// }
//
// public void appendWildcard(int beginIndex, int endIndex)
// {
// int inputLength = input.length();
// if (beginIndex <= inputLength)
// {
// appendWildcard(sections.get(Section.PATTERN), input, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (inputLength + 1);
// endIndex = endIndex - (inputLength + 1);
//
// int thatLength = that.length();
// if (beginIndex <= thatLength)
// {
// appendWildcard(sections.get(Section.THAT), that, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (thatLength + 1);
// endIndex = endIndex - (thatLength + 1);
//
// int topicLength = topic.length();
// if (beginIndex < topicLength)
// appendWildcard(sections.get(Section.TOPIC), topic, beginIndex, endIndex);
// }
//
// /**
// Gets the contents for the (index)th wildcard in the matched section.
// */
// public String wildcard(Section section, int index)
// {
// List<String> wildcards = sections.get(section);
// //fixed by lcl
// if(wildcards.size() == 0)
// return "";
// int i = index - 1;
// if(i < wildcards.size() && i > -1)
// return wildcards.get(i);
// else
// return "";
// }
//
// /*
// Properties
// */
//
// public AliceBot getCallback()
// {
// return callback;
// }
//
// public void setCallback(AliceBot callback)
// {
// this.callback = callback;
// }
//
// public String[] getMatchPath()
// {
// return matchPath;
// }
//
// public String getMatchPath(int index)
// {
// return matchPath[index];
// }
//
// public int getMatchPathLength()
// {
// return matchPath.length;
// }
// }
// Path: alice-src/bitoflife/chatterbean/aiml/A.java
import org.xml.sax.Attributes;
import bitoflife.chatterbean.Match;
package bitoflife.chatterbean.aiml;
public class A extends TemplateElement
{
/*
Constructors
*/
public A(Attributes attributes)
{
}
public A(Object... children)
{
super(children);
}
/*
Methods
*/
| public String process(Match match) |
WonderBeat/vasilich | alice-src/bitoflife/chatterbean/aiml/TemplateElement.java | // Path: alice-src/bitoflife/chatterbean/Match.java
// public class Match implements Serializable
// {
// /*
// Inner Classes
// */
//
// public enum Section {PATTERN, THAT, TOPIC;}
//
// /*
// Attributes
// */
//
// /** Version class identifier for the serialization engine. Matches the number of the last revision where the class was created / modified. */
// private static final long serialVersionUID = 8L;
//
// private final Map<Section, List<String>> sections = new HashMap<Section, List<String>>();
//
// private AliceBot callback;
//
// private Sentence input;
//
// private Sentence that;
//
// private Sentence topic;
//
// private String[] matchPath;
//
// {
// sections.put(Section.PATTERN, new ArrayList<String>(2)); // Pattern wildcards
// sections.put(Section.THAT, new ArrayList<String>(2)); // That wildcards
// sections.put(Section.TOPIC, new ArrayList<String>(2)); // Topic wildcards
// }
//
// /*
// Constructor
// */
//
// public Match()
// {
// }
//
// public Match(AliceBot callback, Sentence input, Sentence that, Sentence topic)
// {
// this.callback = callback;
// this.input = input;
// this.that = that;
// this.topic = topic;
// setUpMatchPath(input.normalized(), that.normalized(), topic.normalized());
// }
//
// public Match(Sentence input)
// {
// this(null, input, ASTERISK, ASTERISK);
// }
//
// /*
// Methods
// */
//
// private void appendWildcard(List<String> section, Sentence source, int beginIndex, int endIndex)
// {
// if (beginIndex == endIndex)
// section.add(0, "");
// else try
// {
// section.add(0, source.original(beginIndex, endIndex));
// }
// catch (Exception e)
// {
// // throw new RuntimeException("Source: {\"" + source.getOriginal() + "\", \"" + source.getNormalized() + "\"}\n" +
// // "Begin Index: " + beginIndex + "\n" +
// // "End Index: " + endIndex, e);
// }
// }
//
// private void setUpMatchPath(String[] pattern, String[] that, String[] topic)
// {
// int m = pattern.length, n = that.length, o = topic.length;
// matchPath = new String[m + 1 + n + 1 + o];
// matchPath[m] = "<THAT>";
// matchPath[m + 1 + n] = "<TOPIC>";
//
// System.arraycopy(pattern, 0, matchPath, 0, m);
// System.arraycopy(that, 0, matchPath, m + 1, n);
// System.arraycopy(topic, 0, matchPath, m + 1 + n + 1, o);
// }
//
// public void appendWildcard(int beginIndex, int endIndex)
// {
// int inputLength = input.length();
// if (beginIndex <= inputLength)
// {
// appendWildcard(sections.get(Section.PATTERN), input, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (inputLength + 1);
// endIndex = endIndex - (inputLength + 1);
//
// int thatLength = that.length();
// if (beginIndex <= thatLength)
// {
// appendWildcard(sections.get(Section.THAT), that, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (thatLength + 1);
// endIndex = endIndex - (thatLength + 1);
//
// int topicLength = topic.length();
// if (beginIndex < topicLength)
// appendWildcard(sections.get(Section.TOPIC), topic, beginIndex, endIndex);
// }
//
// /**
// Gets the contents for the (index)th wildcard in the matched section.
// */
// public String wildcard(Section section, int index)
// {
// List<String> wildcards = sections.get(section);
// //fixed by lcl
// if(wildcards.size() == 0)
// return "";
// int i = index - 1;
// if(i < wildcards.size() && i > -1)
// return wildcards.get(i);
// else
// return "";
// }
//
// /*
// Properties
// */
//
// public AliceBot getCallback()
// {
// return callback;
// }
//
// public void setCallback(AliceBot callback)
// {
// this.callback = callback;
// }
//
// public String[] getMatchPath()
// {
// return matchPath;
// }
//
// public String getMatchPath(int index)
// {
// return matchPath[index];
// }
//
// public int getMatchPathLength()
// {
// return matchPath.length;
// }
// }
| import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import bitoflife.chatterbean.Match; | public void appendChild(AIMLElement element)
{
children.add((TemplateElement) element);
}
public void appendChildren(List<AIMLElement> elements)
{
for (AIMLElement element : elements)
children.add((TemplateElement) element);
}
public List<TemplateElement> children()
{
return children;
}
public boolean equals(Object object)
{
if (object == null || !(object instanceof TemplateElement))
return false;
TemplateElement that = (TemplateElement) object;
return children.equals(that.children);
}
public int hashCode()
{
return children.hashCode();
}
| // Path: alice-src/bitoflife/chatterbean/Match.java
// public class Match implements Serializable
// {
// /*
// Inner Classes
// */
//
// public enum Section {PATTERN, THAT, TOPIC;}
//
// /*
// Attributes
// */
//
// /** Version class identifier for the serialization engine. Matches the number of the last revision where the class was created / modified. */
// private static final long serialVersionUID = 8L;
//
// private final Map<Section, List<String>> sections = new HashMap<Section, List<String>>();
//
// private AliceBot callback;
//
// private Sentence input;
//
// private Sentence that;
//
// private Sentence topic;
//
// private String[] matchPath;
//
// {
// sections.put(Section.PATTERN, new ArrayList<String>(2)); // Pattern wildcards
// sections.put(Section.THAT, new ArrayList<String>(2)); // That wildcards
// sections.put(Section.TOPIC, new ArrayList<String>(2)); // Topic wildcards
// }
//
// /*
// Constructor
// */
//
// public Match()
// {
// }
//
// public Match(AliceBot callback, Sentence input, Sentence that, Sentence topic)
// {
// this.callback = callback;
// this.input = input;
// this.that = that;
// this.topic = topic;
// setUpMatchPath(input.normalized(), that.normalized(), topic.normalized());
// }
//
// public Match(Sentence input)
// {
// this(null, input, ASTERISK, ASTERISK);
// }
//
// /*
// Methods
// */
//
// private void appendWildcard(List<String> section, Sentence source, int beginIndex, int endIndex)
// {
// if (beginIndex == endIndex)
// section.add(0, "");
// else try
// {
// section.add(0, source.original(beginIndex, endIndex));
// }
// catch (Exception e)
// {
// // throw new RuntimeException("Source: {\"" + source.getOriginal() + "\", \"" + source.getNormalized() + "\"}\n" +
// // "Begin Index: " + beginIndex + "\n" +
// // "End Index: " + endIndex, e);
// }
// }
//
// private void setUpMatchPath(String[] pattern, String[] that, String[] topic)
// {
// int m = pattern.length, n = that.length, o = topic.length;
// matchPath = new String[m + 1 + n + 1 + o];
// matchPath[m] = "<THAT>";
// matchPath[m + 1 + n] = "<TOPIC>";
//
// System.arraycopy(pattern, 0, matchPath, 0, m);
// System.arraycopy(that, 0, matchPath, m + 1, n);
// System.arraycopy(topic, 0, matchPath, m + 1 + n + 1, o);
// }
//
// public void appendWildcard(int beginIndex, int endIndex)
// {
// int inputLength = input.length();
// if (beginIndex <= inputLength)
// {
// appendWildcard(sections.get(Section.PATTERN), input, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (inputLength + 1);
// endIndex = endIndex - (inputLength + 1);
//
// int thatLength = that.length();
// if (beginIndex <= thatLength)
// {
// appendWildcard(sections.get(Section.THAT), that, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (thatLength + 1);
// endIndex = endIndex - (thatLength + 1);
//
// int topicLength = topic.length();
// if (beginIndex < topicLength)
// appendWildcard(sections.get(Section.TOPIC), topic, beginIndex, endIndex);
// }
//
// /**
// Gets the contents for the (index)th wildcard in the matched section.
// */
// public String wildcard(Section section, int index)
// {
// List<String> wildcards = sections.get(section);
// //fixed by lcl
// if(wildcards.size() == 0)
// return "";
// int i = index - 1;
// if(i < wildcards.size() && i > -1)
// return wildcards.get(i);
// else
// return "";
// }
//
// /*
// Properties
// */
//
// public AliceBot getCallback()
// {
// return callback;
// }
//
// public void setCallback(AliceBot callback)
// {
// this.callback = callback;
// }
//
// public String[] getMatchPath()
// {
// return matchPath;
// }
//
// public String getMatchPath(int index)
// {
// return matchPath[index];
// }
//
// public int getMatchPathLength()
// {
// return matchPath.length;
// }
// }
// Path: alice-src/bitoflife/chatterbean/aiml/TemplateElement.java
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import bitoflife.chatterbean.Match;
public void appendChild(AIMLElement element)
{
children.add((TemplateElement) element);
}
public void appendChildren(List<AIMLElement> elements)
{
for (AIMLElement element : elements)
children.add((TemplateElement) element);
}
public List<TemplateElement> children()
{
return children;
}
public boolean equals(Object object)
{
if (object == null || !(object instanceof TemplateElement))
return false;
TemplateElement that = (TemplateElement) object;
return children.equals(that.children);
}
public int hashCode()
{
return children.hashCode();
}
| public String process(Match match) |
WonderBeat/vasilich | alice-src/bitoflife/chatterbean/aiml/Em.java | // Path: alice-src/bitoflife/chatterbean/Match.java
// public class Match implements Serializable
// {
// /*
// Inner Classes
// */
//
// public enum Section {PATTERN, THAT, TOPIC;}
//
// /*
// Attributes
// */
//
// /** Version class identifier for the serialization engine. Matches the number of the last revision where the class was created / modified. */
// private static final long serialVersionUID = 8L;
//
// private final Map<Section, List<String>> sections = new HashMap<Section, List<String>>();
//
// private AliceBot callback;
//
// private Sentence input;
//
// private Sentence that;
//
// private Sentence topic;
//
// private String[] matchPath;
//
// {
// sections.put(Section.PATTERN, new ArrayList<String>(2)); // Pattern wildcards
// sections.put(Section.THAT, new ArrayList<String>(2)); // That wildcards
// sections.put(Section.TOPIC, new ArrayList<String>(2)); // Topic wildcards
// }
//
// /*
// Constructor
// */
//
// public Match()
// {
// }
//
// public Match(AliceBot callback, Sentence input, Sentence that, Sentence topic)
// {
// this.callback = callback;
// this.input = input;
// this.that = that;
// this.topic = topic;
// setUpMatchPath(input.normalized(), that.normalized(), topic.normalized());
// }
//
// public Match(Sentence input)
// {
// this(null, input, ASTERISK, ASTERISK);
// }
//
// /*
// Methods
// */
//
// private void appendWildcard(List<String> section, Sentence source, int beginIndex, int endIndex)
// {
// if (beginIndex == endIndex)
// section.add(0, "");
// else try
// {
// section.add(0, source.original(beginIndex, endIndex));
// }
// catch (Exception e)
// {
// // throw new RuntimeException("Source: {\"" + source.getOriginal() + "\", \"" + source.getNormalized() + "\"}\n" +
// // "Begin Index: " + beginIndex + "\n" +
// // "End Index: " + endIndex, e);
// }
// }
//
// private void setUpMatchPath(String[] pattern, String[] that, String[] topic)
// {
// int m = pattern.length, n = that.length, o = topic.length;
// matchPath = new String[m + 1 + n + 1 + o];
// matchPath[m] = "<THAT>";
// matchPath[m + 1 + n] = "<TOPIC>";
//
// System.arraycopy(pattern, 0, matchPath, 0, m);
// System.arraycopy(that, 0, matchPath, m + 1, n);
// System.arraycopy(topic, 0, matchPath, m + 1 + n + 1, o);
// }
//
// public void appendWildcard(int beginIndex, int endIndex)
// {
// int inputLength = input.length();
// if (beginIndex <= inputLength)
// {
// appendWildcard(sections.get(Section.PATTERN), input, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (inputLength + 1);
// endIndex = endIndex - (inputLength + 1);
//
// int thatLength = that.length();
// if (beginIndex <= thatLength)
// {
// appendWildcard(sections.get(Section.THAT), that, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (thatLength + 1);
// endIndex = endIndex - (thatLength + 1);
//
// int topicLength = topic.length();
// if (beginIndex < topicLength)
// appendWildcard(sections.get(Section.TOPIC), topic, beginIndex, endIndex);
// }
//
// /**
// Gets the contents for the (index)th wildcard in the matched section.
// */
// public String wildcard(Section section, int index)
// {
// List<String> wildcards = sections.get(section);
// //fixed by lcl
// if(wildcards.size() == 0)
// return "";
// int i = index - 1;
// if(i < wildcards.size() && i > -1)
// return wildcards.get(i);
// else
// return "";
// }
//
// /*
// Properties
// */
//
// public AliceBot getCallback()
// {
// return callback;
// }
//
// public void setCallback(AliceBot callback)
// {
// this.callback = callback;
// }
//
// public String[] getMatchPath()
// {
// return matchPath;
// }
//
// public String getMatchPath(int index)
// {
// return matchPath[index];
// }
//
// public int getMatchPathLength()
// {
// return matchPath.length;
// }
// }
| import org.xml.sax.Attributes;
import bitoflife.chatterbean.Match; | package bitoflife.chatterbean.aiml;
public class Em extends TemplateElement
{
/*
Constructors
*/
public Em(Attributes attributes)
{
}
public Em(Object... children)
{
super(children);
}
/*
Methods
*/
| // Path: alice-src/bitoflife/chatterbean/Match.java
// public class Match implements Serializable
// {
// /*
// Inner Classes
// */
//
// public enum Section {PATTERN, THAT, TOPIC;}
//
// /*
// Attributes
// */
//
// /** Version class identifier for the serialization engine. Matches the number of the last revision where the class was created / modified. */
// private static final long serialVersionUID = 8L;
//
// private final Map<Section, List<String>> sections = new HashMap<Section, List<String>>();
//
// private AliceBot callback;
//
// private Sentence input;
//
// private Sentence that;
//
// private Sentence topic;
//
// private String[] matchPath;
//
// {
// sections.put(Section.PATTERN, new ArrayList<String>(2)); // Pattern wildcards
// sections.put(Section.THAT, new ArrayList<String>(2)); // That wildcards
// sections.put(Section.TOPIC, new ArrayList<String>(2)); // Topic wildcards
// }
//
// /*
// Constructor
// */
//
// public Match()
// {
// }
//
// public Match(AliceBot callback, Sentence input, Sentence that, Sentence topic)
// {
// this.callback = callback;
// this.input = input;
// this.that = that;
// this.topic = topic;
// setUpMatchPath(input.normalized(), that.normalized(), topic.normalized());
// }
//
// public Match(Sentence input)
// {
// this(null, input, ASTERISK, ASTERISK);
// }
//
// /*
// Methods
// */
//
// private void appendWildcard(List<String> section, Sentence source, int beginIndex, int endIndex)
// {
// if (beginIndex == endIndex)
// section.add(0, "");
// else try
// {
// section.add(0, source.original(beginIndex, endIndex));
// }
// catch (Exception e)
// {
// // throw new RuntimeException("Source: {\"" + source.getOriginal() + "\", \"" + source.getNormalized() + "\"}\n" +
// // "Begin Index: " + beginIndex + "\n" +
// // "End Index: " + endIndex, e);
// }
// }
//
// private void setUpMatchPath(String[] pattern, String[] that, String[] topic)
// {
// int m = pattern.length, n = that.length, o = topic.length;
// matchPath = new String[m + 1 + n + 1 + o];
// matchPath[m] = "<THAT>";
// matchPath[m + 1 + n] = "<TOPIC>";
//
// System.arraycopy(pattern, 0, matchPath, 0, m);
// System.arraycopy(that, 0, matchPath, m + 1, n);
// System.arraycopy(topic, 0, matchPath, m + 1 + n + 1, o);
// }
//
// public void appendWildcard(int beginIndex, int endIndex)
// {
// int inputLength = input.length();
// if (beginIndex <= inputLength)
// {
// appendWildcard(sections.get(Section.PATTERN), input, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (inputLength + 1);
// endIndex = endIndex - (inputLength + 1);
//
// int thatLength = that.length();
// if (beginIndex <= thatLength)
// {
// appendWildcard(sections.get(Section.THAT), that, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (thatLength + 1);
// endIndex = endIndex - (thatLength + 1);
//
// int topicLength = topic.length();
// if (beginIndex < topicLength)
// appendWildcard(sections.get(Section.TOPIC), topic, beginIndex, endIndex);
// }
//
// /**
// Gets the contents for the (index)th wildcard in the matched section.
// */
// public String wildcard(Section section, int index)
// {
// List<String> wildcards = sections.get(section);
// //fixed by lcl
// if(wildcards.size() == 0)
// return "";
// int i = index - 1;
// if(i < wildcards.size() && i > -1)
// return wildcards.get(i);
// else
// return "";
// }
//
// /*
// Properties
// */
//
// public AliceBot getCallback()
// {
// return callback;
// }
//
// public void setCallback(AliceBot callback)
// {
// this.callback = callback;
// }
//
// public String[] getMatchPath()
// {
// return matchPath;
// }
//
// public String getMatchPath(int index)
// {
// return matchPath[index];
// }
//
// public int getMatchPathLength()
// {
// return matchPath.length;
// }
// }
// Path: alice-src/bitoflife/chatterbean/aiml/Em.java
import org.xml.sax.Attributes;
import bitoflife.chatterbean.Match;
package bitoflife.chatterbean.aiml;
public class Em extends TemplateElement
{
/*
Constructors
*/
public Em(Attributes attributes)
{
}
public Em(Object... children)
{
super(children);
}
/*
Methods
*/
| public String process(Match match) |
WonderBeat/vasilich | alice-src/bitoflife/chatterbean/aiml/Uppercase.java | // Path: alice-src/bitoflife/chatterbean/Match.java
// public class Match implements Serializable
// {
// /*
// Inner Classes
// */
//
// public enum Section {PATTERN, THAT, TOPIC;}
//
// /*
// Attributes
// */
//
// /** Version class identifier for the serialization engine. Matches the number of the last revision where the class was created / modified. */
// private static final long serialVersionUID = 8L;
//
// private final Map<Section, List<String>> sections = new HashMap<Section, List<String>>();
//
// private AliceBot callback;
//
// private Sentence input;
//
// private Sentence that;
//
// private Sentence topic;
//
// private String[] matchPath;
//
// {
// sections.put(Section.PATTERN, new ArrayList<String>(2)); // Pattern wildcards
// sections.put(Section.THAT, new ArrayList<String>(2)); // That wildcards
// sections.put(Section.TOPIC, new ArrayList<String>(2)); // Topic wildcards
// }
//
// /*
// Constructor
// */
//
// public Match()
// {
// }
//
// public Match(AliceBot callback, Sentence input, Sentence that, Sentence topic)
// {
// this.callback = callback;
// this.input = input;
// this.that = that;
// this.topic = topic;
// setUpMatchPath(input.normalized(), that.normalized(), topic.normalized());
// }
//
// public Match(Sentence input)
// {
// this(null, input, ASTERISK, ASTERISK);
// }
//
// /*
// Methods
// */
//
// private void appendWildcard(List<String> section, Sentence source, int beginIndex, int endIndex)
// {
// if (beginIndex == endIndex)
// section.add(0, "");
// else try
// {
// section.add(0, source.original(beginIndex, endIndex));
// }
// catch (Exception e)
// {
// // throw new RuntimeException("Source: {\"" + source.getOriginal() + "\", \"" + source.getNormalized() + "\"}\n" +
// // "Begin Index: " + beginIndex + "\n" +
// // "End Index: " + endIndex, e);
// }
// }
//
// private void setUpMatchPath(String[] pattern, String[] that, String[] topic)
// {
// int m = pattern.length, n = that.length, o = topic.length;
// matchPath = new String[m + 1 + n + 1 + o];
// matchPath[m] = "<THAT>";
// matchPath[m + 1 + n] = "<TOPIC>";
//
// System.arraycopy(pattern, 0, matchPath, 0, m);
// System.arraycopy(that, 0, matchPath, m + 1, n);
// System.arraycopy(topic, 0, matchPath, m + 1 + n + 1, o);
// }
//
// public void appendWildcard(int beginIndex, int endIndex)
// {
// int inputLength = input.length();
// if (beginIndex <= inputLength)
// {
// appendWildcard(sections.get(Section.PATTERN), input, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (inputLength + 1);
// endIndex = endIndex - (inputLength + 1);
//
// int thatLength = that.length();
// if (beginIndex <= thatLength)
// {
// appendWildcard(sections.get(Section.THAT), that, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (thatLength + 1);
// endIndex = endIndex - (thatLength + 1);
//
// int topicLength = topic.length();
// if (beginIndex < topicLength)
// appendWildcard(sections.get(Section.TOPIC), topic, beginIndex, endIndex);
// }
//
// /**
// Gets the contents for the (index)th wildcard in the matched section.
// */
// public String wildcard(Section section, int index)
// {
// List<String> wildcards = sections.get(section);
// //fixed by lcl
// if(wildcards.size() == 0)
// return "";
// int i = index - 1;
// if(i < wildcards.size() && i > -1)
// return wildcards.get(i);
// else
// return "";
// }
//
// /*
// Properties
// */
//
// public AliceBot getCallback()
// {
// return callback;
// }
//
// public void setCallback(AliceBot callback)
// {
// this.callback = callback;
// }
//
// public String[] getMatchPath()
// {
// return matchPath;
// }
//
// public String getMatchPath(int index)
// {
// return matchPath[index];
// }
//
// public int getMatchPathLength()
// {
// return matchPath.length;
// }
// }
| import org.xml.sax.Attributes;
import bitoflife.chatterbean.Match; | /*
Copyleft (C) 2005 Hio Perroni Filho
xperroni@yahoo.com
ICQ: 2490863
This file is part of ChatterBean.
ChatterBean is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
ChatterBean 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with ChatterBean (look at the Documents/ directory); if not, either write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA, or visit (http://www.gnu.org/licenses/gpl.txt).
*/
package bitoflife.chatterbean.aiml;
public class Uppercase extends TemplateElement
{
/*
Constructors
*/
public Uppercase(Attributes attributes)
{
}
public Uppercase(Object... children)
{
super(children);
}
/*
Methods
*/
| // Path: alice-src/bitoflife/chatterbean/Match.java
// public class Match implements Serializable
// {
// /*
// Inner Classes
// */
//
// public enum Section {PATTERN, THAT, TOPIC;}
//
// /*
// Attributes
// */
//
// /** Version class identifier for the serialization engine. Matches the number of the last revision where the class was created / modified. */
// private static final long serialVersionUID = 8L;
//
// private final Map<Section, List<String>> sections = new HashMap<Section, List<String>>();
//
// private AliceBot callback;
//
// private Sentence input;
//
// private Sentence that;
//
// private Sentence topic;
//
// private String[] matchPath;
//
// {
// sections.put(Section.PATTERN, new ArrayList<String>(2)); // Pattern wildcards
// sections.put(Section.THAT, new ArrayList<String>(2)); // That wildcards
// sections.put(Section.TOPIC, new ArrayList<String>(2)); // Topic wildcards
// }
//
// /*
// Constructor
// */
//
// public Match()
// {
// }
//
// public Match(AliceBot callback, Sentence input, Sentence that, Sentence topic)
// {
// this.callback = callback;
// this.input = input;
// this.that = that;
// this.topic = topic;
// setUpMatchPath(input.normalized(), that.normalized(), topic.normalized());
// }
//
// public Match(Sentence input)
// {
// this(null, input, ASTERISK, ASTERISK);
// }
//
// /*
// Methods
// */
//
// private void appendWildcard(List<String> section, Sentence source, int beginIndex, int endIndex)
// {
// if (beginIndex == endIndex)
// section.add(0, "");
// else try
// {
// section.add(0, source.original(beginIndex, endIndex));
// }
// catch (Exception e)
// {
// // throw new RuntimeException("Source: {\"" + source.getOriginal() + "\", \"" + source.getNormalized() + "\"}\n" +
// // "Begin Index: " + beginIndex + "\n" +
// // "End Index: " + endIndex, e);
// }
// }
//
// private void setUpMatchPath(String[] pattern, String[] that, String[] topic)
// {
// int m = pattern.length, n = that.length, o = topic.length;
// matchPath = new String[m + 1 + n + 1 + o];
// matchPath[m] = "<THAT>";
// matchPath[m + 1 + n] = "<TOPIC>";
//
// System.arraycopy(pattern, 0, matchPath, 0, m);
// System.arraycopy(that, 0, matchPath, m + 1, n);
// System.arraycopy(topic, 0, matchPath, m + 1 + n + 1, o);
// }
//
// public void appendWildcard(int beginIndex, int endIndex)
// {
// int inputLength = input.length();
// if (beginIndex <= inputLength)
// {
// appendWildcard(sections.get(Section.PATTERN), input, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (inputLength + 1);
// endIndex = endIndex - (inputLength + 1);
//
// int thatLength = that.length();
// if (beginIndex <= thatLength)
// {
// appendWildcard(sections.get(Section.THAT), that, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (thatLength + 1);
// endIndex = endIndex - (thatLength + 1);
//
// int topicLength = topic.length();
// if (beginIndex < topicLength)
// appendWildcard(sections.get(Section.TOPIC), topic, beginIndex, endIndex);
// }
//
// /**
// Gets the contents for the (index)th wildcard in the matched section.
// */
// public String wildcard(Section section, int index)
// {
// List<String> wildcards = sections.get(section);
// //fixed by lcl
// if(wildcards.size() == 0)
// return "";
// int i = index - 1;
// if(i < wildcards.size() && i > -1)
// return wildcards.get(i);
// else
// return "";
// }
//
// /*
// Properties
// */
//
// public AliceBot getCallback()
// {
// return callback;
// }
//
// public void setCallback(AliceBot callback)
// {
// this.callback = callback;
// }
//
// public String[] getMatchPath()
// {
// return matchPath;
// }
//
// public String getMatchPath(int index)
// {
// return matchPath[index];
// }
//
// public int getMatchPathLength()
// {
// return matchPath.length;
// }
// }
// Path: alice-src/bitoflife/chatterbean/aiml/Uppercase.java
import org.xml.sax.Attributes;
import bitoflife.chatterbean.Match;
/*
Copyleft (C) 2005 Hio Perroni Filho
xperroni@yahoo.com
ICQ: 2490863
This file is part of ChatterBean.
ChatterBean is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
ChatterBean 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with ChatterBean (look at the Documents/ directory); if not, either write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA, or visit (http://www.gnu.org/licenses/gpl.txt).
*/
package bitoflife.chatterbean.aiml;
public class Uppercase extends TemplateElement
{
/*
Constructors
*/
public Uppercase(Attributes attributes)
{
}
public Uppercase(Object... children)
{
super(children);
}
/*
Methods
*/
| public String process(Match match) |
WonderBeat/vasilich | alice-src/bitoflife/chatterbean/aiml/Date.java | // Path: alice-src/bitoflife/chatterbean/Match.java
// public class Match implements Serializable
// {
// /*
// Inner Classes
// */
//
// public enum Section {PATTERN, THAT, TOPIC;}
//
// /*
// Attributes
// */
//
// /** Version class identifier for the serialization engine. Matches the number of the last revision where the class was created / modified. */
// private static final long serialVersionUID = 8L;
//
// private final Map<Section, List<String>> sections = new HashMap<Section, List<String>>();
//
// private AliceBot callback;
//
// private Sentence input;
//
// private Sentence that;
//
// private Sentence topic;
//
// private String[] matchPath;
//
// {
// sections.put(Section.PATTERN, new ArrayList<String>(2)); // Pattern wildcards
// sections.put(Section.THAT, new ArrayList<String>(2)); // That wildcards
// sections.put(Section.TOPIC, new ArrayList<String>(2)); // Topic wildcards
// }
//
// /*
// Constructor
// */
//
// public Match()
// {
// }
//
// public Match(AliceBot callback, Sentence input, Sentence that, Sentence topic)
// {
// this.callback = callback;
// this.input = input;
// this.that = that;
// this.topic = topic;
// setUpMatchPath(input.normalized(), that.normalized(), topic.normalized());
// }
//
// public Match(Sentence input)
// {
// this(null, input, ASTERISK, ASTERISK);
// }
//
// /*
// Methods
// */
//
// private void appendWildcard(List<String> section, Sentence source, int beginIndex, int endIndex)
// {
// if (beginIndex == endIndex)
// section.add(0, "");
// else try
// {
// section.add(0, source.original(beginIndex, endIndex));
// }
// catch (Exception e)
// {
// // throw new RuntimeException("Source: {\"" + source.getOriginal() + "\", \"" + source.getNormalized() + "\"}\n" +
// // "Begin Index: " + beginIndex + "\n" +
// // "End Index: " + endIndex, e);
// }
// }
//
// private void setUpMatchPath(String[] pattern, String[] that, String[] topic)
// {
// int m = pattern.length, n = that.length, o = topic.length;
// matchPath = new String[m + 1 + n + 1 + o];
// matchPath[m] = "<THAT>";
// matchPath[m + 1 + n] = "<TOPIC>";
//
// System.arraycopy(pattern, 0, matchPath, 0, m);
// System.arraycopy(that, 0, matchPath, m + 1, n);
// System.arraycopy(topic, 0, matchPath, m + 1 + n + 1, o);
// }
//
// public void appendWildcard(int beginIndex, int endIndex)
// {
// int inputLength = input.length();
// if (beginIndex <= inputLength)
// {
// appendWildcard(sections.get(Section.PATTERN), input, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (inputLength + 1);
// endIndex = endIndex - (inputLength + 1);
//
// int thatLength = that.length();
// if (beginIndex <= thatLength)
// {
// appendWildcard(sections.get(Section.THAT), that, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (thatLength + 1);
// endIndex = endIndex - (thatLength + 1);
//
// int topicLength = topic.length();
// if (beginIndex < topicLength)
// appendWildcard(sections.get(Section.TOPIC), topic, beginIndex, endIndex);
// }
//
// /**
// Gets the contents for the (index)th wildcard in the matched section.
// */
// public String wildcard(Section section, int index)
// {
// List<String> wildcards = sections.get(section);
// //fixed by lcl
// if(wildcards.size() == 0)
// return "";
// int i = index - 1;
// if(i < wildcards.size() && i > -1)
// return wildcards.get(i);
// else
// return "";
// }
//
// /*
// Properties
// */
//
// public AliceBot getCallback()
// {
// return callback;
// }
//
// public void setCallback(AliceBot callback)
// {
// this.callback = callback;
// }
//
// public String[] getMatchPath()
// {
// return matchPath;
// }
//
// public String getMatchPath(int index)
// {
// return matchPath[index];
// }
//
// public int getMatchPathLength()
// {
// return matchPath.length;
// }
// }
| import java.text.SimpleDateFormat;
import org.xml.sax.Attributes;
import bitoflife.chatterbean.Match; | /*
Copyleft (C) 2005 Hio Perroni Filho
xperroni@yahoo.com
ICQ: 2490863
This file is part of ChatterBean.
ChatterBean is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
ChatterBean 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with ChatterBean (look at the Documents/ directory); if not, either write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA, or visit (http://www.gnu.org/licenses/gpl.txt).
*/
package bitoflife.chatterbean.aiml;
public class Date extends TemplateElement
{
/*
Attributes
*/
private final SimpleDateFormat format = new SimpleDateFormat();
/**date tag format value, add by lcl**/
private String formatStr = "";
/*
Constructors
*/
public Date()
{
}
public Date(Attributes attributes)
{
formatStr = attributes.getValue(0);
}
/*
Methods
*/
public int hashCode()
{
return 13;
}
| // Path: alice-src/bitoflife/chatterbean/Match.java
// public class Match implements Serializable
// {
// /*
// Inner Classes
// */
//
// public enum Section {PATTERN, THAT, TOPIC;}
//
// /*
// Attributes
// */
//
// /** Version class identifier for the serialization engine. Matches the number of the last revision where the class was created / modified. */
// private static final long serialVersionUID = 8L;
//
// private final Map<Section, List<String>> sections = new HashMap<Section, List<String>>();
//
// private AliceBot callback;
//
// private Sentence input;
//
// private Sentence that;
//
// private Sentence topic;
//
// private String[] matchPath;
//
// {
// sections.put(Section.PATTERN, new ArrayList<String>(2)); // Pattern wildcards
// sections.put(Section.THAT, new ArrayList<String>(2)); // That wildcards
// sections.put(Section.TOPIC, new ArrayList<String>(2)); // Topic wildcards
// }
//
// /*
// Constructor
// */
//
// public Match()
// {
// }
//
// public Match(AliceBot callback, Sentence input, Sentence that, Sentence topic)
// {
// this.callback = callback;
// this.input = input;
// this.that = that;
// this.topic = topic;
// setUpMatchPath(input.normalized(), that.normalized(), topic.normalized());
// }
//
// public Match(Sentence input)
// {
// this(null, input, ASTERISK, ASTERISK);
// }
//
// /*
// Methods
// */
//
// private void appendWildcard(List<String> section, Sentence source, int beginIndex, int endIndex)
// {
// if (beginIndex == endIndex)
// section.add(0, "");
// else try
// {
// section.add(0, source.original(beginIndex, endIndex));
// }
// catch (Exception e)
// {
// // throw new RuntimeException("Source: {\"" + source.getOriginal() + "\", \"" + source.getNormalized() + "\"}\n" +
// // "Begin Index: " + beginIndex + "\n" +
// // "End Index: " + endIndex, e);
// }
// }
//
// private void setUpMatchPath(String[] pattern, String[] that, String[] topic)
// {
// int m = pattern.length, n = that.length, o = topic.length;
// matchPath = new String[m + 1 + n + 1 + o];
// matchPath[m] = "<THAT>";
// matchPath[m + 1 + n] = "<TOPIC>";
//
// System.arraycopy(pattern, 0, matchPath, 0, m);
// System.arraycopy(that, 0, matchPath, m + 1, n);
// System.arraycopy(topic, 0, matchPath, m + 1 + n + 1, o);
// }
//
// public void appendWildcard(int beginIndex, int endIndex)
// {
// int inputLength = input.length();
// if (beginIndex <= inputLength)
// {
// appendWildcard(sections.get(Section.PATTERN), input, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (inputLength + 1);
// endIndex = endIndex - (inputLength + 1);
//
// int thatLength = that.length();
// if (beginIndex <= thatLength)
// {
// appendWildcard(sections.get(Section.THAT), that, beginIndex, endIndex);
// return;
// }
//
// beginIndex = beginIndex - (thatLength + 1);
// endIndex = endIndex - (thatLength + 1);
//
// int topicLength = topic.length();
// if (beginIndex < topicLength)
// appendWildcard(sections.get(Section.TOPIC), topic, beginIndex, endIndex);
// }
//
// /**
// Gets the contents for the (index)th wildcard in the matched section.
// */
// public String wildcard(Section section, int index)
// {
// List<String> wildcards = sections.get(section);
// //fixed by lcl
// if(wildcards.size() == 0)
// return "";
// int i = index - 1;
// if(i < wildcards.size() && i > -1)
// return wildcards.get(i);
// else
// return "";
// }
//
// /*
// Properties
// */
//
// public AliceBot getCallback()
// {
// return callback;
// }
//
// public void setCallback(AliceBot callback)
// {
// this.callback = callback;
// }
//
// public String[] getMatchPath()
// {
// return matchPath;
// }
//
// public String getMatchPath(int index)
// {
// return matchPath[index];
// }
//
// public int getMatchPathLength()
// {
// return matchPath.length;
// }
// }
// Path: alice-src/bitoflife/chatterbean/aiml/Date.java
import java.text.SimpleDateFormat;
import org.xml.sax.Attributes;
import bitoflife.chatterbean.Match;
/*
Copyleft (C) 2005 Hio Perroni Filho
xperroni@yahoo.com
ICQ: 2490863
This file is part of ChatterBean.
ChatterBean is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
ChatterBean 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with ChatterBean (look at the Documents/ directory); if not, either write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA, or visit (http://www.gnu.org/licenses/gpl.txt).
*/
package bitoflife.chatterbean.aiml;
public class Date extends TemplateElement
{
/*
Attributes
*/
private final SimpleDateFormat format = new SimpleDateFormat();
/**date tag format value, add by lcl**/
private String formatStr = "";
/*
Constructors
*/
public Date()
{
}
public Date(Attributes attributes)
{
formatStr = attributes.getValue(0);
}
/*
Methods
*/
public int hashCode()
{
return 13;
}
| public String process(Match match) |
WonderBeat/vasilich | alice-src/bitoflife/chatterbean/parser/SubstitutionBuilder.java | // Path: alice-src/bitoflife/chatterbean/util/Escaper.java
// public static String escapeRegex(String splitter)
// {
// String special = "";
// try
// {
// splitter = splitter.replaceAll("\\\\", "\\\\\\\\");
//
// for (int i = 0, n = regex.length; i < n; i++)
// {
// special = regex[i];
// splitter = splitter.replaceAll(special, "\\" + special);
// }
// }
// catch (RuntimeException e)
// {
// throw new RuntimeException(e.getMessage() + "\nWhen trying to escape \"" + special + "\" in \"" + splitter + "\"", e);
// }
//
// return splitter;
// }
| import org.xml.sax.Attributes;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import static bitoflife.chatterbean.util.Escaper.escapeRegex; | section = substitutions.get("correction");
}
public void startPerson(Attributes attributes)
{
section = substitutions.get("person");
}
public void startPerson2(Attributes attributes)
{
section = substitutions.get("person2");
}
public void startGender(Attributes attributes)
{
section = substitutions.get("gender");
}
public void startProtection(Attributes attributes)
{
section = substitutions.get("protection");
}
public void startPunctuation(Attributes attributes)
{
section = substitutions.get("punctuation");
}
public void startSubstitute(Attributes attributes)
{ | // Path: alice-src/bitoflife/chatterbean/util/Escaper.java
// public static String escapeRegex(String splitter)
// {
// String special = "";
// try
// {
// splitter = splitter.replaceAll("\\\\", "\\\\\\\\");
//
// for (int i = 0, n = regex.length; i < n; i++)
// {
// special = regex[i];
// splitter = splitter.replaceAll(special, "\\" + special);
// }
// }
// catch (RuntimeException e)
// {
// throw new RuntimeException(e.getMessage() + "\nWhen trying to escape \"" + special + "\" in \"" + splitter + "\"", e);
// }
//
// return splitter;
// }
// Path: alice-src/bitoflife/chatterbean/parser/SubstitutionBuilder.java
import org.xml.sax.Attributes;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import static bitoflife.chatterbean.util.Escaper.escapeRegex;
section = substitutions.get("correction");
}
public void startPerson(Attributes attributes)
{
section = substitutions.get("person");
}
public void startPerson2(Attributes attributes)
{
section = substitutions.get("person2");
}
public void startGender(Attributes attributes)
{
section = substitutions.get("gender");
}
public void startProtection(Attributes attributes)
{
section = substitutions.get("protection");
}
public void startPunctuation(Attributes attributes)
{
section = substitutions.get("punctuation");
}
public void startSubstitute(Attributes attributes)
{ | String find = escapeRegex(attributes.getValue(0)); |
bit-man/SwissArmyJavaGit | javagit/src/test/java/edu/nyu/cs/javagit/test/utilities/TestStringUtilities.java | // Path: javagit/src/main/java/edu/nyu/cs/javagit/utilities/StringUtilities.java
// public final class StringUtilities {
// /**
// * Returns the position for char 'c' in string 'str' starting from position 'pos'
// * and searching towards the string beginning
// * @param str
// * @param from
// * @param c
// * @return char 'c' position or -1 if char is not found
// */
// public static int indexOfLeft(String str, int from, char c) {
// int pos = -1;
// int f = from;
//
// while( f >= 0 && pos == -1 )
// if ( str.charAt(f--) == c )
// pos = f+1;
//
// return pos;
// }
// }
| import edu.nyu.cs.javagit.utilities.StringUtilities;
import junit.framework.TestCase;
import org.junit.Test; | package edu.nyu.cs.javagit.test.utilities;
/**
* Description : StringUtilities testing
* Date: 3/31/13
* Time: 7:16 PM
*/
public class TestStringUtilities extends TestCase {
@Test
public void testFindChar() {
String str = "aaaaaaa bbb cccc"; | // Path: javagit/src/main/java/edu/nyu/cs/javagit/utilities/StringUtilities.java
// public final class StringUtilities {
// /**
// * Returns the position for char 'c' in string 'str' starting from position 'pos'
// * and searching towards the string beginning
// * @param str
// * @param from
// * @param c
// * @return char 'c' position or -1 if char is not found
// */
// public static int indexOfLeft(String str, int from, char c) {
// int pos = -1;
// int f = from;
//
// while( f >= 0 && pos == -1 )
// if ( str.charAt(f--) == c )
// pos = f+1;
//
// return pos;
// }
// }
// Path: javagit/src/test/java/edu/nyu/cs/javagit/test/utilities/TestStringUtilities.java
import edu.nyu.cs.javagit.utilities.StringUtilities;
import junit.framework.TestCase;
import org.junit.Test;
package edu.nyu.cs.javagit.test.utilities;
/**
* Description : StringUtilities testing
* Date: 3/31/13
* Time: 7:16 PM
*/
public class TestStringUtilities extends TestCase {
@Test
public void testFindChar() {
String str = "aaaaaaa bbb cccc"; | assertEquals(11, StringUtilities.indexOfLeft(str, 13, ' ')); |
bit-man/SwissArmyJavaGit | javagit/src/test/java/edu/nyu/cs/javagit/client/cli/TestCliGitMv.java | // Path: javagit/src/test/java/edu/nyu/cs/javagit/TestBase.java
// @Ignore
// public class TestBase extends TestCase {
//
// @Before
// public void setUp() throws IOException, JavaGitException {
// JavaGitConfiguration.setGitPath(TestProperty.GIT_PATH.asString());
// }
// }
//
// Path: javagit/src/main/java/edu/nyu/cs/javagit/client/GitMvResponseImpl.java
// public class GitMvResponseImpl extends GitMvResponse {
//
// /**
// * Adds comments from each line of the message, if received, upon successful execution of the
// * git-mv command, to the message buffer.
// *
// * @param comment
// * The comment from each line of the message, if received, upon successful execution of
// * the git-mv.
// */
// public void addComment(String comment) {
// message.append(comment);
// }
//
// /**
// * Sets the destination file/folder/symlink in response to the destination
// *
// * @param destination
// * The destination to set
// */
// public void setDestination(File destination) {
// this.destination = destination;
// }
//
// /**
// * Sets the source file/folder/symlink in response object to the source string.
// *
// * @param source
// * The source to set
// */
// public void setSource(File source) {
// this.source = source;
// }
//
// }
| import edu.nyu.cs.javagit.TestBase;
import edu.nyu.cs.javagit.api.JavaGitException;
import edu.nyu.cs.javagit.client.GitMvResponseImpl;
import org.junit.Test;
import java.io.File; | package edu.nyu.cs.javagit.client.cli;
public class TestCliGitMv extends TestBase {
private CliGitMv cliGitMv;
@Test
public void testGitBranchParserValidInput() {
cliGitMv = new CliGitMv();
// Checking parsing of git mv with dry-run option. | // Path: javagit/src/test/java/edu/nyu/cs/javagit/TestBase.java
// @Ignore
// public class TestBase extends TestCase {
//
// @Before
// public void setUp() throws IOException, JavaGitException {
// JavaGitConfiguration.setGitPath(TestProperty.GIT_PATH.asString());
// }
// }
//
// Path: javagit/src/main/java/edu/nyu/cs/javagit/client/GitMvResponseImpl.java
// public class GitMvResponseImpl extends GitMvResponse {
//
// /**
// * Adds comments from each line of the message, if received, upon successful execution of the
// * git-mv command, to the message buffer.
// *
// * @param comment
// * The comment from each line of the message, if received, upon successful execution of
// * the git-mv.
// */
// public void addComment(String comment) {
// message.append(comment);
// }
//
// /**
// * Sets the destination file/folder/symlink in response to the destination
// *
// * @param destination
// * The destination to set
// */
// public void setDestination(File destination) {
// this.destination = destination;
// }
//
// /**
// * Sets the source file/folder/symlink in response object to the source string.
// *
// * @param source
// * The source to set
// */
// public void setSource(File source) {
// this.source = source;
// }
//
// }
// Path: javagit/src/test/java/edu/nyu/cs/javagit/client/cli/TestCliGitMv.java
import edu.nyu.cs.javagit.TestBase;
import edu.nyu.cs.javagit.api.JavaGitException;
import edu.nyu.cs.javagit.client.GitMvResponseImpl;
import org.junit.Test;
import java.io.File;
package edu.nyu.cs.javagit.client.cli;
public class TestCliGitMv extends TestBase {
private CliGitMv cliGitMv;
@Test
public void testGitBranchParserValidInput() {
cliGitMv = new CliGitMv();
// Checking parsing of git mv with dry-run option. | GitMvResponseImpl response = new GitMvResponseImpl(); |
bit-man/SwissArmyJavaGit | javagit/src/test/java/edu/nyu/cs/javagit/test/utilities/TestExceptionMessageMap.java | // Path: javagit/src/main/java/edu/nyu/cs/javagit/utilities/ExceptionMessageMap.java
// public class ExceptionMessageMap {
//
// private static Map<String, String> MESSAGE_MAP;
//
// static {
// MESSAGE_MAP = new HashMap<String, String>();
//
// MESSAGE_MAP.put("000001", "000001: A String argument was not specified but is required.");
// MESSAGE_MAP.put("000002", "000002: A List<String> argument was not specified but is required.");
// MESSAGE_MAP.put("000003", "000003: An Object argument was not specified but is required.");
// MESSAGE_MAP.put("000004",
// "000004: The int argument is not greater than the lower bound (lowerBound < toCheck).");
// MESSAGE_MAP.put("000005",
// "000005: An List<?> argument was not specified or is empty but is required.");
// MESSAGE_MAP.put("000006",
// "000006: The int argument is outside the allowable range (start <= index < end).");
// MESSAGE_MAP.put("000007","000007: The argument should be a directory.");
//
// MESSAGE_MAP.put("000100", "000100: Invalid option combination for git-commit command.");
// MESSAGE_MAP.put("000110", "000110: Invalid option combination for git-add command.");
// MESSAGE_MAP.put("000120", "000120: Invalid option combination for git-branch command.");
// MESSAGE_MAP.put("000130", "000130: Invalid option combination for git-checkout command.");
//
// MESSAGE_MAP.put("020001", "020001: File or path does not exist.");
// MESSAGE_MAP.put("020002", "020002: File or path is not a directory.");
//
// MESSAGE_MAP.put("020100", "020100: Unable to start sub-process.");
// MESSAGE_MAP.put("020101", "020101: Error reading input from the sub-process.");
//
// MESSAGE_MAP.put("100000", "100000: Incorrect refType type.");
// MESSAGE_MAP.put("100001", "100001: Error retrieving git version.");
// MESSAGE_MAP.put("100002", "100002: Invalid path to git specified.");
//
// MESSAGE_MAP.put("401000", "401000: Error calling git-add.");
// MESSAGE_MAP.put("401001", "401001: Error fatal pathspec error while executing git-add.");
//
// MESSAGE_MAP.put("410000", "410000: Error calling git-commit.");
//
// MESSAGE_MAP.put("404000", "404000: Error calling git-branch. ");
//
// MESSAGE_MAP.put("424000", "424000: Error calling git-mv. ");
//
// MESSAGE_MAP.put("424001", "424001: Error calling git-mv for dry-run. ");
//
// MESSAGE_MAP.put("420001", "420001: Error calling git log");
//
// MESSAGE_MAP.put("432000", "432000: Error calling git-reset.");
//
// MESSAGE_MAP.put("418000", "418000: Error calling git init.");
//
// MESSAGE_MAP.put("434000", "434000: Error calling git-rm.");
//
// MESSAGE_MAP.put("406000", "406000: Error calling git-checkout");
// MESSAGE_MAP.put("406001", "406001: Error not a treeIsh RefType");
//
// MESSAGE_MAP.put("438000", "438000: Error calling git-status");
//
// MESSAGE_MAP.put("442001", "442001: No git, or wrong, major version number.");
// MESSAGE_MAP.put("442002", "442002: No git, or wrong, minor version number.");
// MESSAGE_MAP.put("442003", "442003: No git, or wrong, major release version number.");
// MESSAGE_MAP.put("442004", "442004: Wrong minor release version number.");
// }
//
// /**
// * Gets the error message for the specified code.
// *
// * @param code
// * The error code for which to get the associated error message.
// * @return The error message for the specified code.
// */
// public static String getMessage(String code) {
// String str = MESSAGE_MAP.get(code);
// if (null == str) {
// return "NO MESSAGE FOR ERROR CODE. { code=[" + code + "] }";
// }
// return str;
// }
//
// }
| import edu.nyu.cs.javagit.utilities.ExceptionMessageMap;
import junit.framework.TestCase;
import org.junit.Before;
import org.junit.Test; | /*
* ====================================================================
* Copyright (c) 2008 JavaGit Project. All rights reserved.
*
* This software is licensed using the GNU LGPL v2.1 license. A copy
* of the license is included with the distribution of this source
* code in the LICENSE.txt file. The text of the license can also
* be obtained at:
*
* http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
*
* For more information on the JavaGit project, see:
*
* http://www.javagit.com
* ====================================================================
*/
package edu.nyu.cs.javagit.test.utilities;
/**
* Test class for edu.nyu.cs.javagit.utiltites.ExceptionMessageMap.
*/
public class TestExceptionMessageMap extends TestCase {
@Before
protected void setUp() {
}
@Test
public void testGetMessage() {
assertGetMessageValid(null, "NO MESSAGE FOR ERROR CODE. { code=[null] }");
assertGetMessageValid("", "NO MESSAGE FOR ERROR CODE. { code=[] }");
assertGetMessageValid("0", "NO MESSAGE FOR ERROR CODE. { code=[0] }");
assertGetMessageValid("000001", "000001: A String argument was not specified but is required.");
}
private void assertGetMessageValid(String code, String expectedMessage) { | // Path: javagit/src/main/java/edu/nyu/cs/javagit/utilities/ExceptionMessageMap.java
// public class ExceptionMessageMap {
//
// private static Map<String, String> MESSAGE_MAP;
//
// static {
// MESSAGE_MAP = new HashMap<String, String>();
//
// MESSAGE_MAP.put("000001", "000001: A String argument was not specified but is required.");
// MESSAGE_MAP.put("000002", "000002: A List<String> argument was not specified but is required.");
// MESSAGE_MAP.put("000003", "000003: An Object argument was not specified but is required.");
// MESSAGE_MAP.put("000004",
// "000004: The int argument is not greater than the lower bound (lowerBound < toCheck).");
// MESSAGE_MAP.put("000005",
// "000005: An List<?> argument was not specified or is empty but is required.");
// MESSAGE_MAP.put("000006",
// "000006: The int argument is outside the allowable range (start <= index < end).");
// MESSAGE_MAP.put("000007","000007: The argument should be a directory.");
//
// MESSAGE_MAP.put("000100", "000100: Invalid option combination for git-commit command.");
// MESSAGE_MAP.put("000110", "000110: Invalid option combination for git-add command.");
// MESSAGE_MAP.put("000120", "000120: Invalid option combination for git-branch command.");
// MESSAGE_MAP.put("000130", "000130: Invalid option combination for git-checkout command.");
//
// MESSAGE_MAP.put("020001", "020001: File or path does not exist.");
// MESSAGE_MAP.put("020002", "020002: File or path is not a directory.");
//
// MESSAGE_MAP.put("020100", "020100: Unable to start sub-process.");
// MESSAGE_MAP.put("020101", "020101: Error reading input from the sub-process.");
//
// MESSAGE_MAP.put("100000", "100000: Incorrect refType type.");
// MESSAGE_MAP.put("100001", "100001: Error retrieving git version.");
// MESSAGE_MAP.put("100002", "100002: Invalid path to git specified.");
//
// MESSAGE_MAP.put("401000", "401000: Error calling git-add.");
// MESSAGE_MAP.put("401001", "401001: Error fatal pathspec error while executing git-add.");
//
// MESSAGE_MAP.put("410000", "410000: Error calling git-commit.");
//
// MESSAGE_MAP.put("404000", "404000: Error calling git-branch. ");
//
// MESSAGE_MAP.put("424000", "424000: Error calling git-mv. ");
//
// MESSAGE_MAP.put("424001", "424001: Error calling git-mv for dry-run. ");
//
// MESSAGE_MAP.put("420001", "420001: Error calling git log");
//
// MESSAGE_MAP.put("432000", "432000: Error calling git-reset.");
//
// MESSAGE_MAP.put("418000", "418000: Error calling git init.");
//
// MESSAGE_MAP.put("434000", "434000: Error calling git-rm.");
//
// MESSAGE_MAP.put("406000", "406000: Error calling git-checkout");
// MESSAGE_MAP.put("406001", "406001: Error not a treeIsh RefType");
//
// MESSAGE_MAP.put("438000", "438000: Error calling git-status");
//
// MESSAGE_MAP.put("442001", "442001: No git, or wrong, major version number.");
// MESSAGE_MAP.put("442002", "442002: No git, or wrong, minor version number.");
// MESSAGE_MAP.put("442003", "442003: No git, or wrong, major release version number.");
// MESSAGE_MAP.put("442004", "442004: Wrong minor release version number.");
// }
//
// /**
// * Gets the error message for the specified code.
// *
// * @param code
// * The error code for which to get the associated error message.
// * @return The error message for the specified code.
// */
// public static String getMessage(String code) {
// String str = MESSAGE_MAP.get(code);
// if (null == str) {
// return "NO MESSAGE FOR ERROR CODE. { code=[" + code + "] }";
// }
// return str;
// }
//
// }
// Path: javagit/src/test/java/edu/nyu/cs/javagit/test/utilities/TestExceptionMessageMap.java
import edu.nyu.cs.javagit.utilities.ExceptionMessageMap;
import junit.framework.TestCase;
import org.junit.Before;
import org.junit.Test;
/*
* ====================================================================
* Copyright (c) 2008 JavaGit Project. All rights reserved.
*
* This software is licensed using the GNU LGPL v2.1 license. A copy
* of the license is included with the distribution of this source
* code in the LICENSE.txt file. The text of the license can also
* be obtained at:
*
* http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
*
* For more information on the JavaGit project, see:
*
* http://www.javagit.com
* ====================================================================
*/
package edu.nyu.cs.javagit.test.utilities;
/**
* Test class for edu.nyu.cs.javagit.utiltites.ExceptionMessageMap.
*/
public class TestExceptionMessageMap extends TestCase {
@Before
protected void setUp() {
}
@Test
public void testGetMessage() {
assertGetMessageValid(null, "NO MESSAGE FOR ERROR CODE. { code=[null] }");
assertGetMessageValid("", "NO MESSAGE FOR ERROR CODE. { code=[] }");
assertGetMessageValid("0", "NO MESSAGE FOR ERROR CODE. { code=[0] }");
assertGetMessageValid("000001", "000001: A String argument was not specified but is required.");
}
private void assertGetMessageValid(String code, String expectedMessage) { | String actualMessage = ExceptionMessageMap.getMessage(code); |
bit-man/SwissArmyJavaGit | javagit/src/test/java/edu/nyu/cs/javagit/api/commands/TestGitCommit.java | // Path: javagit/src/test/java/edu/nyu/cs/javagit/TestBase.java
// @Ignore
// public class TestBase extends TestCase {
//
// @Before
// public void setUp() throws IOException, JavaGitException {
// JavaGitConfiguration.setGitPath(TestProperty.GIT_PATH.asString());
// }
// }
//
// Path: javagit/src/test/java/edu/nyu/cs/javagit/utilities/FileUtilities.java
// public class FileUtilities {
//
// /**
// * Create a temp directory based on the supplied directory base name. The directory will be
// * created under the temp directory for the system running the program.
// *
// * @param baseDirName A base name for the directory. If this directory exists, a directory based on this
// * name will be created.
// * @return A <code>File</code> instance representing the created directory.
// */
// public static File createTempDirectory(String baseDirName) throws IOException {
// // Get the system temp directory location.
// File tmpfile = File.createTempFile("AfileName", "tmp");
// String absPath = tmpfile.getAbsolutePath();
// tmpfile.delete();
// int lastSep = absPath.lastIndexOf(File.separatorChar);
// String tmpDir = absPath.substring(0, lastSep + 1);
//
// // System.out.println("Temp Directory: tmpDir=["+ tmpDir + "]");
//
// // Create a temp directory for the caller
// File file = new File(tmpDir + baseDirName);
// int num = 0;
// while (!file.mkdir()) {
// file = new File(tmpDir + baseDirName + Integer.toString(num++));
// }
//
// return file;
// }
//
// /**
// * Create a new file and write the contents to it.
// *
// * @param baseDir The base directory of the repo.
// * @param filePath The relative path to the file with respect to the base directory.
// * @param contents Some contents to write to the file.
// * @return A <code>File</code> object representation of the file.
// * @throws IOException If there are problems creating the file or writing the contents to the file.
// */
// public static File createFile(File baseDir, String filePath, String contents) throws IOException {
// File file = new File(baseDir.getPath() + File.separator + filePath);
// file.createNewFile();
// FileWriter fw = new FileWriter(file);
// fw.write(contents);
// fw.flush();
// fw.close();
// return new File(filePath);
// }
//
// /**
// * Recursively deletes the specified file/directory.
// *
// * @param dirOrFile The file or directory to delete recursively and forcefully.
// * @throws JavaGitException Thrown if a file or directory was not deleted.
// */
// public static void removeDirectoryRecursivelyAndForcefully(File dirOrFile)
// throws JavaGitException {
// File[] children = dirOrFile.listFiles();
// if (null != children) {
// for (File f : children) {
// removeDirectoryRecursivelyAndForcefully(f);
// }
// }
// //System.gc();
// if (!dirOrFile.delete()) {
// throw new JavaGitException(-1, "-1: Unable to delete file/directory. { path=["
// + dirOrFile.getAbsolutePath() + "] }");
// }
// }
//
// /**
// * Append some text to an existing file.
// *
// * @param file File that will be modified
// * @param appendText The text that will be appended to the file
// * @throws FileNotFoundException Exception thrown if the file does not exist.
// * @throws IOException thrown if the IO operation fails.
// */
// public static void modifyFileContents(File file, String appendText) throws FileNotFoundException,
// IOException {
// if (!file.exists()) {
// throw new FileNotFoundException("File does not exist");
// }
// FileWriter fw = new FileWriter(file);
// fw.append(appendText);
// fw.close();
// }
//
// }
| import edu.nyu.cs.javagit.TestBase;
import edu.nyu.cs.javagit.api.JavaGitException;
import edu.nyu.cs.javagit.utilities.FileUtilities;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List; | /*
* ====================================================================
* Copyright (c) 2008 JavaGit Project. All rights reserved.
*
* This software is licensed using the GNU LGPL v2.1 license. A copy
* of the license is included with the distribution of this source
* code in the LICENSE.txt file. The text of the license can also
* be obtained at:
*
* http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
*
* For more information on the JavaGit project, see:
*
* http://www.javagit.com
* ====================================================================
*/
package edu.nyu.cs.javagit.api.commands;
/**
* Implements test cases for for GitCommit.
*/
public class TestGitCommit extends TestBase {
/*
* TODO (jhl388): Create tests for the following:
*
* commands -- add, move(same dir, different dir in same tree, totally different dir), delete,
* copy (same as for move), just edits
*
* methods -- all methods in GitCommit, thus all the types of commits.
*
* errors -- test errors states returned by git-commit (?)
*/
private File repoDirectory;
private GitCommit commit;
private GitAdd add;
private GitCommitOptions options;
private List<File> paths;
@Before
public void setUp() throws IOException, JavaGitException {
super.setUp(); | // Path: javagit/src/test/java/edu/nyu/cs/javagit/TestBase.java
// @Ignore
// public class TestBase extends TestCase {
//
// @Before
// public void setUp() throws IOException, JavaGitException {
// JavaGitConfiguration.setGitPath(TestProperty.GIT_PATH.asString());
// }
// }
//
// Path: javagit/src/test/java/edu/nyu/cs/javagit/utilities/FileUtilities.java
// public class FileUtilities {
//
// /**
// * Create a temp directory based on the supplied directory base name. The directory will be
// * created under the temp directory for the system running the program.
// *
// * @param baseDirName A base name for the directory. If this directory exists, a directory based on this
// * name will be created.
// * @return A <code>File</code> instance representing the created directory.
// */
// public static File createTempDirectory(String baseDirName) throws IOException {
// // Get the system temp directory location.
// File tmpfile = File.createTempFile("AfileName", "tmp");
// String absPath = tmpfile.getAbsolutePath();
// tmpfile.delete();
// int lastSep = absPath.lastIndexOf(File.separatorChar);
// String tmpDir = absPath.substring(0, lastSep + 1);
//
// // System.out.println("Temp Directory: tmpDir=["+ tmpDir + "]");
//
// // Create a temp directory for the caller
// File file = new File(tmpDir + baseDirName);
// int num = 0;
// while (!file.mkdir()) {
// file = new File(tmpDir + baseDirName + Integer.toString(num++));
// }
//
// return file;
// }
//
// /**
// * Create a new file and write the contents to it.
// *
// * @param baseDir The base directory of the repo.
// * @param filePath The relative path to the file with respect to the base directory.
// * @param contents Some contents to write to the file.
// * @return A <code>File</code> object representation of the file.
// * @throws IOException If there are problems creating the file or writing the contents to the file.
// */
// public static File createFile(File baseDir, String filePath, String contents) throws IOException {
// File file = new File(baseDir.getPath() + File.separator + filePath);
// file.createNewFile();
// FileWriter fw = new FileWriter(file);
// fw.write(contents);
// fw.flush();
// fw.close();
// return new File(filePath);
// }
//
// /**
// * Recursively deletes the specified file/directory.
// *
// * @param dirOrFile The file or directory to delete recursively and forcefully.
// * @throws JavaGitException Thrown if a file or directory was not deleted.
// */
// public static void removeDirectoryRecursivelyAndForcefully(File dirOrFile)
// throws JavaGitException {
// File[] children = dirOrFile.listFiles();
// if (null != children) {
// for (File f : children) {
// removeDirectoryRecursivelyAndForcefully(f);
// }
// }
// //System.gc();
// if (!dirOrFile.delete()) {
// throw new JavaGitException(-1, "-1: Unable to delete file/directory. { path=["
// + dirOrFile.getAbsolutePath() + "] }");
// }
// }
//
// /**
// * Append some text to an existing file.
// *
// * @param file File that will be modified
// * @param appendText The text that will be appended to the file
// * @throws FileNotFoundException Exception thrown if the file does not exist.
// * @throws IOException thrown if the IO operation fails.
// */
// public static void modifyFileContents(File file, String appendText) throws FileNotFoundException,
// IOException {
// if (!file.exists()) {
// throw new FileNotFoundException("File does not exist");
// }
// FileWriter fw = new FileWriter(file);
// fw.append(appendText);
// fw.close();
// }
//
// }
// Path: javagit/src/test/java/edu/nyu/cs/javagit/api/commands/TestGitCommit.java
import edu.nyu.cs.javagit.TestBase;
import edu.nyu.cs.javagit.api.JavaGitException;
import edu.nyu.cs.javagit.utilities.FileUtilities;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/*
* ====================================================================
* Copyright (c) 2008 JavaGit Project. All rights reserved.
*
* This software is licensed using the GNU LGPL v2.1 license. A copy
* of the license is included with the distribution of this source
* code in the LICENSE.txt file. The text of the license can also
* be obtained at:
*
* http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
*
* For more information on the JavaGit project, see:
*
* http://www.javagit.com
* ====================================================================
*/
package edu.nyu.cs.javagit.api.commands;
/**
* Implements test cases for for GitCommit.
*/
public class TestGitCommit extends TestBase {
/*
* TODO (jhl388): Create tests for the following:
*
* commands -- add, move(same dir, different dir in same tree, totally different dir), delete,
* copy (same as for move), just edits
*
* methods -- all methods in GitCommit, thus all the types of commits.
*
* errors -- test errors states returned by git-commit (?)
*/
private File repoDirectory;
private GitCommit commit;
private GitAdd add;
private GitCommitOptions options;
private List<File> paths;
@Before
public void setUp() throws IOException, JavaGitException {
super.setUp(); | repoDirectory = FileUtilities.createTempDirectory("GitCommitTestRepo"); |
bit-man/SwissArmyJavaGit | javagit/src/test/java/edu/nyu/cs/javagit/api/commands/TestGitStatusOptions.java | // Path: javagit/src/test/java/edu/nyu/cs/javagit/TestBase.java
// @Ignore
// public class TestBase extends TestCase {
//
// @Before
// public void setUp() throws IOException, JavaGitException {
// JavaGitConfiguration.setGitPath(TestProperty.GIT_PATH.asString());
// }
// }
//
// Path: javagit/src/test/java/edu/nyu/cs/javagit/utilities/FileUtilities.java
// public class FileUtilities {
//
// /**
// * Create a temp directory based on the supplied directory base name. The directory will be
// * created under the temp directory for the system running the program.
// *
// * @param baseDirName A base name for the directory. If this directory exists, a directory based on this
// * name will be created.
// * @return A <code>File</code> instance representing the created directory.
// */
// public static File createTempDirectory(String baseDirName) throws IOException {
// // Get the system temp directory location.
// File tmpfile = File.createTempFile("AfileName", "tmp");
// String absPath = tmpfile.getAbsolutePath();
// tmpfile.delete();
// int lastSep = absPath.lastIndexOf(File.separatorChar);
// String tmpDir = absPath.substring(0, lastSep + 1);
//
// // System.out.println("Temp Directory: tmpDir=["+ tmpDir + "]");
//
// // Create a temp directory for the caller
// File file = new File(tmpDir + baseDirName);
// int num = 0;
// while (!file.mkdir()) {
// file = new File(tmpDir + baseDirName + Integer.toString(num++));
// }
//
// return file;
// }
//
// /**
// * Create a new file and write the contents to it.
// *
// * @param baseDir The base directory of the repo.
// * @param filePath The relative path to the file with respect to the base directory.
// * @param contents Some contents to write to the file.
// * @return A <code>File</code> object representation of the file.
// * @throws IOException If there are problems creating the file or writing the contents to the file.
// */
// public static File createFile(File baseDir, String filePath, String contents) throws IOException {
// File file = new File(baseDir.getPath() + File.separator + filePath);
// file.createNewFile();
// FileWriter fw = new FileWriter(file);
// fw.write(contents);
// fw.flush();
// fw.close();
// return new File(filePath);
// }
//
// /**
// * Recursively deletes the specified file/directory.
// *
// * @param dirOrFile The file or directory to delete recursively and forcefully.
// * @throws JavaGitException Thrown if a file or directory was not deleted.
// */
// public static void removeDirectoryRecursivelyAndForcefully(File dirOrFile)
// throws JavaGitException {
// File[] children = dirOrFile.listFiles();
// if (null != children) {
// for (File f : children) {
// removeDirectoryRecursivelyAndForcefully(f);
// }
// }
// //System.gc();
// if (!dirOrFile.delete()) {
// throw new JavaGitException(-1, "-1: Unable to delete file/directory. { path=["
// + dirOrFile.getAbsolutePath() + "] }");
// }
// }
//
// /**
// * Append some text to an existing file.
// *
// * @param file File that will be modified
// * @param appendText The text that will be appended to the file
// * @throws FileNotFoundException Exception thrown if the file does not exist.
// * @throws IOException thrown if the IO operation fails.
// */
// public static void modifyFileContents(File file, String appendText) throws FileNotFoundException,
// IOException {
// if (!file.exists()) {
// throw new FileNotFoundException("File does not exist");
// }
// FileWriter fw = new FileWriter(file);
// fw.append(appendText);
// fw.close();
// }
//
// }
| import edu.nyu.cs.javagit.TestBase;
import edu.nyu.cs.javagit.api.JavaGitException;
import edu.nyu.cs.javagit.utilities.FileUtilities;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.io.File;
import java.io.IOException; | /*
* ====================================================================
* Copyright (c) 2008 JavaGit Project. All rights reserved.
*
* This software is licensed using the GNU LGPL v2.1 license. A copy
* of the license is included with the distribution of this source
* code in the LICENSE.txt file. The text of the license can also
* be obtained at:
*
* http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
*
* For more information on the JavaGit project, see:
*
* http://www.javagit.com
* ====================================================================
*/
package edu.nyu.cs.javagit.api.commands;
public class TestGitStatusOptions extends TestBase {
GitStatusOptions options;
File repositoryDirectory;
GitStatus status;
@Before
public void setUp() throws IOException, JavaGitException {
super.setUp(); | // Path: javagit/src/test/java/edu/nyu/cs/javagit/TestBase.java
// @Ignore
// public class TestBase extends TestCase {
//
// @Before
// public void setUp() throws IOException, JavaGitException {
// JavaGitConfiguration.setGitPath(TestProperty.GIT_PATH.asString());
// }
// }
//
// Path: javagit/src/test/java/edu/nyu/cs/javagit/utilities/FileUtilities.java
// public class FileUtilities {
//
// /**
// * Create a temp directory based on the supplied directory base name. The directory will be
// * created under the temp directory for the system running the program.
// *
// * @param baseDirName A base name for the directory. If this directory exists, a directory based on this
// * name will be created.
// * @return A <code>File</code> instance representing the created directory.
// */
// public static File createTempDirectory(String baseDirName) throws IOException {
// // Get the system temp directory location.
// File tmpfile = File.createTempFile("AfileName", "tmp");
// String absPath = tmpfile.getAbsolutePath();
// tmpfile.delete();
// int lastSep = absPath.lastIndexOf(File.separatorChar);
// String tmpDir = absPath.substring(0, lastSep + 1);
//
// // System.out.println("Temp Directory: tmpDir=["+ tmpDir + "]");
//
// // Create a temp directory for the caller
// File file = new File(tmpDir + baseDirName);
// int num = 0;
// while (!file.mkdir()) {
// file = new File(tmpDir + baseDirName + Integer.toString(num++));
// }
//
// return file;
// }
//
// /**
// * Create a new file and write the contents to it.
// *
// * @param baseDir The base directory of the repo.
// * @param filePath The relative path to the file with respect to the base directory.
// * @param contents Some contents to write to the file.
// * @return A <code>File</code> object representation of the file.
// * @throws IOException If there are problems creating the file or writing the contents to the file.
// */
// public static File createFile(File baseDir, String filePath, String contents) throws IOException {
// File file = new File(baseDir.getPath() + File.separator + filePath);
// file.createNewFile();
// FileWriter fw = new FileWriter(file);
// fw.write(contents);
// fw.flush();
// fw.close();
// return new File(filePath);
// }
//
// /**
// * Recursively deletes the specified file/directory.
// *
// * @param dirOrFile The file or directory to delete recursively and forcefully.
// * @throws JavaGitException Thrown if a file or directory was not deleted.
// */
// public static void removeDirectoryRecursivelyAndForcefully(File dirOrFile)
// throws JavaGitException {
// File[] children = dirOrFile.listFiles();
// if (null != children) {
// for (File f : children) {
// removeDirectoryRecursivelyAndForcefully(f);
// }
// }
// //System.gc();
// if (!dirOrFile.delete()) {
// throw new JavaGitException(-1, "-1: Unable to delete file/directory. { path=["
// + dirOrFile.getAbsolutePath() + "] }");
// }
// }
//
// /**
// * Append some text to an existing file.
// *
// * @param file File that will be modified
// * @param appendText The text that will be appended to the file
// * @throws FileNotFoundException Exception thrown if the file does not exist.
// * @throws IOException thrown if the IO operation fails.
// */
// public static void modifyFileContents(File file, String appendText) throws FileNotFoundException,
// IOException {
// if (!file.exists()) {
// throw new FileNotFoundException("File does not exist");
// }
// FileWriter fw = new FileWriter(file);
// fw.append(appendText);
// fw.close();
// }
//
// }
// Path: javagit/src/test/java/edu/nyu/cs/javagit/api/commands/TestGitStatusOptions.java
import edu.nyu.cs.javagit.TestBase;
import edu.nyu.cs.javagit.api.JavaGitException;
import edu.nyu.cs.javagit.utilities.FileUtilities;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
/*
* ====================================================================
* Copyright (c) 2008 JavaGit Project. All rights reserved.
*
* This software is licensed using the GNU LGPL v2.1 license. A copy
* of the license is included with the distribution of this source
* code in the LICENSE.txt file. The text of the license can also
* be obtained at:
*
* http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
*
* For more information on the JavaGit project, see:
*
* http://www.javagit.com
* ====================================================================
*/
package edu.nyu.cs.javagit.api.commands;
public class TestGitStatusOptions extends TestBase {
GitStatusOptions options;
File repositoryDirectory;
GitStatus status;
@Before
public void setUp() throws IOException, JavaGitException {
super.setUp(); | repositoryDirectory = FileUtilities.createTempDirectory("GitStatusTestRepository"); |
bit-man/SwissArmyJavaGit | javagit/src/main/java/edu/nyu/cs/javagit/api/commands/GitCommitOptions.java | // Path: javagit/src/main/java/edu/nyu/cs/javagit/utilities/ExceptionMessageMap.java
// public class ExceptionMessageMap {
//
// private static Map<String, String> MESSAGE_MAP;
//
// static {
// MESSAGE_MAP = new HashMap<String, String>();
//
// MESSAGE_MAP.put("000001", "000001: A String argument was not specified but is required.");
// MESSAGE_MAP.put("000002", "000002: A List<String> argument was not specified but is required.");
// MESSAGE_MAP.put("000003", "000003: An Object argument was not specified but is required.");
// MESSAGE_MAP.put("000004",
// "000004: The int argument is not greater than the lower bound (lowerBound < toCheck).");
// MESSAGE_MAP.put("000005",
// "000005: An List<?> argument was not specified or is empty but is required.");
// MESSAGE_MAP.put("000006",
// "000006: The int argument is outside the allowable range (start <= index < end).");
// MESSAGE_MAP.put("000007","000007: The argument should be a directory.");
//
// MESSAGE_MAP.put("000100", "000100: Invalid option combination for git-commit command.");
// MESSAGE_MAP.put("000110", "000110: Invalid option combination for git-add command.");
// MESSAGE_MAP.put("000120", "000120: Invalid option combination for git-branch command.");
// MESSAGE_MAP.put("000130", "000130: Invalid option combination for git-checkout command.");
//
// MESSAGE_MAP.put("020001", "020001: File or path does not exist.");
// MESSAGE_MAP.put("020002", "020002: File or path is not a directory.");
//
// MESSAGE_MAP.put("020100", "020100: Unable to start sub-process.");
// MESSAGE_MAP.put("020101", "020101: Error reading input from the sub-process.");
//
// MESSAGE_MAP.put("100000", "100000: Incorrect refType type.");
// MESSAGE_MAP.put("100001", "100001: Error retrieving git version.");
// MESSAGE_MAP.put("100002", "100002: Invalid path to git specified.");
//
// MESSAGE_MAP.put("401000", "401000: Error calling git-add.");
// MESSAGE_MAP.put("401001", "401001: Error fatal pathspec error while executing git-add.");
//
// MESSAGE_MAP.put("410000", "410000: Error calling git-commit.");
//
// MESSAGE_MAP.put("404000", "404000: Error calling git-branch. ");
//
// MESSAGE_MAP.put("424000", "424000: Error calling git-mv. ");
//
// MESSAGE_MAP.put("424001", "424001: Error calling git-mv for dry-run. ");
//
// MESSAGE_MAP.put("420001", "420001: Error calling git log");
//
// MESSAGE_MAP.put("432000", "432000: Error calling git-reset.");
//
// MESSAGE_MAP.put("418000", "418000: Error calling git init.");
//
// MESSAGE_MAP.put("434000", "434000: Error calling git-rm.");
//
// MESSAGE_MAP.put("406000", "406000: Error calling git-checkout");
// MESSAGE_MAP.put("406001", "406001: Error not a treeIsh RefType");
//
// MESSAGE_MAP.put("438000", "438000: Error calling git-status");
//
// MESSAGE_MAP.put("442001", "442001: No git, or wrong, major version number.");
// MESSAGE_MAP.put("442002", "442002: No git, or wrong, minor version number.");
// MESSAGE_MAP.put("442003", "442003: No git, or wrong, major release version number.");
// MESSAGE_MAP.put("442004", "442004: Wrong minor release version number.");
// }
//
// /**
// * Gets the error message for the specified code.
// *
// * @param code
// * The error code for which to get the associated error message.
// * @return The error message for the specified code.
// */
// public static String getMessage(String code) {
// String str = MESSAGE_MAP.get(code);
// if (null == str) {
// return "NO MESSAGE FOR ERROR CODE. { code=[" + code + "] }";
// }
// return str;
// }
//
// }
| import edu.nyu.cs.javagit.utilities.ExceptionMessageMap; | }
/**
* Is the --only option set?
*
* @return True if the --only option is set, false if it is not set.
*/
public boolean isOptOnly() {
return optOnly;
}
/**
* Set the value to use as the author name for a commit.
*
* @param author
* The value to use as the author name for a commit.
*/
public void setAuthor(String author) {
this.author = author;
}
/**
* Set the --all option. An <code>IllegalArgumentException</code> is thrown if the only or
* include options are set.
*
* @param optAll
* True to set the --all option, false to unset it.
*/
public void setOptAll(boolean optAll) {
if (optOnly || optInclude) { | // Path: javagit/src/main/java/edu/nyu/cs/javagit/utilities/ExceptionMessageMap.java
// public class ExceptionMessageMap {
//
// private static Map<String, String> MESSAGE_MAP;
//
// static {
// MESSAGE_MAP = new HashMap<String, String>();
//
// MESSAGE_MAP.put("000001", "000001: A String argument was not specified but is required.");
// MESSAGE_MAP.put("000002", "000002: A List<String> argument was not specified but is required.");
// MESSAGE_MAP.put("000003", "000003: An Object argument was not specified but is required.");
// MESSAGE_MAP.put("000004",
// "000004: The int argument is not greater than the lower bound (lowerBound < toCheck).");
// MESSAGE_MAP.put("000005",
// "000005: An List<?> argument was not specified or is empty but is required.");
// MESSAGE_MAP.put("000006",
// "000006: The int argument is outside the allowable range (start <= index < end).");
// MESSAGE_MAP.put("000007","000007: The argument should be a directory.");
//
// MESSAGE_MAP.put("000100", "000100: Invalid option combination for git-commit command.");
// MESSAGE_MAP.put("000110", "000110: Invalid option combination for git-add command.");
// MESSAGE_MAP.put("000120", "000120: Invalid option combination for git-branch command.");
// MESSAGE_MAP.put("000130", "000130: Invalid option combination for git-checkout command.");
//
// MESSAGE_MAP.put("020001", "020001: File or path does not exist.");
// MESSAGE_MAP.put("020002", "020002: File or path is not a directory.");
//
// MESSAGE_MAP.put("020100", "020100: Unable to start sub-process.");
// MESSAGE_MAP.put("020101", "020101: Error reading input from the sub-process.");
//
// MESSAGE_MAP.put("100000", "100000: Incorrect refType type.");
// MESSAGE_MAP.put("100001", "100001: Error retrieving git version.");
// MESSAGE_MAP.put("100002", "100002: Invalid path to git specified.");
//
// MESSAGE_MAP.put("401000", "401000: Error calling git-add.");
// MESSAGE_MAP.put("401001", "401001: Error fatal pathspec error while executing git-add.");
//
// MESSAGE_MAP.put("410000", "410000: Error calling git-commit.");
//
// MESSAGE_MAP.put("404000", "404000: Error calling git-branch. ");
//
// MESSAGE_MAP.put("424000", "424000: Error calling git-mv. ");
//
// MESSAGE_MAP.put("424001", "424001: Error calling git-mv for dry-run. ");
//
// MESSAGE_MAP.put("420001", "420001: Error calling git log");
//
// MESSAGE_MAP.put("432000", "432000: Error calling git-reset.");
//
// MESSAGE_MAP.put("418000", "418000: Error calling git init.");
//
// MESSAGE_MAP.put("434000", "434000: Error calling git-rm.");
//
// MESSAGE_MAP.put("406000", "406000: Error calling git-checkout");
// MESSAGE_MAP.put("406001", "406001: Error not a treeIsh RefType");
//
// MESSAGE_MAP.put("438000", "438000: Error calling git-status");
//
// MESSAGE_MAP.put("442001", "442001: No git, or wrong, major version number.");
// MESSAGE_MAP.put("442002", "442002: No git, or wrong, minor version number.");
// MESSAGE_MAP.put("442003", "442003: No git, or wrong, major release version number.");
// MESSAGE_MAP.put("442004", "442004: Wrong minor release version number.");
// }
//
// /**
// * Gets the error message for the specified code.
// *
// * @param code
// * The error code for which to get the associated error message.
// * @return The error message for the specified code.
// */
// public static String getMessage(String code) {
// String str = MESSAGE_MAP.get(code);
// if (null == str) {
// return "NO MESSAGE FOR ERROR CODE. { code=[" + code + "] }";
// }
// return str;
// }
//
// }
// Path: javagit/src/main/java/edu/nyu/cs/javagit/api/commands/GitCommitOptions.java
import edu.nyu.cs.javagit.utilities.ExceptionMessageMap;
}
/**
* Is the --only option set?
*
* @return True if the --only option is set, false if it is not set.
*/
public boolean isOptOnly() {
return optOnly;
}
/**
* Set the value to use as the author name for a commit.
*
* @param author
* The value to use as the author name for a commit.
*/
public void setAuthor(String author) {
this.author = author;
}
/**
* Set the --all option. An <code>IllegalArgumentException</code> is thrown if the only or
* include options are set.
*
* @param optAll
* True to set the --all option, false to unset it.
*/
public void setOptAll(boolean optAll) {
if (optOnly || optInclude) { | throw new IllegalArgumentException(ExceptionMessageMap.getMessage("000100") |
bit-man/SwissArmyJavaGit | javagit/src/test/java/edu/nyu/cs/javagit/api/commands/TestGitMvResponse.java | // Path: javagit/src/test/java/edu/nyu/cs/javagit/TestBase.java
// @Ignore
// public class TestBase extends TestCase {
//
// @Before
// public void setUp() throws IOException, JavaGitException {
// JavaGitConfiguration.setGitPath(TestProperty.GIT_PATH.asString());
// }
// }
//
// Path: javagit/src/test/java/edu/nyu/cs/javagit/utilities/FileUtilities.java
// public class FileUtilities {
//
// /**
// * Create a temp directory based on the supplied directory base name. The directory will be
// * created under the temp directory for the system running the program.
// *
// * @param baseDirName A base name for the directory. If this directory exists, a directory based on this
// * name will be created.
// * @return A <code>File</code> instance representing the created directory.
// */
// public static File createTempDirectory(String baseDirName) throws IOException {
// // Get the system temp directory location.
// File tmpfile = File.createTempFile("AfileName", "tmp");
// String absPath = tmpfile.getAbsolutePath();
// tmpfile.delete();
// int lastSep = absPath.lastIndexOf(File.separatorChar);
// String tmpDir = absPath.substring(0, lastSep + 1);
//
// // System.out.println("Temp Directory: tmpDir=["+ tmpDir + "]");
//
// // Create a temp directory for the caller
// File file = new File(tmpDir + baseDirName);
// int num = 0;
// while (!file.mkdir()) {
// file = new File(tmpDir + baseDirName + Integer.toString(num++));
// }
//
// return file;
// }
//
// /**
// * Create a new file and write the contents to it.
// *
// * @param baseDir The base directory of the repo.
// * @param filePath The relative path to the file with respect to the base directory.
// * @param contents Some contents to write to the file.
// * @return A <code>File</code> object representation of the file.
// * @throws IOException If there are problems creating the file or writing the contents to the file.
// */
// public static File createFile(File baseDir, String filePath, String contents) throws IOException {
// File file = new File(baseDir.getPath() + File.separator + filePath);
// file.createNewFile();
// FileWriter fw = new FileWriter(file);
// fw.write(contents);
// fw.flush();
// fw.close();
// return new File(filePath);
// }
//
// /**
// * Recursively deletes the specified file/directory.
// *
// * @param dirOrFile The file or directory to delete recursively and forcefully.
// * @throws JavaGitException Thrown if a file or directory was not deleted.
// */
// public static void removeDirectoryRecursivelyAndForcefully(File dirOrFile)
// throws JavaGitException {
// File[] children = dirOrFile.listFiles();
// if (null != children) {
// for (File f : children) {
// removeDirectoryRecursivelyAndForcefully(f);
// }
// }
// //System.gc();
// if (!dirOrFile.delete()) {
// throw new JavaGitException(-1, "-1: Unable to delete file/directory. { path=["
// + dirOrFile.getAbsolutePath() + "] }");
// }
// }
//
// /**
// * Append some text to an existing file.
// *
// * @param file File that will be modified
// * @param appendText The text that will be appended to the file
// * @throws FileNotFoundException Exception thrown if the file does not exist.
// * @throws IOException thrown if the IO operation fails.
// */
// public static void modifyFileContents(File file, String appendText) throws FileNotFoundException,
// IOException {
// if (!file.exists()) {
// throw new FileNotFoundException("File does not exist");
// }
// FileWriter fw = new FileWriter(file);
// fw.append(appendText);
// fw.close();
// }
//
// }
| import edu.nyu.cs.javagit.TestBase;
import edu.nyu.cs.javagit.api.JavaGitException;
import edu.nyu.cs.javagit.utilities.FileUtilities;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List; | package edu.nyu.cs.javagit.api.commands;
public class TestGitMvResponse extends TestBase {
private File repoDirectory;
private File source;
private File destination;
private GitAdd gitAdd;
private GitMv gitMv;
private GitCommit gitCommit;
private GitMvOptions options;
private File fileOne;
private File fileTwo;
@Before
public void setUp() throws IOException, JavaGitException {
super.setUp(); | // Path: javagit/src/test/java/edu/nyu/cs/javagit/TestBase.java
// @Ignore
// public class TestBase extends TestCase {
//
// @Before
// public void setUp() throws IOException, JavaGitException {
// JavaGitConfiguration.setGitPath(TestProperty.GIT_PATH.asString());
// }
// }
//
// Path: javagit/src/test/java/edu/nyu/cs/javagit/utilities/FileUtilities.java
// public class FileUtilities {
//
// /**
// * Create a temp directory based on the supplied directory base name. The directory will be
// * created under the temp directory for the system running the program.
// *
// * @param baseDirName A base name for the directory. If this directory exists, a directory based on this
// * name will be created.
// * @return A <code>File</code> instance representing the created directory.
// */
// public static File createTempDirectory(String baseDirName) throws IOException {
// // Get the system temp directory location.
// File tmpfile = File.createTempFile("AfileName", "tmp");
// String absPath = tmpfile.getAbsolutePath();
// tmpfile.delete();
// int lastSep = absPath.lastIndexOf(File.separatorChar);
// String tmpDir = absPath.substring(0, lastSep + 1);
//
// // System.out.println("Temp Directory: tmpDir=["+ tmpDir + "]");
//
// // Create a temp directory for the caller
// File file = new File(tmpDir + baseDirName);
// int num = 0;
// while (!file.mkdir()) {
// file = new File(tmpDir + baseDirName + Integer.toString(num++));
// }
//
// return file;
// }
//
// /**
// * Create a new file and write the contents to it.
// *
// * @param baseDir The base directory of the repo.
// * @param filePath The relative path to the file with respect to the base directory.
// * @param contents Some contents to write to the file.
// * @return A <code>File</code> object representation of the file.
// * @throws IOException If there are problems creating the file or writing the contents to the file.
// */
// public static File createFile(File baseDir, String filePath, String contents) throws IOException {
// File file = new File(baseDir.getPath() + File.separator + filePath);
// file.createNewFile();
// FileWriter fw = new FileWriter(file);
// fw.write(contents);
// fw.flush();
// fw.close();
// return new File(filePath);
// }
//
// /**
// * Recursively deletes the specified file/directory.
// *
// * @param dirOrFile The file or directory to delete recursively and forcefully.
// * @throws JavaGitException Thrown if a file or directory was not deleted.
// */
// public static void removeDirectoryRecursivelyAndForcefully(File dirOrFile)
// throws JavaGitException {
// File[] children = dirOrFile.listFiles();
// if (null != children) {
// for (File f : children) {
// removeDirectoryRecursivelyAndForcefully(f);
// }
// }
// //System.gc();
// if (!dirOrFile.delete()) {
// throw new JavaGitException(-1, "-1: Unable to delete file/directory. { path=["
// + dirOrFile.getAbsolutePath() + "] }");
// }
// }
//
// /**
// * Append some text to an existing file.
// *
// * @param file File that will be modified
// * @param appendText The text that will be appended to the file
// * @throws FileNotFoundException Exception thrown if the file does not exist.
// * @throws IOException thrown if the IO operation fails.
// */
// public static void modifyFileContents(File file, String appendText) throws FileNotFoundException,
// IOException {
// if (!file.exists()) {
// throw new FileNotFoundException("File does not exist");
// }
// FileWriter fw = new FileWriter(file);
// fw.append(appendText);
// fw.close();
// }
//
// }
// Path: javagit/src/test/java/edu/nyu/cs/javagit/api/commands/TestGitMvResponse.java
import edu.nyu.cs.javagit.TestBase;
import edu.nyu.cs.javagit.api.JavaGitException;
import edu.nyu.cs.javagit.utilities.FileUtilities;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
package edu.nyu.cs.javagit.api.commands;
public class TestGitMvResponse extends TestBase {
private File repoDirectory;
private File source;
private File destination;
private GitAdd gitAdd;
private GitMv gitMv;
private GitCommit gitCommit;
private GitMvOptions options;
private File fileOne;
private File fileTwo;
@Before
public void setUp() throws IOException, JavaGitException {
super.setUp(); | repoDirectory = FileUtilities.createTempDirectory("GitMvTestRepo"); |
bit-man/SwissArmyJavaGit | javagit/src/test/java/edu/nyu/cs/javagit/client/cli/TestCliGitAdd.java | // Path: javagit/src/test/java/edu/nyu/cs/javagit/TestBase.java
// @Ignore
// public class TestBase extends TestCase {
//
// @Before
// public void setUp() throws IOException, JavaGitException {
// JavaGitConfiguration.setGitPath(TestProperty.GIT_PATH.asString());
// }
// }
//
// Path: javagit/src/main/java/edu/nyu/cs/javagit/api/commands/GitAddResponse.java
// public abstract class GitAddResponse implements CommandResponse {
//
// /**
// * List of files added to the index by <git-add> command.
// */
// protected List<File> filePathsList;
//
// /**
// * Initially set to true as git-add many times does not generate any output at all. If output is
// * generated then it needs to be set to false. This can be used as a tester whether any output was
// * generated or not.
// */
// protected boolean noOutput;
//
// protected List<ResponseString> comments;
//
// protected boolean dryRun;
//
// /**
// * Constructor
// */
// public GitAddResponse() {
// filePathsList = new ArrayList<File>();
// comments = new ArrayList<ResponseString>();
// noOutput = true;
// dryRun = false;
// }
//
// /**
// * Gets the number of files added.
// *
// * @return size of list.
// */
// public int getFileListSize() {
// return filePathsList.size();
// }
//
// public File get(int index) throws IndexOutOfBoundsException {
// if (index < filePathsList.size() && index >= 0) {
// return filePathsList.get(index);
// }
// throw new IndexOutOfBoundsException(index + " is out of range");
// }
//
// public boolean noOutput() {
// return noOutput;
// }
//
// public boolean dryRun() {
// return dryRun;
// }
//
// public boolean comment() {
// return (comments.size() > 0);
// }
//
// public int nubmerOfComments() {
// return comments.size();
// }
//
// public ResponseString getComment(int index) {
// CheckUtilities.checkIntInRange(index, 0, comments.size());
// return (comments.get(index));
// }
//
// /**
// * For saving errors, warnings and comments related information in the response object. Currently
// * it has only two fields -
// * <ul>
// * <li>Error, warning or general comment string</li>
// * <li>Line number where the string appeared in output</li>
// * <ul>
// */
// public static class ResponseString {
// final String comment;
// final int lineNumber;
//
// public ResponseString(int lineNumber, String comment) {
// this.lineNumber = lineNumber;
// this.comment = comment;
// }
//
// public int getLineNumber() {
// return lineNumber;
// }
//
// public String comment() {
// return comment;
// }
//
// }
// }
| import edu.nyu.cs.javagit.TestBase;
import edu.nyu.cs.javagit.api.JavaGitException;
import edu.nyu.cs.javagit.api.commands.GitAddOptions;
import edu.nyu.cs.javagit.api.commands.GitAddResponse;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List; |
/**
* Test for testing IOException when the given repository path does not exist. This is different
* <code>testGitAddNullRepositoryPath</code> where the repositoryPath is null.
*
* @throws IOException thrown if file paths or repository path provided is found or git command is not found.
*/
@Test(expected = IOException.class)
public void testGitAddIOExceptionThrown() throws IOException, JavaGitException {
try {
CliGitAdd gitAdd = new CliGitAdd();
GitAddOptions options = null;
List<File> fileNames = new ArrayList<File>();
fileNames.add(new File("testFile"));
gitAdd.add(new File("repo/path/should/not/exist"), options, fileNames);
} catch (IOException e) {
return;
}
fail("IOException not thrown");
}
/**
* Test for parsing the a valid output generated after a couple of files are added to the
* repository. The output starts with 'add'.
*/
@Test
public void testGitAddParserValidInput() throws JavaGitException {
CliGitAdd.GitAddParser parser = new CliGitAdd.GitAddParser();
parser.parseLine("add 'test-repository/eg9'");
parser.parseLine("add 'test-repository/testdir/foo'"); | // Path: javagit/src/test/java/edu/nyu/cs/javagit/TestBase.java
// @Ignore
// public class TestBase extends TestCase {
//
// @Before
// public void setUp() throws IOException, JavaGitException {
// JavaGitConfiguration.setGitPath(TestProperty.GIT_PATH.asString());
// }
// }
//
// Path: javagit/src/main/java/edu/nyu/cs/javagit/api/commands/GitAddResponse.java
// public abstract class GitAddResponse implements CommandResponse {
//
// /**
// * List of files added to the index by <git-add> command.
// */
// protected List<File> filePathsList;
//
// /**
// * Initially set to true as git-add many times does not generate any output at all. If output is
// * generated then it needs to be set to false. This can be used as a tester whether any output was
// * generated or not.
// */
// protected boolean noOutput;
//
// protected List<ResponseString> comments;
//
// protected boolean dryRun;
//
// /**
// * Constructor
// */
// public GitAddResponse() {
// filePathsList = new ArrayList<File>();
// comments = new ArrayList<ResponseString>();
// noOutput = true;
// dryRun = false;
// }
//
// /**
// * Gets the number of files added.
// *
// * @return size of list.
// */
// public int getFileListSize() {
// return filePathsList.size();
// }
//
// public File get(int index) throws IndexOutOfBoundsException {
// if (index < filePathsList.size() && index >= 0) {
// return filePathsList.get(index);
// }
// throw new IndexOutOfBoundsException(index + " is out of range");
// }
//
// public boolean noOutput() {
// return noOutput;
// }
//
// public boolean dryRun() {
// return dryRun;
// }
//
// public boolean comment() {
// return (comments.size() > 0);
// }
//
// public int nubmerOfComments() {
// return comments.size();
// }
//
// public ResponseString getComment(int index) {
// CheckUtilities.checkIntInRange(index, 0, comments.size());
// return (comments.get(index));
// }
//
// /**
// * For saving errors, warnings and comments related information in the response object. Currently
// * it has only two fields -
// * <ul>
// * <li>Error, warning or general comment string</li>
// * <li>Line number where the string appeared in output</li>
// * <ul>
// */
// public static class ResponseString {
// final String comment;
// final int lineNumber;
//
// public ResponseString(int lineNumber, String comment) {
// this.lineNumber = lineNumber;
// this.comment = comment;
// }
//
// public int getLineNumber() {
// return lineNumber;
// }
//
// public String comment() {
// return comment;
// }
//
// }
// }
// Path: javagit/src/test/java/edu/nyu/cs/javagit/client/cli/TestCliGitAdd.java
import edu.nyu.cs.javagit.TestBase;
import edu.nyu.cs.javagit.api.JavaGitException;
import edu.nyu.cs.javagit.api.commands.GitAddOptions;
import edu.nyu.cs.javagit.api.commands.GitAddResponse;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/**
* Test for testing IOException when the given repository path does not exist. This is different
* <code>testGitAddNullRepositoryPath</code> where the repositoryPath is null.
*
* @throws IOException thrown if file paths or repository path provided is found or git command is not found.
*/
@Test(expected = IOException.class)
public void testGitAddIOExceptionThrown() throws IOException, JavaGitException {
try {
CliGitAdd gitAdd = new CliGitAdd();
GitAddOptions options = null;
List<File> fileNames = new ArrayList<File>();
fileNames.add(new File("testFile"));
gitAdd.add(new File("repo/path/should/not/exist"), options, fileNames);
} catch (IOException e) {
return;
}
fail("IOException not thrown");
}
/**
* Test for parsing the a valid output generated after a couple of files are added to the
* repository. The output starts with 'add'.
*/
@Test
public void testGitAddParserValidInput() throws JavaGitException {
CliGitAdd.GitAddParser parser = new CliGitAdd.GitAddParser();
parser.parseLine("add 'test-repository/eg9'");
parser.parseLine("add 'test-repository/testdir/foo'"); | GitAddResponse response = parser.getResponse(); |
bit-man/SwissArmyJavaGit | javagit/src/test/java/edu/nyu/cs/javagit/api/commands/TestGitAdd.java | // Path: javagit/src/test/java/edu/nyu/cs/javagit/TestBase.java
// @Ignore
// public class TestBase extends TestCase {
//
// @Before
// public void setUp() throws IOException, JavaGitException {
// JavaGitConfiguration.setGitPath(TestProperty.GIT_PATH.asString());
// }
// }
//
// Path: javagit/src/test/java/edu/nyu/cs/javagit/utilities/FileUtilities.java
// public class FileUtilities {
//
// /**
// * Create a temp directory based on the supplied directory base name. The directory will be
// * created under the temp directory for the system running the program.
// *
// * @param baseDirName A base name for the directory. If this directory exists, a directory based on this
// * name will be created.
// * @return A <code>File</code> instance representing the created directory.
// */
// public static File createTempDirectory(String baseDirName) throws IOException {
// // Get the system temp directory location.
// File tmpfile = File.createTempFile("AfileName", "tmp");
// String absPath = tmpfile.getAbsolutePath();
// tmpfile.delete();
// int lastSep = absPath.lastIndexOf(File.separatorChar);
// String tmpDir = absPath.substring(0, lastSep + 1);
//
// // System.out.println("Temp Directory: tmpDir=["+ tmpDir + "]");
//
// // Create a temp directory for the caller
// File file = new File(tmpDir + baseDirName);
// int num = 0;
// while (!file.mkdir()) {
// file = new File(tmpDir + baseDirName + Integer.toString(num++));
// }
//
// return file;
// }
//
// /**
// * Create a new file and write the contents to it.
// *
// * @param baseDir The base directory of the repo.
// * @param filePath The relative path to the file with respect to the base directory.
// * @param contents Some contents to write to the file.
// * @return A <code>File</code> object representation of the file.
// * @throws IOException If there are problems creating the file or writing the contents to the file.
// */
// public static File createFile(File baseDir, String filePath, String contents) throws IOException {
// File file = new File(baseDir.getPath() + File.separator + filePath);
// file.createNewFile();
// FileWriter fw = new FileWriter(file);
// fw.write(contents);
// fw.flush();
// fw.close();
// return new File(filePath);
// }
//
// /**
// * Recursively deletes the specified file/directory.
// *
// * @param dirOrFile The file or directory to delete recursively and forcefully.
// * @throws JavaGitException Thrown if a file or directory was not deleted.
// */
// public static void removeDirectoryRecursivelyAndForcefully(File dirOrFile)
// throws JavaGitException {
// File[] children = dirOrFile.listFiles();
// if (null != children) {
// for (File f : children) {
// removeDirectoryRecursivelyAndForcefully(f);
// }
// }
// //System.gc();
// if (!dirOrFile.delete()) {
// throw new JavaGitException(-1, "-1: Unable to delete file/directory. { path=["
// + dirOrFile.getAbsolutePath() + "] }");
// }
// }
//
// /**
// * Append some text to an existing file.
// *
// * @param file File that will be modified
// * @param appendText The text that will be appended to the file
// * @throws FileNotFoundException Exception thrown if the file does not exist.
// * @throws IOException thrown if the IO operation fails.
// */
// public static void modifyFileContents(File file, String appendText) throws FileNotFoundException,
// IOException {
// if (!file.exists()) {
// throw new FileNotFoundException("File does not exist");
// }
// FileWriter fw = new FileWriter(file);
// fw.append(appendText);
// fw.close();
// }
//
// }
| import edu.nyu.cs.javagit.TestBase;
import edu.nyu.cs.javagit.api.JavaGitException;
import edu.nyu.cs.javagit.utilities.FileUtilities;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List; | /*
* ====================================================================
* Copyright (c) 2008 JavaGit Project. All rights reserved.
*
* This software is licensed using the GNU LGPL v2.1 license. A copy
* of the license is included with the distribution of this source
* code in the LICENSE.txt file. The text of the license can also
* be obtained at:
*
* http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
*
* For more information on the JavaGit project, see:
*
* http://www.javagit.com
* ====================================================================
*/
package edu.nyu.cs.javagit.api.commands;
public class TestGitAdd extends TestBase {
File repoDirectory;
GitAdd gitAdd;
GitStatus gitStatus;
@Before
public void setUp() throws IOException, JavaGitException {
super.setUp(); | // Path: javagit/src/test/java/edu/nyu/cs/javagit/TestBase.java
// @Ignore
// public class TestBase extends TestCase {
//
// @Before
// public void setUp() throws IOException, JavaGitException {
// JavaGitConfiguration.setGitPath(TestProperty.GIT_PATH.asString());
// }
// }
//
// Path: javagit/src/test/java/edu/nyu/cs/javagit/utilities/FileUtilities.java
// public class FileUtilities {
//
// /**
// * Create a temp directory based on the supplied directory base name. The directory will be
// * created under the temp directory for the system running the program.
// *
// * @param baseDirName A base name for the directory. If this directory exists, a directory based on this
// * name will be created.
// * @return A <code>File</code> instance representing the created directory.
// */
// public static File createTempDirectory(String baseDirName) throws IOException {
// // Get the system temp directory location.
// File tmpfile = File.createTempFile("AfileName", "tmp");
// String absPath = tmpfile.getAbsolutePath();
// tmpfile.delete();
// int lastSep = absPath.lastIndexOf(File.separatorChar);
// String tmpDir = absPath.substring(0, lastSep + 1);
//
// // System.out.println("Temp Directory: tmpDir=["+ tmpDir + "]");
//
// // Create a temp directory for the caller
// File file = new File(tmpDir + baseDirName);
// int num = 0;
// while (!file.mkdir()) {
// file = new File(tmpDir + baseDirName + Integer.toString(num++));
// }
//
// return file;
// }
//
// /**
// * Create a new file and write the contents to it.
// *
// * @param baseDir The base directory of the repo.
// * @param filePath The relative path to the file with respect to the base directory.
// * @param contents Some contents to write to the file.
// * @return A <code>File</code> object representation of the file.
// * @throws IOException If there are problems creating the file or writing the contents to the file.
// */
// public static File createFile(File baseDir, String filePath, String contents) throws IOException {
// File file = new File(baseDir.getPath() + File.separator + filePath);
// file.createNewFile();
// FileWriter fw = new FileWriter(file);
// fw.write(contents);
// fw.flush();
// fw.close();
// return new File(filePath);
// }
//
// /**
// * Recursively deletes the specified file/directory.
// *
// * @param dirOrFile The file or directory to delete recursively and forcefully.
// * @throws JavaGitException Thrown if a file or directory was not deleted.
// */
// public static void removeDirectoryRecursivelyAndForcefully(File dirOrFile)
// throws JavaGitException {
// File[] children = dirOrFile.listFiles();
// if (null != children) {
// for (File f : children) {
// removeDirectoryRecursivelyAndForcefully(f);
// }
// }
// //System.gc();
// if (!dirOrFile.delete()) {
// throw new JavaGitException(-1, "-1: Unable to delete file/directory. { path=["
// + dirOrFile.getAbsolutePath() + "] }");
// }
// }
//
// /**
// * Append some text to an existing file.
// *
// * @param file File that will be modified
// * @param appendText The text that will be appended to the file
// * @throws FileNotFoundException Exception thrown if the file does not exist.
// * @throws IOException thrown if the IO operation fails.
// */
// public static void modifyFileContents(File file, String appendText) throws FileNotFoundException,
// IOException {
// if (!file.exists()) {
// throw new FileNotFoundException("File does not exist");
// }
// FileWriter fw = new FileWriter(file);
// fw.append(appendText);
// fw.close();
// }
//
// }
// Path: javagit/src/test/java/edu/nyu/cs/javagit/api/commands/TestGitAdd.java
import edu.nyu.cs.javagit.TestBase;
import edu.nyu.cs.javagit.api.JavaGitException;
import edu.nyu.cs.javagit.utilities.FileUtilities;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/*
* ====================================================================
* Copyright (c) 2008 JavaGit Project. All rights reserved.
*
* This software is licensed using the GNU LGPL v2.1 license. A copy
* of the license is included with the distribution of this source
* code in the LICENSE.txt file. The text of the license can also
* be obtained at:
*
* http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
*
* For more information on the JavaGit project, see:
*
* http://www.javagit.com
* ====================================================================
*/
package edu.nyu.cs.javagit.api.commands;
public class TestGitAdd extends TestBase {
File repoDirectory;
GitAdd gitAdd;
GitStatus gitStatus;
@Before
public void setUp() throws IOException, JavaGitException {
super.setUp(); | repoDirectory = FileUtilities.createTempDirectory("GitCommitTestRepo"); |
bit-man/SwissArmyJavaGit | javagit/src/main/java/edu/nyu/cs/javagit/client/ClientManager.java | // Path: javagit/src/main/java/edu/nyu/cs/javagit/client/cli/CliClient.java
// public class CliClient implements IClient {
//
// public IGitAdd getGitAddInstance() {
// return new CliGitAdd();
// }
//
// public IGitCommit getGitCommitInstance() {
// return new CliGitCommit();
// }
//
// public IGitDiff getGitDiffInstance() {
// return new CliGitDiff();
// }
//
// public IGitGrep getGitGrepInstance() {
// return new CliGitGrep();
// }
//
// public IGitLog getGitLogInstance() {
// return new CliGitLog();
// }
//
// public IGitMv getGitMvInstance() {
// return new CliGitMv();
// }
//
// public IGitReset getGitResetInstance() {
// return new CliGitReset();
// }
//
// public IGitRevert getGitRevertInstance() {
// return new CliGitRevert();
// }
//
// public IGitRm getGitRmInstance() {
// return new CliGitRm();
// }
//
// public IGitShow getGitShowInstance() {
// return new CliGitShow();
// }
//
// public IGitStatus getGitStatusInstance() {
// return new CliGitStatus();
// }
//
// public IGitBranch getGitBranchInstance() {
// return new CliGitBranch();
// }
//
// public IGitCheckout getGitCheckoutInstance() {
// return new CliGitCheckout();
// }
//
// public IGitInit getGitInitInstance() {
// return new CliGitInit();
// }
//
// public IGitClone getGitCloneInstance() {
// return new CliGitClone();
// }
//
// }
| import java.util.HashMap;
import java.util.Map;
import edu.nyu.cs.javagit.client.cli.CliClient; | /*
* ====================================================================
* Copyright (c) 2008 JavaGit Project. All rights reserved.
*
* This software is licensed using the GNU LGPL v2.1 license. A copy
* of the license is included with the distribution of this source
* code in the LICENSE.txt file. The text of the license can also
* be obtained at:
*
* http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
*
* For more information on the JavaGit project, see:
*
* http://www.javagit.com
* ====================================================================
*/
package edu.nyu.cs.javagit.client;
/**
* This class manages the <code>IClient</code> instances of the various <code>ClientType</code>s.
* It contains factory type functionality (the <code>getClientType()</code> method) but manages
* much more than just creating <code>IClient</code> instances.
*/
public class ClientManager {
// An enumeration of the available client types.
public static enum ClientType {
CLI
};
// The singleton instance of the class <code>ClientManager</code>.
private static ClientManager INSTANCE = new ClientManager();
/**
* Gets the singleton instance.
*
* @return The singleton instance.
*/
public static ClientManager getInstance() {
return INSTANCE;
}
// The preferred client type.
private ClientType preferredClientType = ClientType.CLI;
/**
* A <code>Map</code> to hold <code>IClient</code> instances for the ClientTypes by
* <code>ClientType</code>.
*/
private Map<ClientType, IClient> clientImpls = new HashMap<ClientType, IClient>();
/**
* Private to make this class a singleton.
*/
private ClientManager() {
}
/**
* Gets an instance of the specified client type.
*
* @param clientType
* The type of client to get.
* @return An instance of the specified client type.
*/
public IClient getClientInstance(ClientType clientType) {
IClient clientInstance = clientImpls.get(clientType);
if (null == clientInstance) {
if (ClientType.CLI == clientType) { | // Path: javagit/src/main/java/edu/nyu/cs/javagit/client/cli/CliClient.java
// public class CliClient implements IClient {
//
// public IGitAdd getGitAddInstance() {
// return new CliGitAdd();
// }
//
// public IGitCommit getGitCommitInstance() {
// return new CliGitCommit();
// }
//
// public IGitDiff getGitDiffInstance() {
// return new CliGitDiff();
// }
//
// public IGitGrep getGitGrepInstance() {
// return new CliGitGrep();
// }
//
// public IGitLog getGitLogInstance() {
// return new CliGitLog();
// }
//
// public IGitMv getGitMvInstance() {
// return new CliGitMv();
// }
//
// public IGitReset getGitResetInstance() {
// return new CliGitReset();
// }
//
// public IGitRevert getGitRevertInstance() {
// return new CliGitRevert();
// }
//
// public IGitRm getGitRmInstance() {
// return new CliGitRm();
// }
//
// public IGitShow getGitShowInstance() {
// return new CliGitShow();
// }
//
// public IGitStatus getGitStatusInstance() {
// return new CliGitStatus();
// }
//
// public IGitBranch getGitBranchInstance() {
// return new CliGitBranch();
// }
//
// public IGitCheckout getGitCheckoutInstance() {
// return new CliGitCheckout();
// }
//
// public IGitInit getGitInitInstance() {
// return new CliGitInit();
// }
//
// public IGitClone getGitCloneInstance() {
// return new CliGitClone();
// }
//
// }
// Path: javagit/src/main/java/edu/nyu/cs/javagit/client/ClientManager.java
import java.util.HashMap;
import java.util.Map;
import edu.nyu.cs.javagit.client.cli.CliClient;
/*
* ====================================================================
* Copyright (c) 2008 JavaGit Project. All rights reserved.
*
* This software is licensed using the GNU LGPL v2.1 license. A copy
* of the license is included with the distribution of this source
* code in the LICENSE.txt file. The text of the license can also
* be obtained at:
*
* http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
*
* For more information on the JavaGit project, see:
*
* http://www.javagit.com
* ====================================================================
*/
package edu.nyu.cs.javagit.client;
/**
* This class manages the <code>IClient</code> instances of the various <code>ClientType</code>s.
* It contains factory type functionality (the <code>getClientType()</code> method) but manages
* much more than just creating <code>IClient</code> instances.
*/
public class ClientManager {
// An enumeration of the available client types.
public static enum ClientType {
CLI
};
// The singleton instance of the class <code>ClientManager</code>.
private static ClientManager INSTANCE = new ClientManager();
/**
* Gets the singleton instance.
*
* @return The singleton instance.
*/
public static ClientManager getInstance() {
return INSTANCE;
}
// The preferred client type.
private ClientType preferredClientType = ClientType.CLI;
/**
* A <code>Map</code> to hold <code>IClient</code> instances for the ClientTypes by
* <code>ClientType</code>.
*/
private Map<ClientType, IClient> clientImpls = new HashMap<ClientType, IClient>();
/**
* Private to make this class a singleton.
*/
private ClientManager() {
}
/**
* Gets an instance of the specified client type.
*
* @param clientType
* The type of client to get.
* @return An instance of the specified client type.
*/
public IClient getClientInstance(ClientType clientType) {
IClient clientInstance = clientImpls.get(clientType);
if (null == clientInstance) {
if (ClientType.CLI == clientType) { | clientInstance = new CliClient(); |
bit-man/SwissArmyJavaGit | javagit/src/test/java/edu/nyu/cs/javagit/api/TestJavaGitConfiguration.java | // Path: javagit/src/test/java/edu/nyu/cs/javagit/TestBase.java
// @Ignore
// public class TestBase extends TestCase {
//
// @Before
// public void setUp() throws IOException, JavaGitException {
// JavaGitConfiguration.setGitPath(TestProperty.GIT_PATH.asString());
// }
// }
//
// Path: javagit/src/test/java/edu/nyu/cs/javagit/test/utilities/TestErrorException.java
// public class TestErrorException extends Throwable {
// public TestErrorException(Exception e) {
// super(e);
// }
//
// public TestErrorException(String s, Exception e) {
// super(s,e);
// }
// }
//
// Path: javagit/src/test/java/edu/nyu/cs/javagit/utilities/FileUtilities.java
// public class FileUtilities {
//
// /**
// * Create a temp directory based on the supplied directory base name. The directory will be
// * created under the temp directory for the system running the program.
// *
// * @param baseDirName A base name for the directory. If this directory exists, a directory based on this
// * name will be created.
// * @return A <code>File</code> instance representing the created directory.
// */
// public static File createTempDirectory(String baseDirName) throws IOException {
// // Get the system temp directory location.
// File tmpfile = File.createTempFile("AfileName", "tmp");
// String absPath = tmpfile.getAbsolutePath();
// tmpfile.delete();
// int lastSep = absPath.lastIndexOf(File.separatorChar);
// String tmpDir = absPath.substring(0, lastSep + 1);
//
// // System.out.println("Temp Directory: tmpDir=["+ tmpDir + "]");
//
// // Create a temp directory for the caller
// File file = new File(tmpDir + baseDirName);
// int num = 0;
// while (!file.mkdir()) {
// file = new File(tmpDir + baseDirName + Integer.toString(num++));
// }
//
// return file;
// }
//
// /**
// * Create a new file and write the contents to it.
// *
// * @param baseDir The base directory of the repo.
// * @param filePath The relative path to the file with respect to the base directory.
// * @param contents Some contents to write to the file.
// * @return A <code>File</code> object representation of the file.
// * @throws IOException If there are problems creating the file or writing the contents to the file.
// */
// public static File createFile(File baseDir, String filePath, String contents) throws IOException {
// File file = new File(baseDir.getPath() + File.separator + filePath);
// file.createNewFile();
// FileWriter fw = new FileWriter(file);
// fw.write(contents);
// fw.flush();
// fw.close();
// return new File(filePath);
// }
//
// /**
// * Recursively deletes the specified file/directory.
// *
// * @param dirOrFile The file or directory to delete recursively and forcefully.
// * @throws JavaGitException Thrown if a file or directory was not deleted.
// */
// public static void removeDirectoryRecursivelyAndForcefully(File dirOrFile)
// throws JavaGitException {
// File[] children = dirOrFile.listFiles();
// if (null != children) {
// for (File f : children) {
// removeDirectoryRecursivelyAndForcefully(f);
// }
// }
// //System.gc();
// if (!dirOrFile.delete()) {
// throw new JavaGitException(-1, "-1: Unable to delete file/directory. { path=["
// + dirOrFile.getAbsolutePath() + "] }");
// }
// }
//
// /**
// * Append some text to an existing file.
// *
// * @param file File that will be modified
// * @param appendText The text that will be appended to the file
// * @throws FileNotFoundException Exception thrown if the file does not exist.
// * @throws IOException thrown if the IO operation fails.
// */
// public static void modifyFileContents(File file, String appendText) throws FileNotFoundException,
// IOException {
// if (!file.exists()) {
// throw new FileNotFoundException("File does not exist");
// }
// FileWriter fw = new FileWriter(file);
// fw.append(appendText);
// fw.close();
// }
//
// }
//
// Path: javagit/src/test/java/edu/nyu/cs/javagit/utilities/TestProperty.java
// public enum TestProperty {
// GIT_PATH("javagit.test.gitpath", "/usr/bin");
//
// private final String value;
// private final String property;
//
// TestProperty(String property, String defaultValue) {
// this.property = property;
// this.value = System.getProperty(property, defaultValue);
// }
//
// public String asString() {
// return value;
// }
//
// public String getName() {
// return property;
// }
// }
| import edu.nyu.cs.javagit.TestBase;
import edu.nyu.cs.javagit.test.utilities.TestErrorException;
import edu.nyu.cs.javagit.utilities.FileUtilities;
import edu.nyu.cs.javagit.utilities.TestProperty;
import org.junit.Test;
import java.io.File;
import java.io.IOException; | }
// Attempting to set an empty path as a File should generate an IOException.
pathFile = new File("");
try {
JavaGitConfiguration.setGitPath(pathFile);
fail("Invalid path - this should never be reached.");
} catch (IOException e) {
// This is fine.
} catch (Exception e) {
fail("Empty path (String) generated wrong kind of exception: " + e.getClass().getName());
}
// Let's create a temp file and try to set that as the path. Should throw a JavaGitException.
try {
pathFile = File.createTempFile("xyz", null);
JavaGitConfiguration.setGitPath(pathFile);
fail("Invalid path - this should never be reached.");
} catch (JavaGitException e) {
assertEquals(e.getCode(), 020002);
pathFile.delete();
} catch (Exception e) {
fail("Non-directory path (File) generated wrong kind of exception: " + e.getClass().getName());
}
/*
* Let's create a temp dir and try to set that as the path. It won't contain git, so it should
* throw a JavaGitException.
*/
try { | // Path: javagit/src/test/java/edu/nyu/cs/javagit/TestBase.java
// @Ignore
// public class TestBase extends TestCase {
//
// @Before
// public void setUp() throws IOException, JavaGitException {
// JavaGitConfiguration.setGitPath(TestProperty.GIT_PATH.asString());
// }
// }
//
// Path: javagit/src/test/java/edu/nyu/cs/javagit/test/utilities/TestErrorException.java
// public class TestErrorException extends Throwable {
// public TestErrorException(Exception e) {
// super(e);
// }
//
// public TestErrorException(String s, Exception e) {
// super(s,e);
// }
// }
//
// Path: javagit/src/test/java/edu/nyu/cs/javagit/utilities/FileUtilities.java
// public class FileUtilities {
//
// /**
// * Create a temp directory based on the supplied directory base name. The directory will be
// * created under the temp directory for the system running the program.
// *
// * @param baseDirName A base name for the directory. If this directory exists, a directory based on this
// * name will be created.
// * @return A <code>File</code> instance representing the created directory.
// */
// public static File createTempDirectory(String baseDirName) throws IOException {
// // Get the system temp directory location.
// File tmpfile = File.createTempFile("AfileName", "tmp");
// String absPath = tmpfile.getAbsolutePath();
// tmpfile.delete();
// int lastSep = absPath.lastIndexOf(File.separatorChar);
// String tmpDir = absPath.substring(0, lastSep + 1);
//
// // System.out.println("Temp Directory: tmpDir=["+ tmpDir + "]");
//
// // Create a temp directory for the caller
// File file = new File(tmpDir + baseDirName);
// int num = 0;
// while (!file.mkdir()) {
// file = new File(tmpDir + baseDirName + Integer.toString(num++));
// }
//
// return file;
// }
//
// /**
// * Create a new file and write the contents to it.
// *
// * @param baseDir The base directory of the repo.
// * @param filePath The relative path to the file with respect to the base directory.
// * @param contents Some contents to write to the file.
// * @return A <code>File</code> object representation of the file.
// * @throws IOException If there are problems creating the file or writing the contents to the file.
// */
// public static File createFile(File baseDir, String filePath, String contents) throws IOException {
// File file = new File(baseDir.getPath() + File.separator + filePath);
// file.createNewFile();
// FileWriter fw = new FileWriter(file);
// fw.write(contents);
// fw.flush();
// fw.close();
// return new File(filePath);
// }
//
// /**
// * Recursively deletes the specified file/directory.
// *
// * @param dirOrFile The file or directory to delete recursively and forcefully.
// * @throws JavaGitException Thrown if a file or directory was not deleted.
// */
// public static void removeDirectoryRecursivelyAndForcefully(File dirOrFile)
// throws JavaGitException {
// File[] children = dirOrFile.listFiles();
// if (null != children) {
// for (File f : children) {
// removeDirectoryRecursivelyAndForcefully(f);
// }
// }
// //System.gc();
// if (!dirOrFile.delete()) {
// throw new JavaGitException(-1, "-1: Unable to delete file/directory. { path=["
// + dirOrFile.getAbsolutePath() + "] }");
// }
// }
//
// /**
// * Append some text to an existing file.
// *
// * @param file File that will be modified
// * @param appendText The text that will be appended to the file
// * @throws FileNotFoundException Exception thrown if the file does not exist.
// * @throws IOException thrown if the IO operation fails.
// */
// public static void modifyFileContents(File file, String appendText) throws FileNotFoundException,
// IOException {
// if (!file.exists()) {
// throw new FileNotFoundException("File does not exist");
// }
// FileWriter fw = new FileWriter(file);
// fw.append(appendText);
// fw.close();
// }
//
// }
//
// Path: javagit/src/test/java/edu/nyu/cs/javagit/utilities/TestProperty.java
// public enum TestProperty {
// GIT_PATH("javagit.test.gitpath", "/usr/bin");
//
// private final String value;
// private final String property;
//
// TestProperty(String property, String defaultValue) {
// this.property = property;
// this.value = System.getProperty(property, defaultValue);
// }
//
// public String asString() {
// return value;
// }
//
// public String getName() {
// return property;
// }
// }
// Path: javagit/src/test/java/edu/nyu/cs/javagit/api/TestJavaGitConfiguration.java
import edu.nyu.cs.javagit.TestBase;
import edu.nyu.cs.javagit.test.utilities.TestErrorException;
import edu.nyu.cs.javagit.utilities.FileUtilities;
import edu.nyu.cs.javagit.utilities.TestProperty;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
}
// Attempting to set an empty path as a File should generate an IOException.
pathFile = new File("");
try {
JavaGitConfiguration.setGitPath(pathFile);
fail("Invalid path - this should never be reached.");
} catch (IOException e) {
// This is fine.
} catch (Exception e) {
fail("Empty path (String) generated wrong kind of exception: " + e.getClass().getName());
}
// Let's create a temp file and try to set that as the path. Should throw a JavaGitException.
try {
pathFile = File.createTempFile("xyz", null);
JavaGitConfiguration.setGitPath(pathFile);
fail("Invalid path - this should never be reached.");
} catch (JavaGitException e) {
assertEquals(e.getCode(), 020002);
pathFile.delete();
} catch (Exception e) {
fail("Non-directory path (File) generated wrong kind of exception: " + e.getClass().getName());
}
/*
* Let's create a temp dir and try to set that as the path. It won't contain git, so it should
* throw a JavaGitException.
*/
try { | pathFile = FileUtilities.createTempDirectory("abc"); |
bit-man/SwissArmyJavaGit | javagit/src/test/java/edu/nyu/cs/javagit/api/TestJavaGitConfiguration.java | // Path: javagit/src/test/java/edu/nyu/cs/javagit/TestBase.java
// @Ignore
// public class TestBase extends TestCase {
//
// @Before
// public void setUp() throws IOException, JavaGitException {
// JavaGitConfiguration.setGitPath(TestProperty.GIT_PATH.asString());
// }
// }
//
// Path: javagit/src/test/java/edu/nyu/cs/javagit/test/utilities/TestErrorException.java
// public class TestErrorException extends Throwable {
// public TestErrorException(Exception e) {
// super(e);
// }
//
// public TestErrorException(String s, Exception e) {
// super(s,e);
// }
// }
//
// Path: javagit/src/test/java/edu/nyu/cs/javagit/utilities/FileUtilities.java
// public class FileUtilities {
//
// /**
// * Create a temp directory based on the supplied directory base name. The directory will be
// * created under the temp directory for the system running the program.
// *
// * @param baseDirName A base name for the directory. If this directory exists, a directory based on this
// * name will be created.
// * @return A <code>File</code> instance representing the created directory.
// */
// public static File createTempDirectory(String baseDirName) throws IOException {
// // Get the system temp directory location.
// File tmpfile = File.createTempFile("AfileName", "tmp");
// String absPath = tmpfile.getAbsolutePath();
// tmpfile.delete();
// int lastSep = absPath.lastIndexOf(File.separatorChar);
// String tmpDir = absPath.substring(0, lastSep + 1);
//
// // System.out.println("Temp Directory: tmpDir=["+ tmpDir + "]");
//
// // Create a temp directory for the caller
// File file = new File(tmpDir + baseDirName);
// int num = 0;
// while (!file.mkdir()) {
// file = new File(tmpDir + baseDirName + Integer.toString(num++));
// }
//
// return file;
// }
//
// /**
// * Create a new file and write the contents to it.
// *
// * @param baseDir The base directory of the repo.
// * @param filePath The relative path to the file with respect to the base directory.
// * @param contents Some contents to write to the file.
// * @return A <code>File</code> object representation of the file.
// * @throws IOException If there are problems creating the file or writing the contents to the file.
// */
// public static File createFile(File baseDir, String filePath, String contents) throws IOException {
// File file = new File(baseDir.getPath() + File.separator + filePath);
// file.createNewFile();
// FileWriter fw = new FileWriter(file);
// fw.write(contents);
// fw.flush();
// fw.close();
// return new File(filePath);
// }
//
// /**
// * Recursively deletes the specified file/directory.
// *
// * @param dirOrFile The file or directory to delete recursively and forcefully.
// * @throws JavaGitException Thrown if a file or directory was not deleted.
// */
// public static void removeDirectoryRecursivelyAndForcefully(File dirOrFile)
// throws JavaGitException {
// File[] children = dirOrFile.listFiles();
// if (null != children) {
// for (File f : children) {
// removeDirectoryRecursivelyAndForcefully(f);
// }
// }
// //System.gc();
// if (!dirOrFile.delete()) {
// throw new JavaGitException(-1, "-1: Unable to delete file/directory. { path=["
// + dirOrFile.getAbsolutePath() + "] }");
// }
// }
//
// /**
// * Append some text to an existing file.
// *
// * @param file File that will be modified
// * @param appendText The text that will be appended to the file
// * @throws FileNotFoundException Exception thrown if the file does not exist.
// * @throws IOException thrown if the IO operation fails.
// */
// public static void modifyFileContents(File file, String appendText) throws FileNotFoundException,
// IOException {
// if (!file.exists()) {
// throw new FileNotFoundException("File does not exist");
// }
// FileWriter fw = new FileWriter(file);
// fw.append(appendText);
// fw.close();
// }
//
// }
//
// Path: javagit/src/test/java/edu/nyu/cs/javagit/utilities/TestProperty.java
// public enum TestProperty {
// GIT_PATH("javagit.test.gitpath", "/usr/bin");
//
// private final String value;
// private final String property;
//
// TestProperty(String property, String defaultValue) {
// this.property = property;
// this.value = System.getProperty(property, defaultValue);
// }
//
// public String asString() {
// return value;
// }
//
// public String getName() {
// return property;
// }
// }
| import edu.nyu.cs.javagit.TestBase;
import edu.nyu.cs.javagit.test.utilities.TestErrorException;
import edu.nyu.cs.javagit.utilities.FileUtilities;
import edu.nyu.cs.javagit.utilities.TestProperty;
import org.junit.Test;
import java.io.File;
import java.io.IOException; | fail("Invalid path - this should never be reached.");
} catch (JavaGitException e) {
assertEquals(e.getCode(), 100002);
pathFile.delete();
} catch (Exception e) {
fail("Temp path not containing git generated wrong kind of exception: "
+ e.getClass().getName());
}
/*
* Set the path using null as the File argument. This is valid - it's saying: wipe out whatever
* was set before (via previous calls to setGitPath) and just look on the PATH for git.
*/
pathFile = null;
try {
JavaGitConfiguration.setGitPath(pathFile);
} catch (Exception e) {
fail("Null path (File) generated exception: " + e.getClass().getName());
}
// Grab the version and see if we can get it exception-free.
String version = "";
try {
version = JavaGitConfiguration.getGitVersion();
} catch (Exception e) {
fail("Couldn't get git version string - saw \"" + version + "\" and got exception: "
+ e.getClass().getName());
}
}
| // Path: javagit/src/test/java/edu/nyu/cs/javagit/TestBase.java
// @Ignore
// public class TestBase extends TestCase {
//
// @Before
// public void setUp() throws IOException, JavaGitException {
// JavaGitConfiguration.setGitPath(TestProperty.GIT_PATH.asString());
// }
// }
//
// Path: javagit/src/test/java/edu/nyu/cs/javagit/test/utilities/TestErrorException.java
// public class TestErrorException extends Throwable {
// public TestErrorException(Exception e) {
// super(e);
// }
//
// public TestErrorException(String s, Exception e) {
// super(s,e);
// }
// }
//
// Path: javagit/src/test/java/edu/nyu/cs/javagit/utilities/FileUtilities.java
// public class FileUtilities {
//
// /**
// * Create a temp directory based on the supplied directory base name. The directory will be
// * created under the temp directory for the system running the program.
// *
// * @param baseDirName A base name for the directory. If this directory exists, a directory based on this
// * name will be created.
// * @return A <code>File</code> instance representing the created directory.
// */
// public static File createTempDirectory(String baseDirName) throws IOException {
// // Get the system temp directory location.
// File tmpfile = File.createTempFile("AfileName", "tmp");
// String absPath = tmpfile.getAbsolutePath();
// tmpfile.delete();
// int lastSep = absPath.lastIndexOf(File.separatorChar);
// String tmpDir = absPath.substring(0, lastSep + 1);
//
// // System.out.println("Temp Directory: tmpDir=["+ tmpDir + "]");
//
// // Create a temp directory for the caller
// File file = new File(tmpDir + baseDirName);
// int num = 0;
// while (!file.mkdir()) {
// file = new File(tmpDir + baseDirName + Integer.toString(num++));
// }
//
// return file;
// }
//
// /**
// * Create a new file and write the contents to it.
// *
// * @param baseDir The base directory of the repo.
// * @param filePath The relative path to the file with respect to the base directory.
// * @param contents Some contents to write to the file.
// * @return A <code>File</code> object representation of the file.
// * @throws IOException If there are problems creating the file or writing the contents to the file.
// */
// public static File createFile(File baseDir, String filePath, String contents) throws IOException {
// File file = new File(baseDir.getPath() + File.separator + filePath);
// file.createNewFile();
// FileWriter fw = new FileWriter(file);
// fw.write(contents);
// fw.flush();
// fw.close();
// return new File(filePath);
// }
//
// /**
// * Recursively deletes the specified file/directory.
// *
// * @param dirOrFile The file or directory to delete recursively and forcefully.
// * @throws JavaGitException Thrown if a file or directory was not deleted.
// */
// public static void removeDirectoryRecursivelyAndForcefully(File dirOrFile)
// throws JavaGitException {
// File[] children = dirOrFile.listFiles();
// if (null != children) {
// for (File f : children) {
// removeDirectoryRecursivelyAndForcefully(f);
// }
// }
// //System.gc();
// if (!dirOrFile.delete()) {
// throw new JavaGitException(-1, "-1: Unable to delete file/directory. { path=["
// + dirOrFile.getAbsolutePath() + "] }");
// }
// }
//
// /**
// * Append some text to an existing file.
// *
// * @param file File that will be modified
// * @param appendText The text that will be appended to the file
// * @throws FileNotFoundException Exception thrown if the file does not exist.
// * @throws IOException thrown if the IO operation fails.
// */
// public static void modifyFileContents(File file, String appendText) throws FileNotFoundException,
// IOException {
// if (!file.exists()) {
// throw new FileNotFoundException("File does not exist");
// }
// FileWriter fw = new FileWriter(file);
// fw.append(appendText);
// fw.close();
// }
//
// }
//
// Path: javagit/src/test/java/edu/nyu/cs/javagit/utilities/TestProperty.java
// public enum TestProperty {
// GIT_PATH("javagit.test.gitpath", "/usr/bin");
//
// private final String value;
// private final String property;
//
// TestProperty(String property, String defaultValue) {
// this.property = property;
// this.value = System.getProperty(property, defaultValue);
// }
//
// public String asString() {
// return value;
// }
//
// public String getName() {
// return property;
// }
// }
// Path: javagit/src/test/java/edu/nyu/cs/javagit/api/TestJavaGitConfiguration.java
import edu.nyu.cs.javagit.TestBase;
import edu.nyu.cs.javagit.test.utilities.TestErrorException;
import edu.nyu.cs.javagit.utilities.FileUtilities;
import edu.nyu.cs.javagit.utilities.TestProperty;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
fail("Invalid path - this should never be reached.");
} catch (JavaGitException e) {
assertEquals(e.getCode(), 100002);
pathFile.delete();
} catch (Exception e) {
fail("Temp path not containing git generated wrong kind of exception: "
+ e.getClass().getName());
}
/*
* Set the path using null as the File argument. This is valid - it's saying: wipe out whatever
* was set before (via previous calls to setGitPath) and just look on the PATH for git.
*/
pathFile = null;
try {
JavaGitConfiguration.setGitPath(pathFile);
} catch (Exception e) {
fail("Null path (File) generated exception: " + e.getClass().getName());
}
// Grab the version and see if we can get it exception-free.
String version = "";
try {
version = JavaGitConfiguration.getGitVersion();
} catch (Exception e) {
fail("Couldn't get git version string - saw \"" + version + "\" and got exception: "
+ e.getClass().getName());
}
}
| public void testPathSeparator_issue2() throws TestErrorException { |
bit-man/SwissArmyJavaGit | javagit/src/test/java/edu/nyu/cs/javagit/api/TestJavaGitConfiguration.java | // Path: javagit/src/test/java/edu/nyu/cs/javagit/TestBase.java
// @Ignore
// public class TestBase extends TestCase {
//
// @Before
// public void setUp() throws IOException, JavaGitException {
// JavaGitConfiguration.setGitPath(TestProperty.GIT_PATH.asString());
// }
// }
//
// Path: javagit/src/test/java/edu/nyu/cs/javagit/test/utilities/TestErrorException.java
// public class TestErrorException extends Throwable {
// public TestErrorException(Exception e) {
// super(e);
// }
//
// public TestErrorException(String s, Exception e) {
// super(s,e);
// }
// }
//
// Path: javagit/src/test/java/edu/nyu/cs/javagit/utilities/FileUtilities.java
// public class FileUtilities {
//
// /**
// * Create a temp directory based on the supplied directory base name. The directory will be
// * created under the temp directory for the system running the program.
// *
// * @param baseDirName A base name for the directory. If this directory exists, a directory based on this
// * name will be created.
// * @return A <code>File</code> instance representing the created directory.
// */
// public static File createTempDirectory(String baseDirName) throws IOException {
// // Get the system temp directory location.
// File tmpfile = File.createTempFile("AfileName", "tmp");
// String absPath = tmpfile.getAbsolutePath();
// tmpfile.delete();
// int lastSep = absPath.lastIndexOf(File.separatorChar);
// String tmpDir = absPath.substring(0, lastSep + 1);
//
// // System.out.println("Temp Directory: tmpDir=["+ tmpDir + "]");
//
// // Create a temp directory for the caller
// File file = new File(tmpDir + baseDirName);
// int num = 0;
// while (!file.mkdir()) {
// file = new File(tmpDir + baseDirName + Integer.toString(num++));
// }
//
// return file;
// }
//
// /**
// * Create a new file and write the contents to it.
// *
// * @param baseDir The base directory of the repo.
// * @param filePath The relative path to the file with respect to the base directory.
// * @param contents Some contents to write to the file.
// * @return A <code>File</code> object representation of the file.
// * @throws IOException If there are problems creating the file or writing the contents to the file.
// */
// public static File createFile(File baseDir, String filePath, String contents) throws IOException {
// File file = new File(baseDir.getPath() + File.separator + filePath);
// file.createNewFile();
// FileWriter fw = new FileWriter(file);
// fw.write(contents);
// fw.flush();
// fw.close();
// return new File(filePath);
// }
//
// /**
// * Recursively deletes the specified file/directory.
// *
// * @param dirOrFile The file or directory to delete recursively and forcefully.
// * @throws JavaGitException Thrown if a file or directory was not deleted.
// */
// public static void removeDirectoryRecursivelyAndForcefully(File dirOrFile)
// throws JavaGitException {
// File[] children = dirOrFile.listFiles();
// if (null != children) {
// for (File f : children) {
// removeDirectoryRecursivelyAndForcefully(f);
// }
// }
// //System.gc();
// if (!dirOrFile.delete()) {
// throw new JavaGitException(-1, "-1: Unable to delete file/directory. { path=["
// + dirOrFile.getAbsolutePath() + "] }");
// }
// }
//
// /**
// * Append some text to an existing file.
// *
// * @param file File that will be modified
// * @param appendText The text that will be appended to the file
// * @throws FileNotFoundException Exception thrown if the file does not exist.
// * @throws IOException thrown if the IO operation fails.
// */
// public static void modifyFileContents(File file, String appendText) throws FileNotFoundException,
// IOException {
// if (!file.exists()) {
// throw new FileNotFoundException("File does not exist");
// }
// FileWriter fw = new FileWriter(file);
// fw.append(appendText);
// fw.close();
// }
//
// }
//
// Path: javagit/src/test/java/edu/nyu/cs/javagit/utilities/TestProperty.java
// public enum TestProperty {
// GIT_PATH("javagit.test.gitpath", "/usr/bin");
//
// private final String value;
// private final String property;
//
// TestProperty(String property, String defaultValue) {
// this.property = property;
// this.value = System.getProperty(property, defaultValue);
// }
//
// public String asString() {
// return value;
// }
//
// public String getName() {
// return property;
// }
// }
| import edu.nyu.cs.javagit.TestBase;
import edu.nyu.cs.javagit.test.utilities.TestErrorException;
import edu.nyu.cs.javagit.utilities.FileUtilities;
import edu.nyu.cs.javagit.utilities.TestProperty;
import org.junit.Test;
import java.io.File;
import java.io.IOException; | assertEquals(e.getCode(), 100002);
pathFile.delete();
} catch (Exception e) {
fail("Temp path not containing git generated wrong kind of exception: "
+ e.getClass().getName());
}
/*
* Set the path using null as the File argument. This is valid - it's saying: wipe out whatever
* was set before (via previous calls to setGitPath) and just look on the PATH for git.
*/
pathFile = null;
try {
JavaGitConfiguration.setGitPath(pathFile);
} catch (Exception e) {
fail("Null path (File) generated exception: " + e.getClass().getName());
}
// Grab the version and see if we can get it exception-free.
String version = "";
try {
version = JavaGitConfiguration.getGitVersion();
} catch (Exception e) {
fail("Couldn't get git version string - saw \"" + version + "\" and got exception: "
+ e.getClass().getName());
}
}
public void testPathSeparator_issue2() throws TestErrorException {
try { | // Path: javagit/src/test/java/edu/nyu/cs/javagit/TestBase.java
// @Ignore
// public class TestBase extends TestCase {
//
// @Before
// public void setUp() throws IOException, JavaGitException {
// JavaGitConfiguration.setGitPath(TestProperty.GIT_PATH.asString());
// }
// }
//
// Path: javagit/src/test/java/edu/nyu/cs/javagit/test/utilities/TestErrorException.java
// public class TestErrorException extends Throwable {
// public TestErrorException(Exception e) {
// super(e);
// }
//
// public TestErrorException(String s, Exception e) {
// super(s,e);
// }
// }
//
// Path: javagit/src/test/java/edu/nyu/cs/javagit/utilities/FileUtilities.java
// public class FileUtilities {
//
// /**
// * Create a temp directory based on the supplied directory base name. The directory will be
// * created under the temp directory for the system running the program.
// *
// * @param baseDirName A base name for the directory. If this directory exists, a directory based on this
// * name will be created.
// * @return A <code>File</code> instance representing the created directory.
// */
// public static File createTempDirectory(String baseDirName) throws IOException {
// // Get the system temp directory location.
// File tmpfile = File.createTempFile("AfileName", "tmp");
// String absPath = tmpfile.getAbsolutePath();
// tmpfile.delete();
// int lastSep = absPath.lastIndexOf(File.separatorChar);
// String tmpDir = absPath.substring(0, lastSep + 1);
//
// // System.out.println("Temp Directory: tmpDir=["+ tmpDir + "]");
//
// // Create a temp directory for the caller
// File file = new File(tmpDir + baseDirName);
// int num = 0;
// while (!file.mkdir()) {
// file = new File(tmpDir + baseDirName + Integer.toString(num++));
// }
//
// return file;
// }
//
// /**
// * Create a new file and write the contents to it.
// *
// * @param baseDir The base directory of the repo.
// * @param filePath The relative path to the file with respect to the base directory.
// * @param contents Some contents to write to the file.
// * @return A <code>File</code> object representation of the file.
// * @throws IOException If there are problems creating the file or writing the contents to the file.
// */
// public static File createFile(File baseDir, String filePath, String contents) throws IOException {
// File file = new File(baseDir.getPath() + File.separator + filePath);
// file.createNewFile();
// FileWriter fw = new FileWriter(file);
// fw.write(contents);
// fw.flush();
// fw.close();
// return new File(filePath);
// }
//
// /**
// * Recursively deletes the specified file/directory.
// *
// * @param dirOrFile The file or directory to delete recursively and forcefully.
// * @throws JavaGitException Thrown if a file or directory was not deleted.
// */
// public static void removeDirectoryRecursivelyAndForcefully(File dirOrFile)
// throws JavaGitException {
// File[] children = dirOrFile.listFiles();
// if (null != children) {
// for (File f : children) {
// removeDirectoryRecursivelyAndForcefully(f);
// }
// }
// //System.gc();
// if (!dirOrFile.delete()) {
// throw new JavaGitException(-1, "-1: Unable to delete file/directory. { path=["
// + dirOrFile.getAbsolutePath() + "] }");
// }
// }
//
// /**
// * Append some text to an existing file.
// *
// * @param file File that will be modified
// * @param appendText The text that will be appended to the file
// * @throws FileNotFoundException Exception thrown if the file does not exist.
// * @throws IOException thrown if the IO operation fails.
// */
// public static void modifyFileContents(File file, String appendText) throws FileNotFoundException,
// IOException {
// if (!file.exists()) {
// throw new FileNotFoundException("File does not exist");
// }
// FileWriter fw = new FileWriter(file);
// fw.append(appendText);
// fw.close();
// }
//
// }
//
// Path: javagit/src/test/java/edu/nyu/cs/javagit/utilities/TestProperty.java
// public enum TestProperty {
// GIT_PATH("javagit.test.gitpath", "/usr/bin");
//
// private final String value;
// private final String property;
//
// TestProperty(String property, String defaultValue) {
// this.property = property;
// this.value = System.getProperty(property, defaultValue);
// }
//
// public String asString() {
// return value;
// }
//
// public String getName() {
// return property;
// }
// }
// Path: javagit/src/test/java/edu/nyu/cs/javagit/api/TestJavaGitConfiguration.java
import edu.nyu.cs.javagit.TestBase;
import edu.nyu.cs.javagit.test.utilities.TestErrorException;
import edu.nyu.cs.javagit.utilities.FileUtilities;
import edu.nyu.cs.javagit.utilities.TestProperty;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
assertEquals(e.getCode(), 100002);
pathFile.delete();
} catch (Exception e) {
fail("Temp path not containing git generated wrong kind of exception: "
+ e.getClass().getName());
}
/*
* Set the path using null as the File argument. This is valid - it's saying: wipe out whatever
* was set before (via previous calls to setGitPath) and just look on the PATH for git.
*/
pathFile = null;
try {
JavaGitConfiguration.setGitPath(pathFile);
} catch (Exception e) {
fail("Null path (File) generated exception: " + e.getClass().getName());
}
// Grab the version and see if we can get it exception-free.
String version = "";
try {
version = JavaGitConfiguration.getGitVersion();
} catch (Exception e) {
fail("Couldn't get git version string - saw \"" + version + "\" and got exception: "
+ e.getClass().getName());
}
}
public void testPathSeparator_issue2() throws TestErrorException {
try { | JavaGitConfiguration.setGitPath(TestProperty.GIT_PATH.asString()); |
bit-man/SwissArmyJavaGit | javagit/src/test/java/edu/nyu/cs/javagit/client/cli/TestGitAddResponseImpl.java | // Path: javagit/src/test/java/edu/nyu/cs/javagit/TestBase.java
// @Ignore
// public class TestBase extends TestCase {
//
// @Before
// public void setUp() throws IOException, JavaGitException {
// JavaGitConfiguration.setGitPath(TestProperty.GIT_PATH.asString());
// }
// }
//
// Path: javagit/src/main/java/edu/nyu/cs/javagit/client/cli/CliGitAdd.java
// public static class GitAddParser implements IParser {
//
// private int lineNum;
// private GitAddResponseImpl response;
// private boolean error = false;
// private List<Error> errorList;
//
// public GitAddParser() {
// lineNum = 0;
// response = new GitAddResponseImpl();
// }
//
// public void parseLine(String line) {
// if (line == null || line.length() == 0) {
// return;
// }
// lineNum++;
// if (isError(line)) {
// error = true;
// errorList.add(new Error(lineNum, line));
// } else if (isComment(line))
// response.setComment(lineNum, line);
// else
// processLine(line);
// }
//
// private boolean isError(String line) {
// if (line.trim().startsWith("fatal") || line.trim().startsWith("error")) {
// if (errorList == null) {
// errorList = new ArrayList<Error>();
// }
// return true;
// }
// return false;
// }
//
// private boolean isComment(String line) {
// if (line.startsWith("Nothing specified") || line.contains("nothing added")
// || line.contains("No changes") || line.contains("Maybe you wanted to say")
// || line.contains("usage")) {
// return true;
// }
// return false;
// }
//
// /**
// * Lines that start with "add" have the second token as the name of the file added by
// * <git-add>.
// *
// * @param line
// */
// private void processLine(String line) {
// if (line.startsWith("add")) {
// StringTokenizer st = new StringTokenizer(line);
//
// if (st.nextToken().equals("add") && st.hasMoreTokens()) {
// String extractedFileName = filterFileName(st.nextToken());
// if (extractedFileName != null && extractedFileName.length() > 0) {
// File file = new File(extractedFileName);
// response.add(file);
// }
// }
// } else {
// processSpaceDelimitedFilePaths(line);
// }
// }
//
// private void processSpaceDelimitedFilePaths(String line) {
// if (!line.startsWith("\\s+")) {
// StringTokenizer st = new StringTokenizer(line);
// while (st.hasMoreTokens()) {
// File file = new File(st.nextToken());
// response.add(file);
// }
// }
// }
//
// public String filterFileName(String token) {
// if (token.length() > 0 && enclosedWithSingleQuotes(token)) {
// int firstQuote = token.indexOf("'");
// int nextQuote = token.indexOf("'", firstQuote + 1);
// if (nextQuote > firstQuote) {
// return token.substring(firstQuote + 1, nextQuote);
// }
// }
// return null;
// }
//
// public boolean enclosedWithSingleQuotes(String token) {
// return token.matches("'.*'");
// }
//
// public void processExitCode(int code) {
// }
//
// /**
// * Gets a <code>GitAddResponse</code> object containing the info generated by <git-add> command.
// * If there was an error generated while running <git-add> then it throws an exception.
// *
// * @return GitAddResponse object containing <git-add> response.
// * @throws JavaGitException If there are any errors generated by <git-add> command.
// */
// public GitAddResponse getResponse() throws JavaGitException {
// if (error) {
// throw new JavaGitException(401000, ExceptionMessageMap.getMessage("401000") +
// " - git add error message: { " + getError() + " }");
// }
// return response;
// }
//
// /**
// * Retrieves all the errors in the error list and concatenate them together in one string.
// *
// * @return concatenation of errors
// */
// private String getError() {
// StringBuffer buf = new StringBuffer();
// for (int i = 0; i < errorList.size(); i++) {
// buf.append("Line " + errorList.get(i).lineNum + ". " + errorList.get(i).getErrorString());
// if (i < errorList.size() - 1) {
// buf.append(" ");
// }
// }
// return buf.toString();
// }
//
// /**
// * Class for storing error details from the <git-add> output.
// */
// private static class Error {
// final int lineNum;
// final String errorStr;
//
// Error(int lineNum, String errorStr) {
// this.lineNum = lineNum;
// this.errorStr = errorStr;
// }
//
// public String getErrorString() {
// return errorStr;
// }
// }
// }
| import edu.nyu.cs.javagit.TestBase;
import edu.nyu.cs.javagit.api.JavaGitException;
import edu.nyu.cs.javagit.api.commands.GitAddOptions;
import edu.nyu.cs.javagit.client.cli.CliGitAdd.GitAddParser;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException; | /*
* ====================================================================
* Copyright (c) 2008 JavaGit Project. All rights reserved.
*
* This software is licensed using the GNU LGPL v2.1 license. A copy
* of the license is included with the distribution of this source
* code in the LICENSE.txt file. The text of the license can also
* be obtained at:
*
* http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
*
* For more information on the JavaGit project, see:
*
* http://www.javagit.com
* ====================================================================
*/
package edu.nyu.cs.javagit.client.cli;
public class TestGitAddResponseImpl extends TestBase {
CliGitAdd gitAdd; | // Path: javagit/src/test/java/edu/nyu/cs/javagit/TestBase.java
// @Ignore
// public class TestBase extends TestCase {
//
// @Before
// public void setUp() throws IOException, JavaGitException {
// JavaGitConfiguration.setGitPath(TestProperty.GIT_PATH.asString());
// }
// }
//
// Path: javagit/src/main/java/edu/nyu/cs/javagit/client/cli/CliGitAdd.java
// public static class GitAddParser implements IParser {
//
// private int lineNum;
// private GitAddResponseImpl response;
// private boolean error = false;
// private List<Error> errorList;
//
// public GitAddParser() {
// lineNum = 0;
// response = new GitAddResponseImpl();
// }
//
// public void parseLine(String line) {
// if (line == null || line.length() == 0) {
// return;
// }
// lineNum++;
// if (isError(line)) {
// error = true;
// errorList.add(new Error(lineNum, line));
// } else if (isComment(line))
// response.setComment(lineNum, line);
// else
// processLine(line);
// }
//
// private boolean isError(String line) {
// if (line.trim().startsWith("fatal") || line.trim().startsWith("error")) {
// if (errorList == null) {
// errorList = new ArrayList<Error>();
// }
// return true;
// }
// return false;
// }
//
// private boolean isComment(String line) {
// if (line.startsWith("Nothing specified") || line.contains("nothing added")
// || line.contains("No changes") || line.contains("Maybe you wanted to say")
// || line.contains("usage")) {
// return true;
// }
// return false;
// }
//
// /**
// * Lines that start with "add" have the second token as the name of the file added by
// * <git-add>.
// *
// * @param line
// */
// private void processLine(String line) {
// if (line.startsWith("add")) {
// StringTokenizer st = new StringTokenizer(line);
//
// if (st.nextToken().equals("add") && st.hasMoreTokens()) {
// String extractedFileName = filterFileName(st.nextToken());
// if (extractedFileName != null && extractedFileName.length() > 0) {
// File file = new File(extractedFileName);
// response.add(file);
// }
// }
// } else {
// processSpaceDelimitedFilePaths(line);
// }
// }
//
// private void processSpaceDelimitedFilePaths(String line) {
// if (!line.startsWith("\\s+")) {
// StringTokenizer st = new StringTokenizer(line);
// while (st.hasMoreTokens()) {
// File file = new File(st.nextToken());
// response.add(file);
// }
// }
// }
//
// public String filterFileName(String token) {
// if (token.length() > 0 && enclosedWithSingleQuotes(token)) {
// int firstQuote = token.indexOf("'");
// int nextQuote = token.indexOf("'", firstQuote + 1);
// if (nextQuote > firstQuote) {
// return token.substring(firstQuote + 1, nextQuote);
// }
// }
// return null;
// }
//
// public boolean enclosedWithSingleQuotes(String token) {
// return token.matches("'.*'");
// }
//
// public void processExitCode(int code) {
// }
//
// /**
// * Gets a <code>GitAddResponse</code> object containing the info generated by <git-add> command.
// * If there was an error generated while running <git-add> then it throws an exception.
// *
// * @return GitAddResponse object containing <git-add> response.
// * @throws JavaGitException If there are any errors generated by <git-add> command.
// */
// public GitAddResponse getResponse() throws JavaGitException {
// if (error) {
// throw new JavaGitException(401000, ExceptionMessageMap.getMessage("401000") +
// " - git add error message: { " + getError() + " }");
// }
// return response;
// }
//
// /**
// * Retrieves all the errors in the error list and concatenate them together in one string.
// *
// * @return concatenation of errors
// */
// private String getError() {
// StringBuffer buf = new StringBuffer();
// for (int i = 0; i < errorList.size(); i++) {
// buf.append("Line " + errorList.get(i).lineNum + ". " + errorList.get(i).getErrorString());
// if (i < errorList.size() - 1) {
// buf.append(" ");
// }
// }
// return buf.toString();
// }
//
// /**
// * Class for storing error details from the <git-add> output.
// */
// private static class Error {
// final int lineNum;
// final String errorStr;
//
// Error(int lineNum, String errorStr) {
// this.lineNum = lineNum;
// this.errorStr = errorStr;
// }
//
// public String getErrorString() {
// return errorStr;
// }
// }
// }
// Path: javagit/src/test/java/edu/nyu/cs/javagit/client/cli/TestGitAddResponseImpl.java
import edu.nyu.cs.javagit.TestBase;
import edu.nyu.cs.javagit.api.JavaGitException;
import edu.nyu.cs.javagit.api.commands.GitAddOptions;
import edu.nyu.cs.javagit.client.cli.CliGitAdd.GitAddParser;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
/*
* ====================================================================
* Copyright (c) 2008 JavaGit Project. All rights reserved.
*
* This software is licensed using the GNU LGPL v2.1 license. A copy
* of the license is included with the distribution of this source
* code in the LICENSE.txt file. The text of the license can also
* be obtained at:
*
* http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
*
* For more information on the JavaGit project, see:
*
* http://www.javagit.com
* ====================================================================
*/
package edu.nyu.cs.javagit.client.cli;
public class TestGitAddResponseImpl extends TestBase {
CliGitAdd gitAdd; | GitAddParser parser; |
bit-man/SwissArmyJavaGit | javagit/src/test/java/edu/nyu/cs/javagit/api/TestBranching.java | // Path: javagit/src/test/java/edu/nyu/cs/javagit/TestBase.java
// @Ignore
// public class TestBase extends TestCase {
//
// @Before
// public void setUp() throws IOException, JavaGitException {
// JavaGitConfiguration.setGitPath(TestProperty.GIT_PATH.asString());
// }
// }
//
// Path: javagit/src/main/java/edu/nyu/cs/javagit/api/commands/GitInit.java
// public class GitInit {
//
// public GitInitResponse init(File repositoryPath, GitInitOptions options) throws JavaGitException, IOException{
// CheckUtilities.checkNullArgument(repositoryPath, "repository");
//
// IClient client = ClientManager.getInstance().getPreferredClient();
// IGitInit gitInit = client.getGitInitInstance();
// return gitInit.init(repositoryPath,options);
// }
//
// public GitInitResponse init(File repositoryPath) throws JavaGitException, IOException{
// CheckUtilities.checkNullArgument(repositoryPath, "repository");
//
// IClient client = ClientManager.getInstance().getPreferredClient();
// IGitInit gitInit = client.getGitInitInstance();
// return gitInit.init(repositoryPath);
// }
//
// }
//
// Path: javagit/src/test/java/edu/nyu/cs/javagit/utilities/FileUtilities.java
// public class FileUtilities {
//
// /**
// * Create a temp directory based on the supplied directory base name. The directory will be
// * created under the temp directory for the system running the program.
// *
// * @param baseDirName A base name for the directory. If this directory exists, a directory based on this
// * name will be created.
// * @return A <code>File</code> instance representing the created directory.
// */
// public static File createTempDirectory(String baseDirName) throws IOException {
// // Get the system temp directory location.
// File tmpfile = File.createTempFile("AfileName", "tmp");
// String absPath = tmpfile.getAbsolutePath();
// tmpfile.delete();
// int lastSep = absPath.lastIndexOf(File.separatorChar);
// String tmpDir = absPath.substring(0, lastSep + 1);
//
// // System.out.println("Temp Directory: tmpDir=["+ tmpDir + "]");
//
// // Create a temp directory for the caller
// File file = new File(tmpDir + baseDirName);
// int num = 0;
// while (!file.mkdir()) {
// file = new File(tmpDir + baseDirName + Integer.toString(num++));
// }
//
// return file;
// }
//
// /**
// * Create a new file and write the contents to it.
// *
// * @param baseDir The base directory of the repo.
// * @param filePath The relative path to the file with respect to the base directory.
// * @param contents Some contents to write to the file.
// * @return A <code>File</code> object representation of the file.
// * @throws IOException If there are problems creating the file or writing the contents to the file.
// */
// public static File createFile(File baseDir, String filePath, String contents) throws IOException {
// File file = new File(baseDir.getPath() + File.separator + filePath);
// file.createNewFile();
// FileWriter fw = new FileWriter(file);
// fw.write(contents);
// fw.flush();
// fw.close();
// return new File(filePath);
// }
//
// /**
// * Recursively deletes the specified file/directory.
// *
// * @param dirOrFile The file or directory to delete recursively and forcefully.
// * @throws JavaGitException Thrown if a file or directory was not deleted.
// */
// public static void removeDirectoryRecursivelyAndForcefully(File dirOrFile)
// throws JavaGitException {
// File[] children = dirOrFile.listFiles();
// if (null != children) {
// for (File f : children) {
// removeDirectoryRecursivelyAndForcefully(f);
// }
// }
// //System.gc();
// if (!dirOrFile.delete()) {
// throw new JavaGitException(-1, "-1: Unable to delete file/directory. { path=["
// + dirOrFile.getAbsolutePath() + "] }");
// }
// }
//
// /**
// * Append some text to an existing file.
// *
// * @param file File that will be modified
// * @param appendText The text that will be appended to the file
// * @throws FileNotFoundException Exception thrown if the file does not exist.
// * @throws IOException thrown if the IO operation fails.
// */
// public static void modifyFileContents(File file, String appendText) throws FileNotFoundException,
// IOException {
// if (!file.exists()) {
// throw new FileNotFoundException("File does not exist");
// }
// FileWriter fw = new FileWriter(file);
// fw.append(appendText);
// fw.close();
// }
//
// }
| import edu.nyu.cs.javagit.TestBase;
import edu.nyu.cs.javagit.api.commands.GitInit;
import edu.nyu.cs.javagit.utilities.FileUtilities;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import java.util.List; | /*
* ====================================================================
* Copyright (c) 2008 JavaGit Project. All rights reserved.
*
* This software is licensed using the GNU LGPL v2.1 license. A copy
* of the license is included with the distribution of this source
* code in the LICENSE.txt file. The text of the license can also
* be obtained at:
*
* http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
*
* For more information on the JavaGit project, see:
*
* http://www.javagit.com
* ====================================================================
*/
package edu.nyu.cs.javagit.api;
public class TestBranching extends TestBase {
private File repositoryDirectory;
private DotGit dotGit;
private WorkingTree workingTree;
@Before
public void setUp() throws JavaGitException, IOException {
super.setUp(); | // Path: javagit/src/test/java/edu/nyu/cs/javagit/TestBase.java
// @Ignore
// public class TestBase extends TestCase {
//
// @Before
// public void setUp() throws IOException, JavaGitException {
// JavaGitConfiguration.setGitPath(TestProperty.GIT_PATH.asString());
// }
// }
//
// Path: javagit/src/main/java/edu/nyu/cs/javagit/api/commands/GitInit.java
// public class GitInit {
//
// public GitInitResponse init(File repositoryPath, GitInitOptions options) throws JavaGitException, IOException{
// CheckUtilities.checkNullArgument(repositoryPath, "repository");
//
// IClient client = ClientManager.getInstance().getPreferredClient();
// IGitInit gitInit = client.getGitInitInstance();
// return gitInit.init(repositoryPath,options);
// }
//
// public GitInitResponse init(File repositoryPath) throws JavaGitException, IOException{
// CheckUtilities.checkNullArgument(repositoryPath, "repository");
//
// IClient client = ClientManager.getInstance().getPreferredClient();
// IGitInit gitInit = client.getGitInitInstance();
// return gitInit.init(repositoryPath);
// }
//
// }
//
// Path: javagit/src/test/java/edu/nyu/cs/javagit/utilities/FileUtilities.java
// public class FileUtilities {
//
// /**
// * Create a temp directory based on the supplied directory base name. The directory will be
// * created under the temp directory for the system running the program.
// *
// * @param baseDirName A base name for the directory. If this directory exists, a directory based on this
// * name will be created.
// * @return A <code>File</code> instance representing the created directory.
// */
// public static File createTempDirectory(String baseDirName) throws IOException {
// // Get the system temp directory location.
// File tmpfile = File.createTempFile("AfileName", "tmp");
// String absPath = tmpfile.getAbsolutePath();
// tmpfile.delete();
// int lastSep = absPath.lastIndexOf(File.separatorChar);
// String tmpDir = absPath.substring(0, lastSep + 1);
//
// // System.out.println("Temp Directory: tmpDir=["+ tmpDir + "]");
//
// // Create a temp directory for the caller
// File file = new File(tmpDir + baseDirName);
// int num = 0;
// while (!file.mkdir()) {
// file = new File(tmpDir + baseDirName + Integer.toString(num++));
// }
//
// return file;
// }
//
// /**
// * Create a new file and write the contents to it.
// *
// * @param baseDir The base directory of the repo.
// * @param filePath The relative path to the file with respect to the base directory.
// * @param contents Some contents to write to the file.
// * @return A <code>File</code> object representation of the file.
// * @throws IOException If there are problems creating the file or writing the contents to the file.
// */
// public static File createFile(File baseDir, String filePath, String contents) throws IOException {
// File file = new File(baseDir.getPath() + File.separator + filePath);
// file.createNewFile();
// FileWriter fw = new FileWriter(file);
// fw.write(contents);
// fw.flush();
// fw.close();
// return new File(filePath);
// }
//
// /**
// * Recursively deletes the specified file/directory.
// *
// * @param dirOrFile The file or directory to delete recursively and forcefully.
// * @throws JavaGitException Thrown if a file or directory was not deleted.
// */
// public static void removeDirectoryRecursivelyAndForcefully(File dirOrFile)
// throws JavaGitException {
// File[] children = dirOrFile.listFiles();
// if (null != children) {
// for (File f : children) {
// removeDirectoryRecursivelyAndForcefully(f);
// }
// }
// //System.gc();
// if (!dirOrFile.delete()) {
// throw new JavaGitException(-1, "-1: Unable to delete file/directory. { path=["
// + dirOrFile.getAbsolutePath() + "] }");
// }
// }
//
// /**
// * Append some text to an existing file.
// *
// * @param file File that will be modified
// * @param appendText The text that will be appended to the file
// * @throws FileNotFoundException Exception thrown if the file does not exist.
// * @throws IOException thrown if the IO operation fails.
// */
// public static void modifyFileContents(File file, String appendText) throws FileNotFoundException,
// IOException {
// if (!file.exists()) {
// throw new FileNotFoundException("File does not exist");
// }
// FileWriter fw = new FileWriter(file);
// fw.append(appendText);
// fw.close();
// }
//
// }
// Path: javagit/src/test/java/edu/nyu/cs/javagit/api/TestBranching.java
import edu.nyu.cs.javagit.TestBase;
import edu.nyu.cs.javagit.api.commands.GitInit;
import edu.nyu.cs.javagit.utilities.FileUtilities;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
/*
* ====================================================================
* Copyright (c) 2008 JavaGit Project. All rights reserved.
*
* This software is licensed using the GNU LGPL v2.1 license. A copy
* of the license is included with the distribution of this source
* code in the LICENSE.txt file. The text of the license can also
* be obtained at:
*
* http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
*
* For more information on the JavaGit project, see:
*
* http://www.javagit.com
* ====================================================================
*/
package edu.nyu.cs.javagit.api;
public class TestBranching extends TestBase {
private File repositoryDirectory;
private DotGit dotGit;
private WorkingTree workingTree;
@Before
public void setUp() throws JavaGitException, IOException {
super.setUp(); | repositoryDirectory = FileUtilities.createTempDirectory("TestGitBranching_dir"); |
bit-man/SwissArmyJavaGit | javagit/src/test/java/edu/nyu/cs/javagit/api/TestBranching.java | // Path: javagit/src/test/java/edu/nyu/cs/javagit/TestBase.java
// @Ignore
// public class TestBase extends TestCase {
//
// @Before
// public void setUp() throws IOException, JavaGitException {
// JavaGitConfiguration.setGitPath(TestProperty.GIT_PATH.asString());
// }
// }
//
// Path: javagit/src/main/java/edu/nyu/cs/javagit/api/commands/GitInit.java
// public class GitInit {
//
// public GitInitResponse init(File repositoryPath, GitInitOptions options) throws JavaGitException, IOException{
// CheckUtilities.checkNullArgument(repositoryPath, "repository");
//
// IClient client = ClientManager.getInstance().getPreferredClient();
// IGitInit gitInit = client.getGitInitInstance();
// return gitInit.init(repositoryPath,options);
// }
//
// public GitInitResponse init(File repositoryPath) throws JavaGitException, IOException{
// CheckUtilities.checkNullArgument(repositoryPath, "repository");
//
// IClient client = ClientManager.getInstance().getPreferredClient();
// IGitInit gitInit = client.getGitInitInstance();
// return gitInit.init(repositoryPath);
// }
//
// }
//
// Path: javagit/src/test/java/edu/nyu/cs/javagit/utilities/FileUtilities.java
// public class FileUtilities {
//
// /**
// * Create a temp directory based on the supplied directory base name. The directory will be
// * created under the temp directory for the system running the program.
// *
// * @param baseDirName A base name for the directory. If this directory exists, a directory based on this
// * name will be created.
// * @return A <code>File</code> instance representing the created directory.
// */
// public static File createTempDirectory(String baseDirName) throws IOException {
// // Get the system temp directory location.
// File tmpfile = File.createTempFile("AfileName", "tmp");
// String absPath = tmpfile.getAbsolutePath();
// tmpfile.delete();
// int lastSep = absPath.lastIndexOf(File.separatorChar);
// String tmpDir = absPath.substring(0, lastSep + 1);
//
// // System.out.println("Temp Directory: tmpDir=["+ tmpDir + "]");
//
// // Create a temp directory for the caller
// File file = new File(tmpDir + baseDirName);
// int num = 0;
// while (!file.mkdir()) {
// file = new File(tmpDir + baseDirName + Integer.toString(num++));
// }
//
// return file;
// }
//
// /**
// * Create a new file and write the contents to it.
// *
// * @param baseDir The base directory of the repo.
// * @param filePath The relative path to the file with respect to the base directory.
// * @param contents Some contents to write to the file.
// * @return A <code>File</code> object representation of the file.
// * @throws IOException If there are problems creating the file or writing the contents to the file.
// */
// public static File createFile(File baseDir, String filePath, String contents) throws IOException {
// File file = new File(baseDir.getPath() + File.separator + filePath);
// file.createNewFile();
// FileWriter fw = new FileWriter(file);
// fw.write(contents);
// fw.flush();
// fw.close();
// return new File(filePath);
// }
//
// /**
// * Recursively deletes the specified file/directory.
// *
// * @param dirOrFile The file or directory to delete recursively and forcefully.
// * @throws JavaGitException Thrown if a file or directory was not deleted.
// */
// public static void removeDirectoryRecursivelyAndForcefully(File dirOrFile)
// throws JavaGitException {
// File[] children = dirOrFile.listFiles();
// if (null != children) {
// for (File f : children) {
// removeDirectoryRecursivelyAndForcefully(f);
// }
// }
// //System.gc();
// if (!dirOrFile.delete()) {
// throw new JavaGitException(-1, "-1: Unable to delete file/directory. { path=["
// + dirOrFile.getAbsolutePath() + "] }");
// }
// }
//
// /**
// * Append some text to an existing file.
// *
// * @param file File that will be modified
// * @param appendText The text that will be appended to the file
// * @throws FileNotFoundException Exception thrown if the file does not exist.
// * @throws IOException thrown if the IO operation fails.
// */
// public static void modifyFileContents(File file, String appendText) throws FileNotFoundException,
// IOException {
// if (!file.exists()) {
// throw new FileNotFoundException("File does not exist");
// }
// FileWriter fw = new FileWriter(file);
// fw.append(appendText);
// fw.close();
// }
//
// }
| import edu.nyu.cs.javagit.TestBase;
import edu.nyu.cs.javagit.api.commands.GitInit;
import edu.nyu.cs.javagit.utilities.FileUtilities;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import java.util.List; | /*
* ====================================================================
* Copyright (c) 2008 JavaGit Project. All rights reserved.
*
* This software is licensed using the GNU LGPL v2.1 license. A copy
* of the license is included with the distribution of this source
* code in the LICENSE.txt file. The text of the license can also
* be obtained at:
*
* http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
*
* For more information on the JavaGit project, see:
*
* http://www.javagit.com
* ====================================================================
*/
package edu.nyu.cs.javagit.api;
public class TestBranching extends TestBase {
private File repositoryDirectory;
private DotGit dotGit;
private WorkingTree workingTree;
@Before
public void setUp() throws JavaGitException, IOException {
super.setUp();
repositoryDirectory = FileUtilities.createTempDirectory("TestGitBranching_dir"); | // Path: javagit/src/test/java/edu/nyu/cs/javagit/TestBase.java
// @Ignore
// public class TestBase extends TestCase {
//
// @Before
// public void setUp() throws IOException, JavaGitException {
// JavaGitConfiguration.setGitPath(TestProperty.GIT_PATH.asString());
// }
// }
//
// Path: javagit/src/main/java/edu/nyu/cs/javagit/api/commands/GitInit.java
// public class GitInit {
//
// public GitInitResponse init(File repositoryPath, GitInitOptions options) throws JavaGitException, IOException{
// CheckUtilities.checkNullArgument(repositoryPath, "repository");
//
// IClient client = ClientManager.getInstance().getPreferredClient();
// IGitInit gitInit = client.getGitInitInstance();
// return gitInit.init(repositoryPath,options);
// }
//
// public GitInitResponse init(File repositoryPath) throws JavaGitException, IOException{
// CheckUtilities.checkNullArgument(repositoryPath, "repository");
//
// IClient client = ClientManager.getInstance().getPreferredClient();
// IGitInit gitInit = client.getGitInitInstance();
// return gitInit.init(repositoryPath);
// }
//
// }
//
// Path: javagit/src/test/java/edu/nyu/cs/javagit/utilities/FileUtilities.java
// public class FileUtilities {
//
// /**
// * Create a temp directory based on the supplied directory base name. The directory will be
// * created under the temp directory for the system running the program.
// *
// * @param baseDirName A base name for the directory. If this directory exists, a directory based on this
// * name will be created.
// * @return A <code>File</code> instance representing the created directory.
// */
// public static File createTempDirectory(String baseDirName) throws IOException {
// // Get the system temp directory location.
// File tmpfile = File.createTempFile("AfileName", "tmp");
// String absPath = tmpfile.getAbsolutePath();
// tmpfile.delete();
// int lastSep = absPath.lastIndexOf(File.separatorChar);
// String tmpDir = absPath.substring(0, lastSep + 1);
//
// // System.out.println("Temp Directory: tmpDir=["+ tmpDir + "]");
//
// // Create a temp directory for the caller
// File file = new File(tmpDir + baseDirName);
// int num = 0;
// while (!file.mkdir()) {
// file = new File(tmpDir + baseDirName + Integer.toString(num++));
// }
//
// return file;
// }
//
// /**
// * Create a new file and write the contents to it.
// *
// * @param baseDir The base directory of the repo.
// * @param filePath The relative path to the file with respect to the base directory.
// * @param contents Some contents to write to the file.
// * @return A <code>File</code> object representation of the file.
// * @throws IOException If there are problems creating the file or writing the contents to the file.
// */
// public static File createFile(File baseDir, String filePath, String contents) throws IOException {
// File file = new File(baseDir.getPath() + File.separator + filePath);
// file.createNewFile();
// FileWriter fw = new FileWriter(file);
// fw.write(contents);
// fw.flush();
// fw.close();
// return new File(filePath);
// }
//
// /**
// * Recursively deletes the specified file/directory.
// *
// * @param dirOrFile The file or directory to delete recursively and forcefully.
// * @throws JavaGitException Thrown if a file or directory was not deleted.
// */
// public static void removeDirectoryRecursivelyAndForcefully(File dirOrFile)
// throws JavaGitException {
// File[] children = dirOrFile.listFiles();
// if (null != children) {
// for (File f : children) {
// removeDirectoryRecursivelyAndForcefully(f);
// }
// }
// //System.gc();
// if (!dirOrFile.delete()) {
// throw new JavaGitException(-1, "-1: Unable to delete file/directory. { path=["
// + dirOrFile.getAbsolutePath() + "] }");
// }
// }
//
// /**
// * Append some text to an existing file.
// *
// * @param file File that will be modified
// * @param appendText The text that will be appended to the file
// * @throws FileNotFoundException Exception thrown if the file does not exist.
// * @throws IOException thrown if the IO operation fails.
// */
// public static void modifyFileContents(File file, String appendText) throws FileNotFoundException,
// IOException {
// if (!file.exists()) {
// throw new FileNotFoundException("File does not exist");
// }
// FileWriter fw = new FileWriter(file);
// fw.append(appendText);
// fw.close();
// }
//
// }
// Path: javagit/src/test/java/edu/nyu/cs/javagit/api/TestBranching.java
import edu.nyu.cs.javagit.TestBase;
import edu.nyu.cs.javagit.api.commands.GitInit;
import edu.nyu.cs.javagit.utilities.FileUtilities;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
/*
* ====================================================================
* Copyright (c) 2008 JavaGit Project. All rights reserved.
*
* This software is licensed using the GNU LGPL v2.1 license. A copy
* of the license is included with the distribution of this source
* code in the LICENSE.txt file. The text of the license can also
* be obtained at:
*
* http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
*
* For more information on the JavaGit project, see:
*
* http://www.javagit.com
* ====================================================================
*/
package edu.nyu.cs.javagit.api;
public class TestBranching extends TestBase {
private File repositoryDirectory;
private DotGit dotGit;
private WorkingTree workingTree;
@Before
public void setUp() throws JavaGitException, IOException {
super.setUp();
repositoryDirectory = FileUtilities.createTempDirectory("TestGitBranching_dir"); | GitInit gitInit = new GitInit(); |
micmiu/bigdata-tutorial | hbase-tutorial/src/test/java/com/micmiu/bigdata/hbase/test/HBaseClientMangerTest.java | // Path: hbase-tutorial/src/main/java/com/micmiu/bigdata/hbase/client/HBaseClientManager.java
// public class HBaseClientManager implements HBaseConnPool {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(HBaseClientManager.class);
//
// private static final String DEF_ZNODE = "/hbase";
//
// private Configuration config;
// private HConnection conn;
//
// public HBaseClientManager() {
// this.config = HBaseConfiguration.create();
// }
//
// public HBaseClientManager(Configuration config) {
// this.config = config;
// }
//
// public HBaseClientManager(String quorum, int port) {
// //默认为 : /hbase EDH: /hyperbase1
// this(quorum, port, DEF_ZNODE);
// }
//
//
// public HBaseClientManager(String quorum, int port, String znode) {
// Configuration conf = HBaseConfiguration.create();
// conf.set("hbase.zookeeper.property.clientPort", port + "");
// conf.set("hbase.zookeeper.quorum", quorum);
// conf.set("zookeeper.znode.parent", znode);
// this.config = conf;
// }
//
// public synchronized HConnection getConn() {
// if (null == conn) {
// try {
// this.conn = HConnectionManager.createConnection(config);
// } catch (Exception ex) {
// LOGGER.error("create conn err:", ex);
// }
// }
// return conn;
// }
//
//
// public void closeConn() {
// if (null != conn) {
// try {
// conn.close();
// } catch (Exception ex) {
// ex.printStackTrace();
// }
// }
// }
//
// public void reloadConfig() {
// this.closeConn();
// this.getConn();
// }
//
// public void setup() {
//
// }
//
// public Configuration getConfig() {
// return config;
// }
//
// public void setConfig(Configuration config) {
// this.config = config;
// this.reloadConfig();
// }
// }
| import com.micmiu.bigdata.hbase.client.HBaseClientManager; | package com.micmiu.bigdata.hbase.test;
/**
* Created
* User: <a href="http://micmiu.com">micmiu</a>
* Date: 8/27/2015
* Time: 13:18
*/
public class HBaseClientMangerTest {
public static void main(String[] args) throws Exception {
String quorum = "192.168.0.30,192.168.0.31,192.168.0.32";
//quorum = "192.168.8.191,192.168.1.192,192.168.1.193";
int port = 2181;
String znode = "/hyperbase1"; //hbase | // Path: hbase-tutorial/src/main/java/com/micmiu/bigdata/hbase/client/HBaseClientManager.java
// public class HBaseClientManager implements HBaseConnPool {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(HBaseClientManager.class);
//
// private static final String DEF_ZNODE = "/hbase";
//
// private Configuration config;
// private HConnection conn;
//
// public HBaseClientManager() {
// this.config = HBaseConfiguration.create();
// }
//
// public HBaseClientManager(Configuration config) {
// this.config = config;
// }
//
// public HBaseClientManager(String quorum, int port) {
// //默认为 : /hbase EDH: /hyperbase1
// this(quorum, port, DEF_ZNODE);
// }
//
//
// public HBaseClientManager(String quorum, int port, String znode) {
// Configuration conf = HBaseConfiguration.create();
// conf.set("hbase.zookeeper.property.clientPort", port + "");
// conf.set("hbase.zookeeper.quorum", quorum);
// conf.set("zookeeper.znode.parent", znode);
// this.config = conf;
// }
//
// public synchronized HConnection getConn() {
// if (null == conn) {
// try {
// this.conn = HConnectionManager.createConnection(config);
// } catch (Exception ex) {
// LOGGER.error("create conn err:", ex);
// }
// }
// return conn;
// }
//
//
// public void closeConn() {
// if (null != conn) {
// try {
// conn.close();
// } catch (Exception ex) {
// ex.printStackTrace();
// }
// }
// }
//
// public void reloadConfig() {
// this.closeConn();
// this.getConn();
// }
//
// public void setup() {
//
// }
//
// public Configuration getConfig() {
// return config;
// }
//
// public void setConfig(Configuration config) {
// this.config = config;
// this.reloadConfig();
// }
// }
// Path: hbase-tutorial/src/test/java/com/micmiu/bigdata/hbase/test/HBaseClientMangerTest.java
import com.micmiu.bigdata.hbase.client.HBaseClientManager;
package com.micmiu.bigdata.hbase.test;
/**
* Created
* User: <a href="http://micmiu.com">micmiu</a>
* Date: 8/27/2015
* Time: 13:18
*/
public class HBaseClientMangerTest {
public static void main(String[] args) throws Exception {
String quorum = "192.168.0.30,192.168.0.31,192.168.0.32";
//quorum = "192.168.8.191,192.168.1.192,192.168.1.193";
int port = 2181;
String znode = "/hyperbase1"; //hbase | HBaseClientManager clientManager = new HBaseClientManager(quorum, port, znode); |
micmiu/bigdata-tutorial | hbase-tutorial/src/main/java/com/micmiu/bigdata/hbase/HBaseDDLHandler.java | // Path: hbase-tutorial/src/main/java/com/micmiu/bigdata/hbase/client/HBaseClientManager.java
// public class HBaseClientManager implements HBaseConnPool {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(HBaseClientManager.class);
//
// private static final String DEF_ZNODE = "/hbase";
//
// private Configuration config;
// private HConnection conn;
//
// public HBaseClientManager() {
// this.config = HBaseConfiguration.create();
// }
//
// public HBaseClientManager(Configuration config) {
// this.config = config;
// }
//
// public HBaseClientManager(String quorum, int port) {
// //默认为 : /hbase EDH: /hyperbase1
// this(quorum, port, DEF_ZNODE);
// }
//
//
// public HBaseClientManager(String quorum, int port, String znode) {
// Configuration conf = HBaseConfiguration.create();
// conf.set("hbase.zookeeper.property.clientPort", port + "");
// conf.set("hbase.zookeeper.quorum", quorum);
// conf.set("zookeeper.znode.parent", znode);
// this.config = conf;
// }
//
// public synchronized HConnection getConn() {
// if (null == conn) {
// try {
// this.conn = HConnectionManager.createConnection(config);
// } catch (Exception ex) {
// LOGGER.error("create conn err:", ex);
// }
// }
// return conn;
// }
//
//
// public void closeConn() {
// if (null != conn) {
// try {
// conn.close();
// } catch (Exception ex) {
// ex.printStackTrace();
// }
// }
// }
//
// public void reloadConfig() {
// this.closeConn();
// this.getConn();
// }
//
// public void setup() {
//
// }
//
// public Configuration getConfig() {
// return config;
// }
//
// public void setConfig(Configuration config) {
// this.config = config;
// this.reloadConfig();
// }
// }
//
// Path: hbase-tutorial/src/main/java/com/micmiu/bigdata/hbase/client/HBaseConnPool.java
// public interface HBaseConnPool {
//
// void setup();
//
// Configuration getConfig();
//
// HConnection getConn();
//
// void closeConn();
// }
| import com.micmiu.bigdata.hbase.client.HBaseClientManager;
import com.micmiu.bigdata.hbase.client.HBaseConnPool;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.HBaseAdmin;
import org.apache.hadoop.hbase.client.HTableInterface;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List; | package com.micmiu.bigdata.hbase;
/**
* HTable DDL handler
* User: <a href="http://micmiu.com">micmiu</a>
* Date: 7/8/2015
* Time: 08:00
*/
public class HBaseDDLHandler extends HBaseBaseHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(HBaseBaseHandler.class);
| // Path: hbase-tutorial/src/main/java/com/micmiu/bigdata/hbase/client/HBaseClientManager.java
// public class HBaseClientManager implements HBaseConnPool {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(HBaseClientManager.class);
//
// private static final String DEF_ZNODE = "/hbase";
//
// private Configuration config;
// private HConnection conn;
//
// public HBaseClientManager() {
// this.config = HBaseConfiguration.create();
// }
//
// public HBaseClientManager(Configuration config) {
// this.config = config;
// }
//
// public HBaseClientManager(String quorum, int port) {
// //默认为 : /hbase EDH: /hyperbase1
// this(quorum, port, DEF_ZNODE);
// }
//
//
// public HBaseClientManager(String quorum, int port, String znode) {
// Configuration conf = HBaseConfiguration.create();
// conf.set("hbase.zookeeper.property.clientPort", port + "");
// conf.set("hbase.zookeeper.quorum", quorum);
// conf.set("zookeeper.znode.parent", znode);
// this.config = conf;
// }
//
// public synchronized HConnection getConn() {
// if (null == conn) {
// try {
// this.conn = HConnectionManager.createConnection(config);
// } catch (Exception ex) {
// LOGGER.error("create conn err:", ex);
// }
// }
// return conn;
// }
//
//
// public void closeConn() {
// if (null != conn) {
// try {
// conn.close();
// } catch (Exception ex) {
// ex.printStackTrace();
// }
// }
// }
//
// public void reloadConfig() {
// this.closeConn();
// this.getConn();
// }
//
// public void setup() {
//
// }
//
// public Configuration getConfig() {
// return config;
// }
//
// public void setConfig(Configuration config) {
// this.config = config;
// this.reloadConfig();
// }
// }
//
// Path: hbase-tutorial/src/main/java/com/micmiu/bigdata/hbase/client/HBaseConnPool.java
// public interface HBaseConnPool {
//
// void setup();
//
// Configuration getConfig();
//
// HConnection getConn();
//
// void closeConn();
// }
// Path: hbase-tutorial/src/main/java/com/micmiu/bigdata/hbase/HBaseDDLHandler.java
import com.micmiu.bigdata.hbase.client.HBaseClientManager;
import com.micmiu.bigdata.hbase.client.HBaseConnPool;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.HBaseAdmin;
import org.apache.hadoop.hbase.client.HTableInterface;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
package com.micmiu.bigdata.hbase;
/**
* HTable DDL handler
* User: <a href="http://micmiu.com">micmiu</a>
* Date: 7/8/2015
* Time: 08:00
*/
public class HBaseDDLHandler extends HBaseBaseHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(HBaseBaseHandler.class);
| public HBaseDDLHandler(HBaseConnPool connPool) { |
micmiu/bigdata-tutorial | hbase-tutorial/src/main/java/com/micmiu/bigdata/hbase/HBaseDDLHandler.java | // Path: hbase-tutorial/src/main/java/com/micmiu/bigdata/hbase/client/HBaseClientManager.java
// public class HBaseClientManager implements HBaseConnPool {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(HBaseClientManager.class);
//
// private static final String DEF_ZNODE = "/hbase";
//
// private Configuration config;
// private HConnection conn;
//
// public HBaseClientManager() {
// this.config = HBaseConfiguration.create();
// }
//
// public HBaseClientManager(Configuration config) {
// this.config = config;
// }
//
// public HBaseClientManager(String quorum, int port) {
// //默认为 : /hbase EDH: /hyperbase1
// this(quorum, port, DEF_ZNODE);
// }
//
//
// public HBaseClientManager(String quorum, int port, String znode) {
// Configuration conf = HBaseConfiguration.create();
// conf.set("hbase.zookeeper.property.clientPort", port + "");
// conf.set("hbase.zookeeper.quorum", quorum);
// conf.set("zookeeper.znode.parent", znode);
// this.config = conf;
// }
//
// public synchronized HConnection getConn() {
// if (null == conn) {
// try {
// this.conn = HConnectionManager.createConnection(config);
// } catch (Exception ex) {
// LOGGER.error("create conn err:", ex);
// }
// }
// return conn;
// }
//
//
// public void closeConn() {
// if (null != conn) {
// try {
// conn.close();
// } catch (Exception ex) {
// ex.printStackTrace();
// }
// }
// }
//
// public void reloadConfig() {
// this.closeConn();
// this.getConn();
// }
//
// public void setup() {
//
// }
//
// public Configuration getConfig() {
// return config;
// }
//
// public void setConfig(Configuration config) {
// this.config = config;
// this.reloadConfig();
// }
// }
//
// Path: hbase-tutorial/src/main/java/com/micmiu/bigdata/hbase/client/HBaseConnPool.java
// public interface HBaseConnPool {
//
// void setup();
//
// Configuration getConfig();
//
// HConnection getConn();
//
// void closeConn();
// }
| import com.micmiu.bigdata.hbase.client.HBaseClientManager;
import com.micmiu.bigdata.hbase.client.HBaseConnPool;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.HBaseAdmin;
import org.apache.hadoop.hbase.client.HTableInterface;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List; | }
return tableNameList;
}
/**
* @param tableName
* @return
*/
public boolean deleteTable(String tableName) throws IOException {
HBaseAdmin admin = new HBaseAdmin(getConnPool().getConn());
if (admin.tableExists(tableName)) {
try {
if (admin.isTableEnabled(tableName)) {
admin.disableTable(tableName);
}
admin.deleteTable(tableName);
LOGGER.info(">>>> Table {} delete success!", tableName);
} catch (Exception ex) {
LOGGER.error("delete table error:", ex);
return false;
}
} else {
LOGGER.warn(">>>> Table {} delete but not exist.", tableName);
}
admin.close();
return true;
}
public static void main(String[] args) throws Exception { | // Path: hbase-tutorial/src/main/java/com/micmiu/bigdata/hbase/client/HBaseClientManager.java
// public class HBaseClientManager implements HBaseConnPool {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(HBaseClientManager.class);
//
// private static final String DEF_ZNODE = "/hbase";
//
// private Configuration config;
// private HConnection conn;
//
// public HBaseClientManager() {
// this.config = HBaseConfiguration.create();
// }
//
// public HBaseClientManager(Configuration config) {
// this.config = config;
// }
//
// public HBaseClientManager(String quorum, int port) {
// //默认为 : /hbase EDH: /hyperbase1
// this(quorum, port, DEF_ZNODE);
// }
//
//
// public HBaseClientManager(String quorum, int port, String znode) {
// Configuration conf = HBaseConfiguration.create();
// conf.set("hbase.zookeeper.property.clientPort", port + "");
// conf.set("hbase.zookeeper.quorum", quorum);
// conf.set("zookeeper.znode.parent", znode);
// this.config = conf;
// }
//
// public synchronized HConnection getConn() {
// if (null == conn) {
// try {
// this.conn = HConnectionManager.createConnection(config);
// } catch (Exception ex) {
// LOGGER.error("create conn err:", ex);
// }
// }
// return conn;
// }
//
//
// public void closeConn() {
// if (null != conn) {
// try {
// conn.close();
// } catch (Exception ex) {
// ex.printStackTrace();
// }
// }
// }
//
// public void reloadConfig() {
// this.closeConn();
// this.getConn();
// }
//
// public void setup() {
//
// }
//
// public Configuration getConfig() {
// return config;
// }
//
// public void setConfig(Configuration config) {
// this.config = config;
// this.reloadConfig();
// }
// }
//
// Path: hbase-tutorial/src/main/java/com/micmiu/bigdata/hbase/client/HBaseConnPool.java
// public interface HBaseConnPool {
//
// void setup();
//
// Configuration getConfig();
//
// HConnection getConn();
//
// void closeConn();
// }
// Path: hbase-tutorial/src/main/java/com/micmiu/bigdata/hbase/HBaseDDLHandler.java
import com.micmiu.bigdata.hbase.client.HBaseClientManager;
import com.micmiu.bigdata.hbase.client.HBaseConnPool;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.HBaseAdmin;
import org.apache.hadoop.hbase.client.HTableInterface;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
}
return tableNameList;
}
/**
* @param tableName
* @return
*/
public boolean deleteTable(String tableName) throws IOException {
HBaseAdmin admin = new HBaseAdmin(getConnPool().getConn());
if (admin.tableExists(tableName)) {
try {
if (admin.isTableEnabled(tableName)) {
admin.disableTable(tableName);
}
admin.deleteTable(tableName);
LOGGER.info(">>>> Table {} delete success!", tableName);
} catch (Exception ex) {
LOGGER.error("delete table error:", ex);
return false;
}
} else {
LOGGER.warn(">>>> Table {} delete but not exist.", tableName);
}
admin.close();
return true;
}
public static void main(String[] args) throws Exception { | HBaseClientManager clientManager = new HBaseClientManager(); |
micmiu/bigdata-tutorial | hbase-tutorial/src/main/java/com/micmiu/bigdata/hbase/HBaseBaseHandler.java | // Path: hbase-tutorial/src/main/java/com/micmiu/bigdata/hbase/client/HBaseConnPoolManager.java
// public class HBaseConnPoolManager extends HBaseConnAbstractPool {
//
// public HBaseConnPoolManager() {
// super();
// }
//
// public HBaseConnPoolManager(Configuration config) {
// super(config);
// }
//
// public HBaseConnPoolManager(String quorum, int port, String znode) {
// getConfig().set("hbase.zookeeper.property.clientPort", port + "");
// getConfig().set("hbase.zookeeper.quorum", quorum);
// getConfig().set("zookeeper.znode.parent", znode);
// }
// }
//
// Path: hbase-tutorial/src/main/java/com/micmiu/bigdata/hbase/client/HBaseConnPool.java
// public interface HBaseConnPool {
//
// void setup();
//
// Configuration getConfig();
//
// HConnection getConn();
//
// void closeConn();
// }
| import com.micmiu.bigdata.hbase.client.HBaseConnPoolManager;
import com.micmiu.bigdata.hbase.client.HBaseConnPool;
import org.apache.hadoop.hbase.client.HBaseAdmin;
import org.apache.hadoop.hbase.client.HTableInterface;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | package com.micmiu.bigdata.hbase;
/**
* Created
* User: <a href="http://micmiu.com">micmiu</a>
* Date: 7/8/2015
* Time: 08:20
*/
public class HBaseBaseHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(HBaseBaseHandler.class);
private String encoding = "UTF-8";
| // Path: hbase-tutorial/src/main/java/com/micmiu/bigdata/hbase/client/HBaseConnPoolManager.java
// public class HBaseConnPoolManager extends HBaseConnAbstractPool {
//
// public HBaseConnPoolManager() {
// super();
// }
//
// public HBaseConnPoolManager(Configuration config) {
// super(config);
// }
//
// public HBaseConnPoolManager(String quorum, int port, String znode) {
// getConfig().set("hbase.zookeeper.property.clientPort", port + "");
// getConfig().set("hbase.zookeeper.quorum", quorum);
// getConfig().set("zookeeper.znode.parent", znode);
// }
// }
//
// Path: hbase-tutorial/src/main/java/com/micmiu/bigdata/hbase/client/HBaseConnPool.java
// public interface HBaseConnPool {
//
// void setup();
//
// Configuration getConfig();
//
// HConnection getConn();
//
// void closeConn();
// }
// Path: hbase-tutorial/src/main/java/com/micmiu/bigdata/hbase/HBaseBaseHandler.java
import com.micmiu.bigdata.hbase.client.HBaseConnPoolManager;
import com.micmiu.bigdata.hbase.client.HBaseConnPool;
import org.apache.hadoop.hbase.client.HBaseAdmin;
import org.apache.hadoop.hbase.client.HTableInterface;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package com.micmiu.bigdata.hbase;
/**
* Created
* User: <a href="http://micmiu.com">micmiu</a>
* Date: 7/8/2015
* Time: 08:20
*/
public class HBaseBaseHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(HBaseBaseHandler.class);
private String encoding = "UTF-8";
| private HBaseConnPool connPool; |
micmiu/bigdata-tutorial | hbase-tutorial/src/main/java/com/micmiu/bigdata/hbase/HBaseBaseHandler.java | // Path: hbase-tutorial/src/main/java/com/micmiu/bigdata/hbase/client/HBaseConnPoolManager.java
// public class HBaseConnPoolManager extends HBaseConnAbstractPool {
//
// public HBaseConnPoolManager() {
// super();
// }
//
// public HBaseConnPoolManager(Configuration config) {
// super(config);
// }
//
// public HBaseConnPoolManager(String quorum, int port, String znode) {
// getConfig().set("hbase.zookeeper.property.clientPort", port + "");
// getConfig().set("hbase.zookeeper.quorum", quorum);
// getConfig().set("zookeeper.znode.parent", znode);
// }
// }
//
// Path: hbase-tutorial/src/main/java/com/micmiu/bigdata/hbase/client/HBaseConnPool.java
// public interface HBaseConnPool {
//
// void setup();
//
// Configuration getConfig();
//
// HConnection getConn();
//
// void closeConn();
// }
| import com.micmiu.bigdata.hbase.client.HBaseConnPoolManager;
import com.micmiu.bigdata.hbase.client.HBaseConnPool;
import org.apache.hadoop.hbase.client.HBaseAdmin;
import org.apache.hadoop.hbase.client.HTableInterface;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | package com.micmiu.bigdata.hbase;
/**
* Created
* User: <a href="http://micmiu.com">micmiu</a>
* Date: 7/8/2015
* Time: 08:20
*/
public class HBaseBaseHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(HBaseBaseHandler.class);
private String encoding = "UTF-8";
private HBaseConnPool connPool;
public HBaseBaseHandler(HBaseConnPool connPool) {
this.connPool = connPool;
}
public HBaseBaseHandler() { | // Path: hbase-tutorial/src/main/java/com/micmiu/bigdata/hbase/client/HBaseConnPoolManager.java
// public class HBaseConnPoolManager extends HBaseConnAbstractPool {
//
// public HBaseConnPoolManager() {
// super();
// }
//
// public HBaseConnPoolManager(Configuration config) {
// super(config);
// }
//
// public HBaseConnPoolManager(String quorum, int port, String znode) {
// getConfig().set("hbase.zookeeper.property.clientPort", port + "");
// getConfig().set("hbase.zookeeper.quorum", quorum);
// getConfig().set("zookeeper.znode.parent", znode);
// }
// }
//
// Path: hbase-tutorial/src/main/java/com/micmiu/bigdata/hbase/client/HBaseConnPool.java
// public interface HBaseConnPool {
//
// void setup();
//
// Configuration getConfig();
//
// HConnection getConn();
//
// void closeConn();
// }
// Path: hbase-tutorial/src/main/java/com/micmiu/bigdata/hbase/HBaseBaseHandler.java
import com.micmiu.bigdata.hbase.client.HBaseConnPoolManager;
import com.micmiu.bigdata.hbase.client.HBaseConnPool;
import org.apache.hadoop.hbase.client.HBaseAdmin;
import org.apache.hadoop.hbase.client.HTableInterface;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package com.micmiu.bigdata.hbase;
/**
* Created
* User: <a href="http://micmiu.com">micmiu</a>
* Date: 7/8/2015
* Time: 08:20
*/
public class HBaseBaseHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(HBaseBaseHandler.class);
private String encoding = "UTF-8";
private HBaseConnPool connPool;
public HBaseBaseHandler(HBaseConnPool connPool) {
this.connPool = connPool;
}
public HBaseBaseHandler() { | this.connPool = new HBaseConnPoolManager(); |
micmiu/bigdata-tutorial | es-tutorial/src/main/java/com/micmiu/es/tutorial/EsClient.java | // Path: es-tutorial/src/main/java/com/micmiu/es/tutorial/model/User.java
// public class User {
//
// private Long id;
//
// private String name;
//
// private Integer age;
//
// public Integer getAge() {
// return age;
// }
//
// public void setAge(Integer age) {
// this.age = age;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
// }
| import com.micmiu.es.tutorial.model.User;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.search.SearchType;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.index.query.FilterBuilders;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.SearchHits;
import java.io.IOException; | package com.micmiu.es.tutorial;
/**
* Created
* User: <a href="http://micmiu.com">micmiu</a>
* Date: 6/5/2015
* Time: 12:19
*/
public class EsClient {
private Client client;
public void init() {
client = new TransportClient().addTransportAddress(
new InetSocketTransportAddress("localhost", 9300));
}
public void close() {
client.close();
}
/**
* index
*/
public void createIndex() {
for (int i = 0; i < 1000; i++) { | // Path: es-tutorial/src/main/java/com/micmiu/es/tutorial/model/User.java
// public class User {
//
// private Long id;
//
// private String name;
//
// private Integer age;
//
// public Integer getAge() {
// return age;
// }
//
// public void setAge(Integer age) {
// this.age = age;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
// }
// Path: es-tutorial/src/main/java/com/micmiu/es/tutorial/EsClient.java
import com.micmiu.es.tutorial.model.User;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.search.SearchType;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.index.query.FilterBuilders;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.SearchHits;
import java.io.IOException;
package com.micmiu.es.tutorial;
/**
* Created
* User: <a href="http://micmiu.com">micmiu</a>
* Date: 6/5/2015
* Time: 12:19
*/
public class EsClient {
private Client client;
public void init() {
client = new TransportClient().addTransportAddress(
new InetSocketTransportAddress("localhost", 9300));
}
public void close() {
client.close();
}
/**
* index
*/
public void createIndex() {
for (int i = 0; i < 1000; i++) { | User user = new User(); |
micmiu/bigdata-tutorial | hbase-tutorial/src/main/java/com/micmiu/bigdata/hbase/HBaseDMLHandler.java | // Path: hbase-tutorial/src/main/java/com/micmiu/bigdata/hbase/client/HBaseClientManager.java
// public class HBaseClientManager implements HBaseConnPool {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(HBaseClientManager.class);
//
// private static final String DEF_ZNODE = "/hbase";
//
// private Configuration config;
// private HConnection conn;
//
// public HBaseClientManager() {
// this.config = HBaseConfiguration.create();
// }
//
// public HBaseClientManager(Configuration config) {
// this.config = config;
// }
//
// public HBaseClientManager(String quorum, int port) {
// //默认为 : /hbase EDH: /hyperbase1
// this(quorum, port, DEF_ZNODE);
// }
//
//
// public HBaseClientManager(String quorum, int port, String znode) {
// Configuration conf = HBaseConfiguration.create();
// conf.set("hbase.zookeeper.property.clientPort", port + "");
// conf.set("hbase.zookeeper.quorum", quorum);
// conf.set("zookeeper.znode.parent", znode);
// this.config = conf;
// }
//
// public synchronized HConnection getConn() {
// if (null == conn) {
// try {
// this.conn = HConnectionManager.createConnection(config);
// } catch (Exception ex) {
// LOGGER.error("create conn err:", ex);
// }
// }
// return conn;
// }
//
//
// public void closeConn() {
// if (null != conn) {
// try {
// conn.close();
// } catch (Exception ex) {
// ex.printStackTrace();
// }
// }
// }
//
// public void reloadConfig() {
// this.closeConn();
// this.getConn();
// }
//
// public void setup() {
//
// }
//
// public Configuration getConfig() {
// return config;
// }
//
// public void setConfig(Configuration config) {
// this.config = config;
// this.reloadConfig();
// }
// }
//
// Path: hbase-tutorial/src/main/java/com/micmiu/bigdata/hbase/client/HBaseConnPool.java
// public interface HBaseConnPool {
//
// void setup();
//
// Configuration getConfig();
//
// HConnection getConn();
//
// void closeConn();
// }
| import com.micmiu.bigdata.hbase.client.HBaseClientManager;
import com.micmiu.bigdata.hbase.client.HBaseConnPool;
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.HTableInterface;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.ResultScanner;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.util.Bytes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List; | package com.micmiu.bigdata.hbase;
/**
* HTable DML handler
* User: <a href="http://micmiu.com">micmiu</a>
* Date: 7/8/2015
* Time: 08:00
*/
public class HBaseDMLHandler extends HBaseBaseHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(HBaseDMLHandler.class);
| // Path: hbase-tutorial/src/main/java/com/micmiu/bigdata/hbase/client/HBaseClientManager.java
// public class HBaseClientManager implements HBaseConnPool {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(HBaseClientManager.class);
//
// private static final String DEF_ZNODE = "/hbase";
//
// private Configuration config;
// private HConnection conn;
//
// public HBaseClientManager() {
// this.config = HBaseConfiguration.create();
// }
//
// public HBaseClientManager(Configuration config) {
// this.config = config;
// }
//
// public HBaseClientManager(String quorum, int port) {
// //默认为 : /hbase EDH: /hyperbase1
// this(quorum, port, DEF_ZNODE);
// }
//
//
// public HBaseClientManager(String quorum, int port, String znode) {
// Configuration conf = HBaseConfiguration.create();
// conf.set("hbase.zookeeper.property.clientPort", port + "");
// conf.set("hbase.zookeeper.quorum", quorum);
// conf.set("zookeeper.znode.parent", znode);
// this.config = conf;
// }
//
// public synchronized HConnection getConn() {
// if (null == conn) {
// try {
// this.conn = HConnectionManager.createConnection(config);
// } catch (Exception ex) {
// LOGGER.error("create conn err:", ex);
// }
// }
// return conn;
// }
//
//
// public void closeConn() {
// if (null != conn) {
// try {
// conn.close();
// } catch (Exception ex) {
// ex.printStackTrace();
// }
// }
// }
//
// public void reloadConfig() {
// this.closeConn();
// this.getConn();
// }
//
// public void setup() {
//
// }
//
// public Configuration getConfig() {
// return config;
// }
//
// public void setConfig(Configuration config) {
// this.config = config;
// this.reloadConfig();
// }
// }
//
// Path: hbase-tutorial/src/main/java/com/micmiu/bigdata/hbase/client/HBaseConnPool.java
// public interface HBaseConnPool {
//
// void setup();
//
// Configuration getConfig();
//
// HConnection getConn();
//
// void closeConn();
// }
// Path: hbase-tutorial/src/main/java/com/micmiu/bigdata/hbase/HBaseDMLHandler.java
import com.micmiu.bigdata.hbase.client.HBaseClientManager;
import com.micmiu.bigdata.hbase.client.HBaseConnPool;
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.HTableInterface;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.ResultScanner;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.util.Bytes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
package com.micmiu.bigdata.hbase;
/**
* HTable DML handler
* User: <a href="http://micmiu.com">micmiu</a>
* Date: 7/8/2015
* Time: 08:00
*/
public class HBaseDMLHandler extends HBaseBaseHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(HBaseDMLHandler.class);
| public HBaseDMLHandler(HBaseConnPool connPool) { |
micmiu/bigdata-tutorial | hbase-tutorial/src/main/java/com/micmiu/bigdata/hbase/HBaseDMLHandler.java | // Path: hbase-tutorial/src/main/java/com/micmiu/bigdata/hbase/client/HBaseClientManager.java
// public class HBaseClientManager implements HBaseConnPool {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(HBaseClientManager.class);
//
// private static final String DEF_ZNODE = "/hbase";
//
// private Configuration config;
// private HConnection conn;
//
// public HBaseClientManager() {
// this.config = HBaseConfiguration.create();
// }
//
// public HBaseClientManager(Configuration config) {
// this.config = config;
// }
//
// public HBaseClientManager(String quorum, int port) {
// //默认为 : /hbase EDH: /hyperbase1
// this(quorum, port, DEF_ZNODE);
// }
//
//
// public HBaseClientManager(String quorum, int port, String znode) {
// Configuration conf = HBaseConfiguration.create();
// conf.set("hbase.zookeeper.property.clientPort", port + "");
// conf.set("hbase.zookeeper.quorum", quorum);
// conf.set("zookeeper.znode.parent", znode);
// this.config = conf;
// }
//
// public synchronized HConnection getConn() {
// if (null == conn) {
// try {
// this.conn = HConnectionManager.createConnection(config);
// } catch (Exception ex) {
// LOGGER.error("create conn err:", ex);
// }
// }
// return conn;
// }
//
//
// public void closeConn() {
// if (null != conn) {
// try {
// conn.close();
// } catch (Exception ex) {
// ex.printStackTrace();
// }
// }
// }
//
// public void reloadConfig() {
// this.closeConn();
// this.getConn();
// }
//
// public void setup() {
//
// }
//
// public Configuration getConfig() {
// return config;
// }
//
// public void setConfig(Configuration config) {
// this.config = config;
// this.reloadConfig();
// }
// }
//
// Path: hbase-tutorial/src/main/java/com/micmiu/bigdata/hbase/client/HBaseConnPool.java
// public interface HBaseConnPool {
//
// void setup();
//
// Configuration getConfig();
//
// HConnection getConn();
//
// void closeConn();
// }
| import com.micmiu.bigdata.hbase.client.HBaseClientManager;
import com.micmiu.bigdata.hbase.client.HBaseConnPool;
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.HTableInterface;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.ResultScanner;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.util.Bytes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List; | * delete a row identified by rowkey
*
* @param tableName
* @param rowKey
* @throws Exception
*/
public void deleteQualifier(String tableName, String rowKey, String family, String qualifier) throws Exception {
HTableInterface htable = getTable(tableName);
Delete delete = new Delete(Bytes.toBytes(rowKey));
delete.deleteColumn(Bytes.toBytes(family), Bytes.toBytes(qualifier));
htable.delete(delete);
}
/**
* return all row from a table
*
* @param table
* @throws Exception
*/
public static ResultScanner scanAll(HTableInterface table) throws Exception {
Scan s = new Scan();
ResultScanner rs = table.getScanner(s);
return rs;
}
public static void main(String[] args) throws Exception {
String quorum = "192.168.0.30,192.168.0.31,192.168.0.32";
//quorum = "192.168.8.191,192.168.1.192,192.168.1.193";
int port = 2181;
String znode = "/hyperbase1"; | // Path: hbase-tutorial/src/main/java/com/micmiu/bigdata/hbase/client/HBaseClientManager.java
// public class HBaseClientManager implements HBaseConnPool {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(HBaseClientManager.class);
//
// private static final String DEF_ZNODE = "/hbase";
//
// private Configuration config;
// private HConnection conn;
//
// public HBaseClientManager() {
// this.config = HBaseConfiguration.create();
// }
//
// public HBaseClientManager(Configuration config) {
// this.config = config;
// }
//
// public HBaseClientManager(String quorum, int port) {
// //默认为 : /hbase EDH: /hyperbase1
// this(quorum, port, DEF_ZNODE);
// }
//
//
// public HBaseClientManager(String quorum, int port, String znode) {
// Configuration conf = HBaseConfiguration.create();
// conf.set("hbase.zookeeper.property.clientPort", port + "");
// conf.set("hbase.zookeeper.quorum", quorum);
// conf.set("zookeeper.znode.parent", znode);
// this.config = conf;
// }
//
// public synchronized HConnection getConn() {
// if (null == conn) {
// try {
// this.conn = HConnectionManager.createConnection(config);
// } catch (Exception ex) {
// LOGGER.error("create conn err:", ex);
// }
// }
// return conn;
// }
//
//
// public void closeConn() {
// if (null != conn) {
// try {
// conn.close();
// } catch (Exception ex) {
// ex.printStackTrace();
// }
// }
// }
//
// public void reloadConfig() {
// this.closeConn();
// this.getConn();
// }
//
// public void setup() {
//
// }
//
// public Configuration getConfig() {
// return config;
// }
//
// public void setConfig(Configuration config) {
// this.config = config;
// this.reloadConfig();
// }
// }
//
// Path: hbase-tutorial/src/main/java/com/micmiu/bigdata/hbase/client/HBaseConnPool.java
// public interface HBaseConnPool {
//
// void setup();
//
// Configuration getConfig();
//
// HConnection getConn();
//
// void closeConn();
// }
// Path: hbase-tutorial/src/main/java/com/micmiu/bigdata/hbase/HBaseDMLHandler.java
import com.micmiu.bigdata.hbase.client.HBaseClientManager;
import com.micmiu.bigdata.hbase.client.HBaseConnPool;
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.HTableInterface;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.ResultScanner;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.util.Bytes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
* delete a row identified by rowkey
*
* @param tableName
* @param rowKey
* @throws Exception
*/
public void deleteQualifier(String tableName, String rowKey, String family, String qualifier) throws Exception {
HTableInterface htable = getTable(tableName);
Delete delete = new Delete(Bytes.toBytes(rowKey));
delete.deleteColumn(Bytes.toBytes(family), Bytes.toBytes(qualifier));
htable.delete(delete);
}
/**
* return all row from a table
*
* @param table
* @throws Exception
*/
public static ResultScanner scanAll(HTableInterface table) throws Exception {
Scan s = new Scan();
ResultScanner rs = table.getScanner(s);
return rs;
}
public static void main(String[] args) throws Exception {
String quorum = "192.168.0.30,192.168.0.31,192.168.0.32";
//quorum = "192.168.8.191,192.168.1.192,192.168.1.193";
int port = 2181;
String znode = "/hyperbase1"; | HBaseConnPool connPool = new HBaseClientManager(quorum, port, znode); |
tomtom-international/configuration-service | src/test/java/com/tomtom/services/configuration/implementation/ApiHelperMethodsTest.java | // Path: src/main/java/com/tomtom/services/configuration/dto/VersionDTO.java
// @SuppressWarnings({"EqualsWhichDoesntCheckParameterClass", "squid:S2160"})
// @JsonInclude(Include.NON_EMPTY)
// @XmlRootElement(name = "version")
// @XmlAccessorType(XmlAccessType.FIELD)
// public final class VersionDTO extends ApiDTO {
// public static final int API_VERSION_MAX_LENGTH = 25;
// public static final int API_VERSION_MIN_LENGTH = 0;
//
// /**
// * Version string of service. No assumptions can be made on its format.
// */
// @JsonProperty("version")
// @XmlElement(name = "version")
// @Nullable
// private String version;
//
// /**
// * The URI of the startup configuration, which was read during startup of the service.
// * If not start configuration was specified, this element is empty.
// */
// @XmlElement(name = "startupConfigurationURI")
// @Nullable
// private String startupConfigurationURI;
//
// public VersionDTO(
// @Nonnull final String version,
// @Nullable final String startupConfigurationURI) {
// super();
// setVersion(version);
// setStartupConfigurationURI(startupConfigurationURI);
// }
//
// @SuppressWarnings({"UnusedDeclaration", "squid:MissingDeprecatedCheck", "squid:S1133"})
// @Deprecated
// VersionDTO() {
// // Default constructor required by JAX-B.
// super();
// }
//
// /**
// * For an explanation of validate(), see {@link NodeDTO}.
// */
// @Override
// public void validate() {
// validator().start();
// validator().checkString(true, "version", version,
// API_VERSION_MIN_LENGTH, API_VERSION_MAX_LENGTH);
// validator().checkString(false, "startupConfigurationURI", startupConfigurationURI,
// 0, Integer.MAX_VALUE);
// validator().done();
// }
//
// @Nonnull
// public String getVersion() {
// beforeGet();
// //noinspection ConstantConditions
// return version; // Cannot be null after validation.
// }
//
// public void setVersion(@Nonnull final String version) {
// beforeSet();
// this.version = StringUtils.trim(version);
// }
//
// @Nullable
// public String getStartupConfigurationURI() {
// beforeGet();
// return startupConfigurationURI;
// }
//
// public void setStartupConfigurationURI(@Nullable final String startupConfigurationURI) {
// beforeSet();
// this.startupConfigurationURI = StringUtils.emptyToNull(StringUtils.trim(startupConfigurationURI));
// }
// }
| import com.google.gson.Gson;
import com.tomtom.services.configuration.dto.VersionDTO;
import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; | }
@Test
public void checkStatusOK() {
LOG.info("checkStatusOK");
final Response r = new ResteasyClientBuilder().build().
target(server.getHost() + "/status").
request().
get();
Assert.assertNotNull(r);
final int status = r.getStatus();
LOG.info("status = {}", status);
Assert.assertEquals(200, status);
}
@Test
public void checkVersionWithParameters() {
LOG.info("checkVersionWithParameters");
final Response r = new ResteasyClientBuilder().build().
target(server.getHost() + "/version?x=1&y=2").
request().
get();
Assert.assertNotNull(r);
final int status = r.getStatus();
LOG.info("status = {}", status);
Assert.assertEquals(200, status);
final String s = r.readEntity(String.class);
Assert.assertEquals("{\"version\":\"1.0.0-TEST\",\"startupConfigurationURI\":\"classpath:example.json\"}",
s);
| // Path: src/main/java/com/tomtom/services/configuration/dto/VersionDTO.java
// @SuppressWarnings({"EqualsWhichDoesntCheckParameterClass", "squid:S2160"})
// @JsonInclude(Include.NON_EMPTY)
// @XmlRootElement(name = "version")
// @XmlAccessorType(XmlAccessType.FIELD)
// public final class VersionDTO extends ApiDTO {
// public static final int API_VERSION_MAX_LENGTH = 25;
// public static final int API_VERSION_MIN_LENGTH = 0;
//
// /**
// * Version string of service. No assumptions can be made on its format.
// */
// @JsonProperty("version")
// @XmlElement(name = "version")
// @Nullable
// private String version;
//
// /**
// * The URI of the startup configuration, which was read during startup of the service.
// * If not start configuration was specified, this element is empty.
// */
// @XmlElement(name = "startupConfigurationURI")
// @Nullable
// private String startupConfigurationURI;
//
// public VersionDTO(
// @Nonnull final String version,
// @Nullable final String startupConfigurationURI) {
// super();
// setVersion(version);
// setStartupConfigurationURI(startupConfigurationURI);
// }
//
// @SuppressWarnings({"UnusedDeclaration", "squid:MissingDeprecatedCheck", "squid:S1133"})
// @Deprecated
// VersionDTO() {
// // Default constructor required by JAX-B.
// super();
// }
//
// /**
// * For an explanation of validate(), see {@link NodeDTO}.
// */
// @Override
// public void validate() {
// validator().start();
// validator().checkString(true, "version", version,
// API_VERSION_MIN_LENGTH, API_VERSION_MAX_LENGTH);
// validator().checkString(false, "startupConfigurationURI", startupConfigurationURI,
// 0, Integer.MAX_VALUE);
// validator().done();
// }
//
// @Nonnull
// public String getVersion() {
// beforeGet();
// //noinspection ConstantConditions
// return version; // Cannot be null after validation.
// }
//
// public void setVersion(@Nonnull final String version) {
// beforeSet();
// this.version = StringUtils.trim(version);
// }
//
// @Nullable
// public String getStartupConfigurationURI() {
// beforeGet();
// return startupConfigurationURI;
// }
//
// public void setStartupConfigurationURI(@Nullable final String startupConfigurationURI) {
// beforeSet();
// this.startupConfigurationURI = StringUtils.emptyToNull(StringUtils.trim(startupConfigurationURI));
// }
// }
// Path: src/test/java/com/tomtom/services/configuration/implementation/ApiHelperMethodsTest.java
import com.google.gson.Gson;
import com.tomtom.services.configuration.dto.VersionDTO;
import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
}
@Test
public void checkStatusOK() {
LOG.info("checkStatusOK");
final Response r = new ResteasyClientBuilder().build().
target(server.getHost() + "/status").
request().
get();
Assert.assertNotNull(r);
final int status = r.getStatus();
LOG.info("status = {}", status);
Assert.assertEquals(200, status);
}
@Test
public void checkVersionWithParameters() {
LOG.info("checkVersionWithParameters");
final Response r = new ResteasyClientBuilder().build().
target(server.getHost() + "/version?x=1&y=2").
request().
get();
Assert.assertNotNull(r);
final int status = r.getStatus();
LOG.info("status = {}", status);
Assert.assertEquals(200, status);
final String s = r.readEntity(String.class);
Assert.assertEquals("{\"version\":\"1.0.0-TEST\",\"startupConfigurationURI\":\"classpath:example.json\"}",
s);
| final VersionDTO x = new Gson().fromJson(s, VersionDTO.class); |
tomtom-international/configuration-service | src/main/java/com/tomtom/services/configuration/dto/ParameterDTO.java | // Path: src/main/java/com/tomtom/services/configuration/domain/Parameter.java
// @Immutable
// @JsonInclude(Include.NON_EMPTY)
// public final class Parameter {
//
// @Nonnull
// private final String key;
//
// @Nonnull
// private final String value;
//
// public Parameter(
// @Nonnull final String key,
// @Nonnull final String value) {
// this.key = key;
// this.value = value;
// }
//
// public Parameter(@Nonnull final ParameterDTO parameterDTO) {
// //noinspection ConstantConditions Already checked in Configuration during load
// this(parameterDTO.getKey(), parameterDTO.getValue());
// }
//
// @Nonnull
// public String getKey() {
// return key;
// }
//
// @Nonnull
// public String getValue() {
// return value;
// }
//
// @Override
// @Nonnull
// public String toString() {
// return Json.toJson(this);
// }
// }
| import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.tomtom.services.configuration.domain.Parameter;
import com.tomtom.speedtools.apivalidation.ApiDTO;
import com.tomtom.speedtools.utils.StringUtils;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; | /*
* Copyright (C) 2012-2021, TomTom (http://tomtom.com).
*
* 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 com.tomtom.services.configuration.dto;
@SuppressWarnings({"EqualsWhichDoesntCheckParameterClass", "NullableProblems", "NonFinalFieldReferenceInEquals", "NonFinalFieldReferencedInHashCode", "squid:S2160"})
@JsonInclude(Include.NON_EMPTY)
@XmlRootElement(name = "parameter")
@XmlAccessorType(XmlAccessType.FIELD)
public final class ParameterDTO extends ApiDTO implements SupportsInclude {
/**
* Key name. Cannot be null or empty after parsing includes.
*/
@JsonProperty("key")
@XmlElement(name = "key")
@Nullable
private String key;
/**
* Value. Cannot be null after parsing includes, but can be empty.
*/
@JsonProperty("value")
@XmlElement(name = "value")
@Nullable
private String value;
/**
* Include name. Can be null.
*/
@JsonProperty("include")
@XmlElement(name = "include")
@Nullable
private String include;
/**
* Include name. Can be null.
*/
@JsonProperty("include_array")
@XmlElement(name = "include_array")
@Nullable
private String includeArray;
public ParameterDTO(
@Nonnull final String key,
@Nonnull final String value) {
super(false);
setKey(key);
setValue(value);
}
/**
* Convert a Parameter object into a ParameterDTO.
*
* @param parameter Parameter to convert.
*/ | // Path: src/main/java/com/tomtom/services/configuration/domain/Parameter.java
// @Immutable
// @JsonInclude(Include.NON_EMPTY)
// public final class Parameter {
//
// @Nonnull
// private final String key;
//
// @Nonnull
// private final String value;
//
// public Parameter(
// @Nonnull final String key,
// @Nonnull final String value) {
// this.key = key;
// this.value = value;
// }
//
// public Parameter(@Nonnull final ParameterDTO parameterDTO) {
// //noinspection ConstantConditions Already checked in Configuration during load
// this(parameterDTO.getKey(), parameterDTO.getValue());
// }
//
// @Nonnull
// public String getKey() {
// return key;
// }
//
// @Nonnull
// public String getValue() {
// return value;
// }
//
// @Override
// @Nonnull
// public String toString() {
// return Json.toJson(this);
// }
// }
// Path: src/main/java/com/tomtom/services/configuration/dto/ParameterDTO.java
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.tomtom.services.configuration.domain.Parameter;
import com.tomtom.speedtools.apivalidation.ApiDTO;
import com.tomtom.speedtools.utils.StringUtils;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
/*
* Copyright (C) 2012-2021, TomTom (http://tomtom.com).
*
* 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 com.tomtom.services.configuration.dto;
@SuppressWarnings({"EqualsWhichDoesntCheckParameterClass", "NullableProblems", "NonFinalFieldReferenceInEquals", "NonFinalFieldReferencedInHashCode", "squid:S2160"})
@JsonInclude(Include.NON_EMPTY)
@XmlRootElement(name = "parameter")
@XmlAccessorType(XmlAccessType.FIELD)
public final class ParameterDTO extends ApiDTO implements SupportsInclude {
/**
* Key name. Cannot be null or empty after parsing includes.
*/
@JsonProperty("key")
@XmlElement(name = "key")
@Nullable
private String key;
/**
* Value. Cannot be null after parsing includes, but can be empty.
*/
@JsonProperty("value")
@XmlElement(name = "value")
@Nullable
private String value;
/**
* Include name. Can be null.
*/
@JsonProperty("include")
@XmlElement(name = "include")
@Nullable
private String include;
/**
* Include name. Can be null.
*/
@JsonProperty("include_array")
@XmlElement(name = "include_array")
@Nullable
private String includeArray;
public ParameterDTO(
@Nonnull final String key,
@Nonnull final String value) {
super(false);
setKey(key);
setValue(value);
}
/**
* Convert a Parameter object into a ParameterDTO.
*
* @param parameter Parameter to convert.
*/ | public ParameterDTO(@Nonnull final Parameter parameter) { |
tomtom-international/configuration-service | src/test/java/com/tomtom/services/configuration/implementation/LocalTestServer.java | // Path: src/main/java/com/tomtom/services/configuration/ConfigurationServiceProperties.java
// @SuppressWarnings("squid:S2637")
// public class ConfigurationServiceProperties implements HasProperties {
//
// @Nonnull
// private final String startupConfigurationURI;
//
// @Inject
// public ConfigurationServiceProperties(
// @Named("ConfigurationService.startupConfigurationURI") @Nonnull final String startupConfigurationURI) {
// this.startupConfigurationURI = startupConfigurationURI.trim();
// }
//
// @Nonnull
// public String getStartupConfigurationURI() {
// return startupConfigurationURI;
// }
// }
| import com.tomtom.services.configuration.ConfigurationServiceProperties;
import com.tomtom.speedtools.maven.MavenProperties;
import com.tomtom.speedtools.rest.Reactor;
import com.tomtom.speedtools.rest.ResourceProcessor;
import com.tomtom.speedtools.testutils.SimpleExecutionContext;
import org.jboss.resteasy.plugins.server.tjws.TJWSEmbeddedJaxrsServer;
import org.joda.time.DateTime;
import org.junit.After;
import org.junit.Before;
import scala.concurrent.ExecutionContext;
import javax.annotation.Nonnull; | /*
* Copyright (C) 2012-2021, TomTom (http://tomtom.com).
*
* 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 com.tomtom.services.configuration.implementation;
@SuppressWarnings("JUnitTestMethodWithNoAssertions")
public class LocalTestServer {
private static final int PORT = 8081;
private static final String HOST = "http://localhost:";
final private TJWSEmbeddedJaxrsServer server;
private final String config;
private final int port;
public LocalTestServer(@Nonnull final String config) {
this.config = config;
this.port = PORT;
server = new TJWSEmbeddedJaxrsServer();
server.setPort(port);
}
@Before
public void startServer() throws IncorrectConfigurationException { | // Path: src/main/java/com/tomtom/services/configuration/ConfigurationServiceProperties.java
// @SuppressWarnings("squid:S2637")
// public class ConfigurationServiceProperties implements HasProperties {
//
// @Nonnull
// private final String startupConfigurationURI;
//
// @Inject
// public ConfigurationServiceProperties(
// @Named("ConfigurationService.startupConfigurationURI") @Nonnull final String startupConfigurationURI) {
// this.startupConfigurationURI = startupConfigurationURI.trim();
// }
//
// @Nonnull
// public String getStartupConfigurationURI() {
// return startupConfigurationURI;
// }
// }
// Path: src/test/java/com/tomtom/services/configuration/implementation/LocalTestServer.java
import com.tomtom.services.configuration.ConfigurationServiceProperties;
import com.tomtom.speedtools.maven.MavenProperties;
import com.tomtom.speedtools.rest.Reactor;
import com.tomtom.speedtools.rest.ResourceProcessor;
import com.tomtom.speedtools.testutils.SimpleExecutionContext;
import org.jboss.resteasy.plugins.server.tjws.TJWSEmbeddedJaxrsServer;
import org.joda.time.DateTime;
import org.junit.After;
import org.junit.Before;
import scala.concurrent.ExecutionContext;
import javax.annotation.Nonnull;
/*
* Copyright (C) 2012-2021, TomTom (http://tomtom.com).
*
* 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 com.tomtom.services.configuration.implementation;
@SuppressWarnings("JUnitTestMethodWithNoAssertions")
public class LocalTestServer {
private static final int PORT = 8081;
private static final String HOST = "http://localhost:";
final private TJWSEmbeddedJaxrsServer server;
private final String config;
private final int port;
public LocalTestServer(@Nonnull final String config) {
this.config = config;
this.port = PORT;
server = new TJWSEmbeddedJaxrsServer();
server.setPort(port);
}
@Before
public void startServer() throws IncorrectConfigurationException { | final ConfigurationServiceProperties configurationServiceProperties = |
tomtom-international/configuration-service | src/main/java/com/tomtom/services/configuration/domain/Parameter.java | // Path: src/main/java/com/tomtom/services/configuration/dto/ParameterDTO.java
// @SuppressWarnings({"EqualsWhichDoesntCheckParameterClass", "NullableProblems", "NonFinalFieldReferenceInEquals", "NonFinalFieldReferencedInHashCode", "squid:S2160"})
// @JsonInclude(Include.NON_EMPTY)
// @XmlRootElement(name = "parameter")
// @XmlAccessorType(XmlAccessType.FIELD)
// public final class ParameterDTO extends ApiDTO implements SupportsInclude {
//
// /**
// * Key name. Cannot be null or empty after parsing includes.
// */
// @JsonProperty("key")
// @XmlElement(name = "key")
// @Nullable
// private String key;
//
// /**
// * Value. Cannot be null after parsing includes, but can be empty.
// */
// @JsonProperty("value")
// @XmlElement(name = "value")
// @Nullable
// private String value;
//
// /**
// * Include name. Can be null.
// */
// @JsonProperty("include")
// @XmlElement(name = "include")
// @Nullable
// private String include;
//
// /**
// * Include name. Can be null.
// */
// @JsonProperty("include_array")
// @XmlElement(name = "include_array")
// @Nullable
// private String includeArray;
//
// public ParameterDTO(
// @Nonnull final String key,
// @Nonnull final String value) {
// super(false);
// setKey(key);
// setValue(value);
// }
//
// /**
// * Convert a Parameter object into a ParameterDTO.
// *
// * @param parameter Parameter to convert.
// */
// public ParameterDTO(@Nonnull final Parameter parameter) {
// this(parameter.getKey(), parameter.getValue());
// }
//
// @SuppressWarnings({"UnusedDeclaration", "squid:MissingDeprecatedCheck", "squid:S1133"})
// @Deprecated
// ParameterDTO() {
// // Default constructor required by JAX-B.
// super(false);
// }
//
// /**
// * For an explanation of validate(), see {@link NodeDTO}.
// */
// @Override
// public void validate() {
// validator().start();
//
// // This validation is ONLY executed after includes have been expanded, so they must be null.
// validator().checkNull(true, "include_array", includeArray);
// validator().checkNull(true, "include", include);
// validator().checkNotNull(true, "key", key);
// validator().checkString(true, "key", key, 1, Integer.MAX_VALUE);
// validator().checkNotNull(true, "value", value);
// validator().done();
// }
//
// @Override
// @Nullable
// public String getIncludeArray() {
// beforeGet();
// return includeArray;
// }
//
// public void setIncludeArray(@Nonnull final String includeArray) {
// beforeSet();
// this.includeArray = includeArray.trim();
// }
//
// @Override
// @Nullable
// public String getInclude() {
// beforeGet();
// return include;
// }
//
// public void setInclude(@Nonnull final String include) {
// beforeSet();
// this.include = include.trim();
// }
//
// @Nullable
// public String getKey() {
// beforeGet();
// return key;
// }
//
// public void setKey(@Nonnull final String key) {
// beforeSet();
// this.key = key.trim();
// }
//
// @Nullable
// public String getValue() {
// beforeGet();
// return value;
// }
//
// public void setValue(@Nonnull final String value) {
// beforeSet();
// this.value = StringUtils.trim(value); // Empty string allowed.
// }
// }
| import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.tomtom.services.configuration.dto.ParameterDTO;
import com.tomtom.speedtools.json.Json;
import javax.annotation.Nonnull;
import javax.annotation.concurrent.Immutable; | /*
* Copyright (C) 2012-2021, TomTom (http://tomtom.com).
*
* 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 com.tomtom.services.configuration.domain;
/**
* This class contains a single parameter, which is a
* key, value pair.
*/
@Immutable
@JsonInclude(Include.NON_EMPTY)
public final class Parameter {
@Nonnull
private final String key;
@Nonnull
private final String value;
public Parameter(
@Nonnull final String key,
@Nonnull final String value) {
this.key = key;
this.value = value;
}
| // Path: src/main/java/com/tomtom/services/configuration/dto/ParameterDTO.java
// @SuppressWarnings({"EqualsWhichDoesntCheckParameterClass", "NullableProblems", "NonFinalFieldReferenceInEquals", "NonFinalFieldReferencedInHashCode", "squid:S2160"})
// @JsonInclude(Include.NON_EMPTY)
// @XmlRootElement(name = "parameter")
// @XmlAccessorType(XmlAccessType.FIELD)
// public final class ParameterDTO extends ApiDTO implements SupportsInclude {
//
// /**
// * Key name. Cannot be null or empty after parsing includes.
// */
// @JsonProperty("key")
// @XmlElement(name = "key")
// @Nullable
// private String key;
//
// /**
// * Value. Cannot be null after parsing includes, but can be empty.
// */
// @JsonProperty("value")
// @XmlElement(name = "value")
// @Nullable
// private String value;
//
// /**
// * Include name. Can be null.
// */
// @JsonProperty("include")
// @XmlElement(name = "include")
// @Nullable
// private String include;
//
// /**
// * Include name. Can be null.
// */
// @JsonProperty("include_array")
// @XmlElement(name = "include_array")
// @Nullable
// private String includeArray;
//
// public ParameterDTO(
// @Nonnull final String key,
// @Nonnull final String value) {
// super(false);
// setKey(key);
// setValue(value);
// }
//
// /**
// * Convert a Parameter object into a ParameterDTO.
// *
// * @param parameter Parameter to convert.
// */
// public ParameterDTO(@Nonnull final Parameter parameter) {
// this(parameter.getKey(), parameter.getValue());
// }
//
// @SuppressWarnings({"UnusedDeclaration", "squid:MissingDeprecatedCheck", "squid:S1133"})
// @Deprecated
// ParameterDTO() {
// // Default constructor required by JAX-B.
// super(false);
// }
//
// /**
// * For an explanation of validate(), see {@link NodeDTO}.
// */
// @Override
// public void validate() {
// validator().start();
//
// // This validation is ONLY executed after includes have been expanded, so they must be null.
// validator().checkNull(true, "include_array", includeArray);
// validator().checkNull(true, "include", include);
// validator().checkNotNull(true, "key", key);
// validator().checkString(true, "key", key, 1, Integer.MAX_VALUE);
// validator().checkNotNull(true, "value", value);
// validator().done();
// }
//
// @Override
// @Nullable
// public String getIncludeArray() {
// beforeGet();
// return includeArray;
// }
//
// public void setIncludeArray(@Nonnull final String includeArray) {
// beforeSet();
// this.includeArray = includeArray.trim();
// }
//
// @Override
// @Nullable
// public String getInclude() {
// beforeGet();
// return include;
// }
//
// public void setInclude(@Nonnull final String include) {
// beforeSet();
// this.include = include.trim();
// }
//
// @Nullable
// public String getKey() {
// beforeGet();
// return key;
// }
//
// public void setKey(@Nonnull final String key) {
// beforeSet();
// this.key = key.trim();
// }
//
// @Nullable
// public String getValue() {
// beforeGet();
// return value;
// }
//
// public void setValue(@Nonnull final String value) {
// beforeSet();
// this.value = StringUtils.trim(value); // Empty string allowed.
// }
// }
// Path: src/main/java/com/tomtom/services/configuration/domain/Parameter.java
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.tomtom.services.configuration.dto.ParameterDTO;
import com.tomtom.speedtools.json.Json;
import javax.annotation.Nonnull;
import javax.annotation.concurrent.Immutable;
/*
* Copyright (C) 2012-2021, TomTom (http://tomtom.com).
*
* 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 com.tomtom.services.configuration.domain;
/**
* This class contains a single parameter, which is a
* key, value pair.
*/
@Immutable
@JsonInclude(Include.NON_EMPTY)
public final class Parameter {
@Nonnull
private final String key;
@Nonnull
private final String value;
public Parameter(
@Nonnull final String key,
@Nonnull final String value) {
this.key = key;
this.value = value;
}
| public Parameter(@Nonnull final ParameterDTO parameterDTO) { |
tomtom-international/configuration-service | src/main/java/com/tomtom/services/configuration/implementation/HelperResourceImpl.java | // Path: src/main/java/com/tomtom/services/configuration/ConfigurationServiceProperties.java
// @SuppressWarnings("squid:S2637")
// public class ConfigurationServiceProperties implements HasProperties {
//
// @Nonnull
// private final String startupConfigurationURI;
//
// @Inject
// public ConfigurationServiceProperties(
// @Named("ConfigurationService.startupConfigurationURI") @Nonnull final String startupConfigurationURI) {
// this.startupConfigurationURI = startupConfigurationURI.trim();
// }
//
// @Nonnull
// public String getStartupConfigurationURI() {
// return startupConfigurationURI;
// }
// }
//
// Path: src/main/java/com/tomtom/services/configuration/HelperResource.java
// @Path("/")
// public interface HelperResource {
//
// /**
// * This method provides help info.
// *
// * @return Returns help text as HTML.
// */
// @GET
// @Produces(MediaType.TEXT_HTML)
// @Nonnull
// String getHelpHTML();
//
// /**
// * Additional method: this method returns the current version of the application.
// * <p>
// * Return HTTP status 200.
// *
// * @param response Version, {@link com.tomtom.services.configuration.dto.VersionDTO}.
// */
// @GET
// @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
// @Path("version")
// void getVersion(@Suspended @Nonnull AsyncResponse response);
//
// /**
// * This method returns whether the service is operational or not (status code 200 is OK).
// *
// * @param response Returns a version number as JSON.
// */
// @GET
// @Path("status")
// @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
// void getStatus(@Suspended @Nonnull AsyncResponse response);
// }
//
// Path: src/main/java/com/tomtom/services/configuration/dto/VersionDTO.java
// @SuppressWarnings({"EqualsWhichDoesntCheckParameterClass", "squid:S2160"})
// @JsonInclude(Include.NON_EMPTY)
// @XmlRootElement(name = "version")
// @XmlAccessorType(XmlAccessType.FIELD)
// public final class VersionDTO extends ApiDTO {
// public static final int API_VERSION_MAX_LENGTH = 25;
// public static final int API_VERSION_MIN_LENGTH = 0;
//
// /**
// * Version string of service. No assumptions can be made on its format.
// */
// @JsonProperty("version")
// @XmlElement(name = "version")
// @Nullable
// private String version;
//
// /**
// * The URI of the startup configuration, which was read during startup of the service.
// * If not start configuration was specified, this element is empty.
// */
// @XmlElement(name = "startupConfigurationURI")
// @Nullable
// private String startupConfigurationURI;
//
// public VersionDTO(
// @Nonnull final String version,
// @Nullable final String startupConfigurationURI) {
// super();
// setVersion(version);
// setStartupConfigurationURI(startupConfigurationURI);
// }
//
// @SuppressWarnings({"UnusedDeclaration", "squid:MissingDeprecatedCheck", "squid:S1133"})
// @Deprecated
// VersionDTO() {
// // Default constructor required by JAX-B.
// super();
// }
//
// /**
// * For an explanation of validate(), see {@link NodeDTO}.
// */
// @Override
// public void validate() {
// validator().start();
// validator().checkString(true, "version", version,
// API_VERSION_MIN_LENGTH, API_VERSION_MAX_LENGTH);
// validator().checkString(false, "startupConfigurationURI", startupConfigurationURI,
// 0, Integer.MAX_VALUE);
// validator().done();
// }
//
// @Nonnull
// public String getVersion() {
// beforeGet();
// //noinspection ConstantConditions
// return version; // Cannot be null after validation.
// }
//
// public void setVersion(@Nonnull final String version) {
// beforeSet();
// this.version = StringUtils.trim(version);
// }
//
// @Nullable
// public String getStartupConfigurationURI() {
// beforeGet();
// return startupConfigurationURI;
// }
//
// public void setStartupConfigurationURI(@Nullable final String startupConfigurationURI) {
// beforeSet();
// this.startupConfigurationURI = StringUtils.emptyToNull(StringUtils.trim(startupConfigurationURI));
// }
// }
| import com.google.common.base.Joiner;
import com.tomtom.services.configuration.ConfigurationServiceProperties;
import com.tomtom.services.configuration.HelperResource;
import com.tomtom.services.configuration.dto.VersionDTO;
import com.tomtom.speedtools.maven.MavenProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nonnull;
import javax.inject.Inject;
import javax.ws.rs.container.AsyncResponse;
import javax.ws.rs.container.Suspended;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status; | "It just returns a node if it exists or `404 NOT FOUND` if it doesn't.\n" +
"The returned response looks like this:\n\n" +
" {\"nodes\": [\"{node1}\", \"{node2}\", ...],\n" +
" \"parameters\": [{\"key\": \"{key1}\", \"value\": \"{value1}\"]}, ...]," +
" \"match\": \"{node-name\"}}\n\n" +
"The \"nodes\" array is optional and lists the children nodes with search\n" +
"terms one level below the specified node.\n\n" +
"The \"parameters\" value is the optional leaf node of this node and lists the\n" +
"search result (an array of key-value pairs).\n\n" +
"Note that this is exactly the same format as the configuration file for the service.\n" +
"Return codes:\n" +
" Successful call: 200 - OK\n" +
" Not modified since If-Modified-Since or ETag not changed: 304 - NOT MODIFIED\n" +
" Node not found or no search result found: 404 - NOT FOUND\n";
/**
* The search tree, which holds all configurations.
*/
@Nonnull
private final Configuration configuration;
/**
* Specific ACDS properties from the properties file.
*/
@Nonnull | // Path: src/main/java/com/tomtom/services/configuration/ConfigurationServiceProperties.java
// @SuppressWarnings("squid:S2637")
// public class ConfigurationServiceProperties implements HasProperties {
//
// @Nonnull
// private final String startupConfigurationURI;
//
// @Inject
// public ConfigurationServiceProperties(
// @Named("ConfigurationService.startupConfigurationURI") @Nonnull final String startupConfigurationURI) {
// this.startupConfigurationURI = startupConfigurationURI.trim();
// }
//
// @Nonnull
// public String getStartupConfigurationURI() {
// return startupConfigurationURI;
// }
// }
//
// Path: src/main/java/com/tomtom/services/configuration/HelperResource.java
// @Path("/")
// public interface HelperResource {
//
// /**
// * This method provides help info.
// *
// * @return Returns help text as HTML.
// */
// @GET
// @Produces(MediaType.TEXT_HTML)
// @Nonnull
// String getHelpHTML();
//
// /**
// * Additional method: this method returns the current version of the application.
// * <p>
// * Return HTTP status 200.
// *
// * @param response Version, {@link com.tomtom.services.configuration.dto.VersionDTO}.
// */
// @GET
// @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
// @Path("version")
// void getVersion(@Suspended @Nonnull AsyncResponse response);
//
// /**
// * This method returns whether the service is operational or not (status code 200 is OK).
// *
// * @param response Returns a version number as JSON.
// */
// @GET
// @Path("status")
// @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
// void getStatus(@Suspended @Nonnull AsyncResponse response);
// }
//
// Path: src/main/java/com/tomtom/services/configuration/dto/VersionDTO.java
// @SuppressWarnings({"EqualsWhichDoesntCheckParameterClass", "squid:S2160"})
// @JsonInclude(Include.NON_EMPTY)
// @XmlRootElement(name = "version")
// @XmlAccessorType(XmlAccessType.FIELD)
// public final class VersionDTO extends ApiDTO {
// public static final int API_VERSION_MAX_LENGTH = 25;
// public static final int API_VERSION_MIN_LENGTH = 0;
//
// /**
// * Version string of service. No assumptions can be made on its format.
// */
// @JsonProperty("version")
// @XmlElement(name = "version")
// @Nullable
// private String version;
//
// /**
// * The URI of the startup configuration, which was read during startup of the service.
// * If not start configuration was specified, this element is empty.
// */
// @XmlElement(name = "startupConfigurationURI")
// @Nullable
// private String startupConfigurationURI;
//
// public VersionDTO(
// @Nonnull final String version,
// @Nullable final String startupConfigurationURI) {
// super();
// setVersion(version);
// setStartupConfigurationURI(startupConfigurationURI);
// }
//
// @SuppressWarnings({"UnusedDeclaration", "squid:MissingDeprecatedCheck", "squid:S1133"})
// @Deprecated
// VersionDTO() {
// // Default constructor required by JAX-B.
// super();
// }
//
// /**
// * For an explanation of validate(), see {@link NodeDTO}.
// */
// @Override
// public void validate() {
// validator().start();
// validator().checkString(true, "version", version,
// API_VERSION_MIN_LENGTH, API_VERSION_MAX_LENGTH);
// validator().checkString(false, "startupConfigurationURI", startupConfigurationURI,
// 0, Integer.MAX_VALUE);
// validator().done();
// }
//
// @Nonnull
// public String getVersion() {
// beforeGet();
// //noinspection ConstantConditions
// return version; // Cannot be null after validation.
// }
//
// public void setVersion(@Nonnull final String version) {
// beforeSet();
// this.version = StringUtils.trim(version);
// }
//
// @Nullable
// public String getStartupConfigurationURI() {
// beforeGet();
// return startupConfigurationURI;
// }
//
// public void setStartupConfigurationURI(@Nullable final String startupConfigurationURI) {
// beforeSet();
// this.startupConfigurationURI = StringUtils.emptyToNull(StringUtils.trim(startupConfigurationURI));
// }
// }
// Path: src/main/java/com/tomtom/services/configuration/implementation/HelperResourceImpl.java
import com.google.common.base.Joiner;
import com.tomtom.services.configuration.ConfigurationServiceProperties;
import com.tomtom.services.configuration.HelperResource;
import com.tomtom.services.configuration.dto.VersionDTO;
import com.tomtom.speedtools.maven.MavenProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nonnull;
import javax.inject.Inject;
import javax.ws.rs.container.AsyncResponse;
import javax.ws.rs.container.Suspended;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
"It just returns a node if it exists or `404 NOT FOUND` if it doesn't.\n" +
"The returned response looks like this:\n\n" +
" {\"nodes\": [\"{node1}\", \"{node2}\", ...],\n" +
" \"parameters\": [{\"key\": \"{key1}\", \"value\": \"{value1}\"]}, ...]," +
" \"match\": \"{node-name\"}}\n\n" +
"The \"nodes\" array is optional and lists the children nodes with search\n" +
"terms one level below the specified node.\n\n" +
"The \"parameters\" value is the optional leaf node of this node and lists the\n" +
"search result (an array of key-value pairs).\n\n" +
"Note that this is exactly the same format as the configuration file for the service.\n" +
"Return codes:\n" +
" Successful call: 200 - OK\n" +
" Not modified since If-Modified-Since or ETag not changed: 304 - NOT MODIFIED\n" +
" Node not found or no search result found: 404 - NOT FOUND\n";
/**
* The search tree, which holds all configurations.
*/
@Nonnull
private final Configuration configuration;
/**
* Specific ACDS properties from the properties file.
*/
@Nonnull | private final ConfigurationServiceProperties configurationServiceProperties; |
tomtom-international/configuration-service | src/main/java/com/tomtom/services/configuration/implementation/HelperResourceImpl.java | // Path: src/main/java/com/tomtom/services/configuration/ConfigurationServiceProperties.java
// @SuppressWarnings("squid:S2637")
// public class ConfigurationServiceProperties implements HasProperties {
//
// @Nonnull
// private final String startupConfigurationURI;
//
// @Inject
// public ConfigurationServiceProperties(
// @Named("ConfigurationService.startupConfigurationURI") @Nonnull final String startupConfigurationURI) {
// this.startupConfigurationURI = startupConfigurationURI.trim();
// }
//
// @Nonnull
// public String getStartupConfigurationURI() {
// return startupConfigurationURI;
// }
// }
//
// Path: src/main/java/com/tomtom/services/configuration/HelperResource.java
// @Path("/")
// public interface HelperResource {
//
// /**
// * This method provides help info.
// *
// * @return Returns help text as HTML.
// */
// @GET
// @Produces(MediaType.TEXT_HTML)
// @Nonnull
// String getHelpHTML();
//
// /**
// * Additional method: this method returns the current version of the application.
// * <p>
// * Return HTTP status 200.
// *
// * @param response Version, {@link com.tomtom.services.configuration.dto.VersionDTO}.
// */
// @GET
// @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
// @Path("version")
// void getVersion(@Suspended @Nonnull AsyncResponse response);
//
// /**
// * This method returns whether the service is operational or not (status code 200 is OK).
// *
// * @param response Returns a version number as JSON.
// */
// @GET
// @Path("status")
// @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
// void getStatus(@Suspended @Nonnull AsyncResponse response);
// }
//
// Path: src/main/java/com/tomtom/services/configuration/dto/VersionDTO.java
// @SuppressWarnings({"EqualsWhichDoesntCheckParameterClass", "squid:S2160"})
// @JsonInclude(Include.NON_EMPTY)
// @XmlRootElement(name = "version")
// @XmlAccessorType(XmlAccessType.FIELD)
// public final class VersionDTO extends ApiDTO {
// public static final int API_VERSION_MAX_LENGTH = 25;
// public static final int API_VERSION_MIN_LENGTH = 0;
//
// /**
// * Version string of service. No assumptions can be made on its format.
// */
// @JsonProperty("version")
// @XmlElement(name = "version")
// @Nullable
// private String version;
//
// /**
// * The URI of the startup configuration, which was read during startup of the service.
// * If not start configuration was specified, this element is empty.
// */
// @XmlElement(name = "startupConfigurationURI")
// @Nullable
// private String startupConfigurationURI;
//
// public VersionDTO(
// @Nonnull final String version,
// @Nullable final String startupConfigurationURI) {
// super();
// setVersion(version);
// setStartupConfigurationURI(startupConfigurationURI);
// }
//
// @SuppressWarnings({"UnusedDeclaration", "squid:MissingDeprecatedCheck", "squid:S1133"})
// @Deprecated
// VersionDTO() {
// // Default constructor required by JAX-B.
// super();
// }
//
// /**
// * For an explanation of validate(), see {@link NodeDTO}.
// */
// @Override
// public void validate() {
// validator().start();
// validator().checkString(true, "version", version,
// API_VERSION_MIN_LENGTH, API_VERSION_MAX_LENGTH);
// validator().checkString(false, "startupConfigurationURI", startupConfigurationURI,
// 0, Integer.MAX_VALUE);
// validator().done();
// }
//
// @Nonnull
// public String getVersion() {
// beforeGet();
// //noinspection ConstantConditions
// return version; // Cannot be null after validation.
// }
//
// public void setVersion(@Nonnull final String version) {
// beforeSet();
// this.version = StringUtils.trim(version);
// }
//
// @Nullable
// public String getStartupConfigurationURI() {
// beforeGet();
// return startupConfigurationURI;
// }
//
// public void setStartupConfigurationURI(@Nullable final String startupConfigurationURI) {
// beforeSet();
// this.startupConfigurationURI = StringUtils.emptyToNull(StringUtils.trim(startupConfigurationURI));
// }
// }
| import com.google.common.base.Joiner;
import com.tomtom.services.configuration.ConfigurationServiceProperties;
import com.tomtom.services.configuration.HelperResource;
import com.tomtom.services.configuration.dto.VersionDTO;
import com.tomtom.speedtools.maven.MavenProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nonnull;
import javax.inject.Inject;
import javax.ws.rs.container.AsyncResponse;
import javax.ws.rs.container.Suspended;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status; | // Store the injected values.
this.configuration = configuration;
this.configurationServiceProperties = configurationServiceProperties;
this.mavenProperties = mavenProperties;
}
@Override
@Nonnull
public String getHelpHTML() {
LOG.info("getHelpHTML: show help page", mavenProperties.getPomVersion());
return "<html><pre>\n" +
"CONFIGURATION SERVICE (" + mavenProperties.getPomVersion() + ")\n" +
"---------------------\n\n" +
HELP_TEXT + '\n' +
(configuration.getRoot().getLevels() == null ? "" :
"CURRENT CONFIGURATION\n\n" +
"The current configuration used by the service is:\n" +
" URI=" + configuration.getStartupConfigurationURI() + '\n' +
" levels=" + Joiner.on("/").join(configuration.getRoot().getLevels())) +
"\n</pre></html>\n";
}
@Override
public void getVersion(@Suspended @Nonnull final AsyncResponse response) {
// No input validation required. Just return version number.
final String pomVersion = mavenProperties.getPomVersion();
final String startupConfigurationURI = configurationServiceProperties.getStartupConfigurationURI();
LOG.info("getVersion: POM version={}, startupConfigurationURI={}", pomVersion, startupConfigurationURI);
| // Path: src/main/java/com/tomtom/services/configuration/ConfigurationServiceProperties.java
// @SuppressWarnings("squid:S2637")
// public class ConfigurationServiceProperties implements HasProperties {
//
// @Nonnull
// private final String startupConfigurationURI;
//
// @Inject
// public ConfigurationServiceProperties(
// @Named("ConfigurationService.startupConfigurationURI") @Nonnull final String startupConfigurationURI) {
// this.startupConfigurationURI = startupConfigurationURI.trim();
// }
//
// @Nonnull
// public String getStartupConfigurationURI() {
// return startupConfigurationURI;
// }
// }
//
// Path: src/main/java/com/tomtom/services/configuration/HelperResource.java
// @Path("/")
// public interface HelperResource {
//
// /**
// * This method provides help info.
// *
// * @return Returns help text as HTML.
// */
// @GET
// @Produces(MediaType.TEXT_HTML)
// @Nonnull
// String getHelpHTML();
//
// /**
// * Additional method: this method returns the current version of the application.
// * <p>
// * Return HTTP status 200.
// *
// * @param response Version, {@link com.tomtom.services.configuration.dto.VersionDTO}.
// */
// @GET
// @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
// @Path("version")
// void getVersion(@Suspended @Nonnull AsyncResponse response);
//
// /**
// * This method returns whether the service is operational or not (status code 200 is OK).
// *
// * @param response Returns a version number as JSON.
// */
// @GET
// @Path("status")
// @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
// void getStatus(@Suspended @Nonnull AsyncResponse response);
// }
//
// Path: src/main/java/com/tomtom/services/configuration/dto/VersionDTO.java
// @SuppressWarnings({"EqualsWhichDoesntCheckParameterClass", "squid:S2160"})
// @JsonInclude(Include.NON_EMPTY)
// @XmlRootElement(name = "version")
// @XmlAccessorType(XmlAccessType.FIELD)
// public final class VersionDTO extends ApiDTO {
// public static final int API_VERSION_MAX_LENGTH = 25;
// public static final int API_VERSION_MIN_LENGTH = 0;
//
// /**
// * Version string of service. No assumptions can be made on its format.
// */
// @JsonProperty("version")
// @XmlElement(name = "version")
// @Nullable
// private String version;
//
// /**
// * The URI of the startup configuration, which was read during startup of the service.
// * If not start configuration was specified, this element is empty.
// */
// @XmlElement(name = "startupConfigurationURI")
// @Nullable
// private String startupConfigurationURI;
//
// public VersionDTO(
// @Nonnull final String version,
// @Nullable final String startupConfigurationURI) {
// super();
// setVersion(version);
// setStartupConfigurationURI(startupConfigurationURI);
// }
//
// @SuppressWarnings({"UnusedDeclaration", "squid:MissingDeprecatedCheck", "squid:S1133"})
// @Deprecated
// VersionDTO() {
// // Default constructor required by JAX-B.
// super();
// }
//
// /**
// * For an explanation of validate(), see {@link NodeDTO}.
// */
// @Override
// public void validate() {
// validator().start();
// validator().checkString(true, "version", version,
// API_VERSION_MIN_LENGTH, API_VERSION_MAX_LENGTH);
// validator().checkString(false, "startupConfigurationURI", startupConfigurationURI,
// 0, Integer.MAX_VALUE);
// validator().done();
// }
//
// @Nonnull
// public String getVersion() {
// beforeGet();
// //noinspection ConstantConditions
// return version; // Cannot be null after validation.
// }
//
// public void setVersion(@Nonnull final String version) {
// beforeSet();
// this.version = StringUtils.trim(version);
// }
//
// @Nullable
// public String getStartupConfigurationURI() {
// beforeGet();
// return startupConfigurationURI;
// }
//
// public void setStartupConfigurationURI(@Nullable final String startupConfigurationURI) {
// beforeSet();
// this.startupConfigurationURI = StringUtils.emptyToNull(StringUtils.trim(startupConfigurationURI));
// }
// }
// Path: src/main/java/com/tomtom/services/configuration/implementation/HelperResourceImpl.java
import com.google.common.base.Joiner;
import com.tomtom.services.configuration.ConfigurationServiceProperties;
import com.tomtom.services.configuration.HelperResource;
import com.tomtom.services.configuration.dto.VersionDTO;
import com.tomtom.speedtools.maven.MavenProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nonnull;
import javax.inject.Inject;
import javax.ws.rs.container.AsyncResponse;
import javax.ws.rs.container.Suspended;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
// Store the injected values.
this.configuration = configuration;
this.configurationServiceProperties = configurationServiceProperties;
this.mavenProperties = mavenProperties;
}
@Override
@Nonnull
public String getHelpHTML() {
LOG.info("getHelpHTML: show help page", mavenProperties.getPomVersion());
return "<html><pre>\n" +
"CONFIGURATION SERVICE (" + mavenProperties.getPomVersion() + ")\n" +
"---------------------\n\n" +
HELP_TEXT + '\n' +
(configuration.getRoot().getLevels() == null ? "" :
"CURRENT CONFIGURATION\n\n" +
"The current configuration used by the service is:\n" +
" URI=" + configuration.getStartupConfigurationURI() + '\n' +
" levels=" + Joiner.on("/").join(configuration.getRoot().getLevels())) +
"\n</pre></html>\n";
}
@Override
public void getVersion(@Suspended @Nonnull final AsyncResponse response) {
// No input validation required. Just return version number.
final String pomVersion = mavenProperties.getPomVersion();
final String startupConfigurationURI = configurationServiceProperties.getStartupConfigurationURI();
LOG.info("getVersion: POM version={}, startupConfigurationURI={}", pomVersion, startupConfigurationURI);
| final VersionDTO result = new VersionDTO(pomVersion, startupConfigurationURI); |
vatbub/zorkClone | src/main/java/model/Entity.java | // Path: src/main/java/parser/Word.java
// public class Word implements Serializable {
// private final Word thisWordInstance;
// private String word;
// private List<String> synonyms;
// private List<? extends Word> permittedWordClassesThatFollow;
// private final List<Word> permittedWordsThatFollow = new ArrayList<Word>() {
// @Override
// public void add(int index, Word word) {
// if (!thisWordInstance.isWordPermittedAsFollowingWord(word))
// throw new IllegalArgumentException("The word " + word.toString() + "is not permitted as a following word of " + thisWordInstance.toString());
// else
// super.add(index, word);
// }
// };
//
// public Word() {
// this(null);
// }
//
// public Word(String word) {
// this(word, null);
// }
//
// public Word(String word, List<String> synonyms) {
// this.word = word;
// this.synonyms = synonyms;
// thisWordInstance = this;
// }
//
// public String getWord() {
// return word;
// }
//
// @SuppressWarnings({"unused"})
// public void setWord(String word) {
// this.word = word;
// }
//
// public List<String> getSynonyms() {
// return synonyms;
// }
//
// @SuppressWarnings({"unused"})
// public void setSynonyms(List<String> synonyms) {
// this.synonyms = synonyms;
// }
//
// public List<? extends Word> getPermittedWordClassesThatFollow() {
// return permittedWordClassesThatFollow;
// }
//
// @SuppressWarnings({"unused"})
// public void setPermittedWordClassesThatFollow(List<? extends Word> permittedWordClassesThatFollow) {
// this.permittedWordClassesThatFollow = permittedWordClassesThatFollow;
// }
//
// public List<Word> getPermittedWordsThatFollow() {
// return permittedWordsThatFollow;
// }
//
// public boolean isWordPermittedAsFollowingWord(Word word) {
// //noinspection SuspiciousMethodCalls
// return this.getPermittedWordClassesThatFollow().contains(word.getClass()) && this.getPermittedWordsThatFollow().contains(word);
// }
//
// @Override
// public boolean equals(Object obj) {
// if (obj instanceof Word) {
// // obj is a word
// Word word = (Word) obj;
//
// if (!word.getWord().equals(this.getWord())) {
// return false;
// }
// if (!word.getSynonyms().equals(this.getSynonyms())) {
// return false;
// }
// if (!word.getPermittedWordClassesThatFollow().equals(this.getPermittedWordClassesThatFollow())) {
// return false;
// }
// if (!word.getPermittedWordsThatFollow().equals(this.getPermittedWordsThatFollow())) {
// return false;
// }
//
// // everything ok
// return true;
//
// } else {
// // Not the same class
// return false;
// }
// }
//
// @Override
// public String toString() {
// return this.getClass().getSimpleName() + "@" + this.getWord();
// }
//
// /**
// * Checks if {@code input} is equal to {@code this.}{@link #getWord()} or to one of the synonyms
// *
// * @param input The string to compare
// * @return {@code true} if {@code input} is equal to {@code this.}{@link #getWord()} or to one of the synonyms, {@code false} otherwise.
// */
// @SuppressWarnings({"unused"})
// public boolean equals(String input) {
// return (this.getWord().equals(input) || this.getSynonyms().contains(input));
// }
// }
| import java.io.Serializable;
import parser.Word; | package model;
/*-
* #%L
* Zork Clone
* %%
* Copyright (C) 2016 Frederik Kammel
* %%
* 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.
* #L%
*/
/**
* Any entity in the game like a {@link Player} or thief, troll, ...
*/
@SuppressWarnings("unused")
public class Entity implements Serializable {
private int remainingHealth = 10; | // Path: src/main/java/parser/Word.java
// public class Word implements Serializable {
// private final Word thisWordInstance;
// private String word;
// private List<String> synonyms;
// private List<? extends Word> permittedWordClassesThatFollow;
// private final List<Word> permittedWordsThatFollow = new ArrayList<Word>() {
// @Override
// public void add(int index, Word word) {
// if (!thisWordInstance.isWordPermittedAsFollowingWord(word))
// throw new IllegalArgumentException("The word " + word.toString() + "is not permitted as a following word of " + thisWordInstance.toString());
// else
// super.add(index, word);
// }
// };
//
// public Word() {
// this(null);
// }
//
// public Word(String word) {
// this(word, null);
// }
//
// public Word(String word, List<String> synonyms) {
// this.word = word;
// this.synonyms = synonyms;
// thisWordInstance = this;
// }
//
// public String getWord() {
// return word;
// }
//
// @SuppressWarnings({"unused"})
// public void setWord(String word) {
// this.word = word;
// }
//
// public List<String> getSynonyms() {
// return synonyms;
// }
//
// @SuppressWarnings({"unused"})
// public void setSynonyms(List<String> synonyms) {
// this.synonyms = synonyms;
// }
//
// public List<? extends Word> getPermittedWordClassesThatFollow() {
// return permittedWordClassesThatFollow;
// }
//
// @SuppressWarnings({"unused"})
// public void setPermittedWordClassesThatFollow(List<? extends Word> permittedWordClassesThatFollow) {
// this.permittedWordClassesThatFollow = permittedWordClassesThatFollow;
// }
//
// public List<Word> getPermittedWordsThatFollow() {
// return permittedWordsThatFollow;
// }
//
// public boolean isWordPermittedAsFollowingWord(Word word) {
// //noinspection SuspiciousMethodCalls
// return this.getPermittedWordClassesThatFollow().contains(word.getClass()) && this.getPermittedWordsThatFollow().contains(word);
// }
//
// @Override
// public boolean equals(Object obj) {
// if (obj instanceof Word) {
// // obj is a word
// Word word = (Word) obj;
//
// if (!word.getWord().equals(this.getWord())) {
// return false;
// }
// if (!word.getSynonyms().equals(this.getSynonyms())) {
// return false;
// }
// if (!word.getPermittedWordClassesThatFollow().equals(this.getPermittedWordClassesThatFollow())) {
// return false;
// }
// if (!word.getPermittedWordsThatFollow().equals(this.getPermittedWordsThatFollow())) {
// return false;
// }
//
// // everything ok
// return true;
//
// } else {
// // Not the same class
// return false;
// }
// }
//
// @Override
// public String toString() {
// return this.getClass().getSimpleName() + "@" + this.getWord();
// }
//
// /**
// * Checks if {@code input} is equal to {@code this.}{@link #getWord()} or to one of the synonyms
// *
// * @param input The string to compare
// * @return {@code true} if {@code input} is equal to {@code this.}{@link #getWord()} or to one of the synonyms, {@code false} otherwise.
// */
// @SuppressWarnings({"unused"})
// public boolean equals(String input) {
// return (this.getWord().equals(input) || this.getSynonyms().contains(input));
// }
// }
// Path: src/main/java/model/Entity.java
import java.io.Serializable;
import parser.Word;
package model;
/*-
* #%L
* Zork Clone
* %%
* Copyright (C) 2016 Frederik Kammel
* %%
* 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.
* #L%
*/
/**
* Any entity in the game like a {@link Player} or thief, troll, ...
*/
@SuppressWarnings("unused")
public class Entity implements Serializable {
private int remainingHealth = 10; | private Word name; |
vatbub/zorkClone | src/main/java/parser/Verb.java | // Path: src/main/java/model/Action.java
// @SuppressWarnings("unused")
// public abstract class Action {
// private String name;
// private Map<String, Object> params;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public Map<String, Object> getParams() {
// return params;
// }
//
// public void setParams(Map<String, Object> params) {
// this.params = params;
// }
//
// abstract void execute(Map<String, Object> params);
// }
| import java.util.List;
import model.Action; | package parser;
/*-
* #%L
* Zork Clone
* %%
* Copyright (C) 2016 Frederik Kammel
* %%
* 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.
* #L%
*/
/**
* The representation of a verb in a sentence.
*/
@SuppressWarnings({"unused"})
public class Verb extends Word { | // Path: src/main/java/model/Action.java
// @SuppressWarnings("unused")
// public abstract class Action {
// private String name;
// private Map<String, Object> params;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public Map<String, Object> getParams() {
// return params;
// }
//
// public void setParams(Map<String, Object> params) {
// this.params = params;
// }
//
// abstract void execute(Map<String, Object> params);
// }
// Path: src/main/java/parser/Verb.java
import java.util.List;
import model.Action;
package parser;
/*-
* #%L
* Zork Clone
* %%
* Copyright (C) 2016 Frederik Kammel
* %%
* 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.
* #L%
*/
/**
* The representation of a verb in a sentence.
*/
@SuppressWarnings({"unused"})
public class Verb extends Word { | Action action; |
vatbub/zorkClone | src/main/java/model/Game.java | // Path: src/main/java/view/GameMessage.java
// public class GameMessage implements Serializable {
// private String message;
// private boolean messageFromGame;
//
// @SuppressWarnings("unused")
// public GameMessage() {
// this(null, false);
// }
//
// public GameMessage(String message, boolean isMessageFromGame) {
// this.setMessage(message);
// this.setIsMessageFromGame(isMessageFromGame);
// }
//
// public boolean isMessageFromGame() {
// return messageFromGame;
// }
//
// @SuppressWarnings("unused")
// public boolean isMessageFromPlayer() {
// return !messageFromGame;
// }
//
// public void setIsMessageFromGame(boolean messageFromGame) {
// this.messageFromGame = messageFromGame;
// }
//
// @SuppressWarnings("unused")
// public void messageIsFromGame() {
// this.setIsMessageFromGame(true);
// }
//
// @SuppressWarnings("unused")
// public void messageIsFromPlayer() {
// this.setIsMessageFromGame(false);
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
// }
| import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.logging.Level;
import com.github.vatbub.common.core.Common;
import com.github.vatbub.common.core.logging.FOKLogger;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.value.ChangeListener;
import org.jetbrains.annotations.NotNull;
import view.GameMessage;
import java.io.*; | package model;
/*-
* #%L
* Zork Clone
* %%
* Copyright (C) 2016 Frederik Kammel
* %%
* 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.
* #L%
*/
/**
* Represents the game as a whole, all the rooms, items and the current {@link Player}.
*/
@SuppressWarnings("unused")
public class Game implements Serializable {
/**
* The app version that was used when the game was saved.
*/
@SuppressWarnings({"unused"})
public final String gameSavedWithAppVersion = Common.getInstance().getAppVersion();
private Room currentRoom;
private Player player;
private int score;
private int moveCount; | // Path: src/main/java/view/GameMessage.java
// public class GameMessage implements Serializable {
// private String message;
// private boolean messageFromGame;
//
// @SuppressWarnings("unused")
// public GameMessage() {
// this(null, false);
// }
//
// public GameMessage(String message, boolean isMessageFromGame) {
// this.setMessage(message);
// this.setIsMessageFromGame(isMessageFromGame);
// }
//
// public boolean isMessageFromGame() {
// return messageFromGame;
// }
//
// @SuppressWarnings("unused")
// public boolean isMessageFromPlayer() {
// return !messageFromGame;
// }
//
// public void setIsMessageFromGame(boolean messageFromGame) {
// this.messageFromGame = messageFromGame;
// }
//
// @SuppressWarnings("unused")
// public void messageIsFromGame() {
// this.setIsMessageFromGame(true);
// }
//
// @SuppressWarnings("unused")
// public void messageIsFromPlayer() {
// this.setIsMessageFromGame(false);
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
// }
// Path: src/main/java/model/Game.java
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.logging.Level;
import com.github.vatbub.common.core.Common;
import com.github.vatbub.common.core.logging.FOKLogger;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.value.ChangeListener;
import org.jetbrains.annotations.NotNull;
import view.GameMessage;
import java.io.*;
package model;
/*-
* #%L
* Zork Clone
* %%
* Copyright (C) 2016 Frederik Kammel
* %%
* 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.
* #L%
*/
/**
* Represents the game as a whole, all the rooms, items and the current {@link Player}.
*/
@SuppressWarnings("unused")
public class Game implements Serializable {
/**
* The app version that was used when the game was saved.
*/
@SuppressWarnings({"unused"})
public final String gameSavedWithAppVersion = Common.getInstance().getAppVersion();
private Room currentRoom;
private Player player;
private int score;
private int moveCount; | private List<GameMessage> messages; |
vatbub/zorkClone | src/main/java/model/Item.java | // Path: src/main/java/parser/Noun.java
// @SuppressWarnings("unused")
// public class Noun extends Word {
// public Noun() {
// super();
// }
//
// public Noun(String word) {
// super(word);
// }
//
// public Noun(String word, List<String> synonyms) {
// super(word, synonyms);
// }
// }
| import java.io.Serializable;
import java.util.List;
import parser.Noun; | package model;
/*-
* #%L
* Zork Clone
* %%
* Copyright (C) 2016 Frederik Kammel
* %%
* 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.
* #L%
*/
/**
* Any item in the game that can be placed in a {@link Room} or in the {@link Player}{@code s} inventory
*/
@SuppressWarnings("unused")
public class Item implements Serializable { | // Path: src/main/java/parser/Noun.java
// @SuppressWarnings("unused")
// public class Noun extends Word {
// public Noun() {
// super();
// }
//
// public Noun(String word) {
// super(word);
// }
//
// public Noun(String word, List<String> synonyms) {
// super(word, synonyms);
// }
// }
// Path: src/main/java/model/Item.java
import java.io.Serializable;
import java.util.List;
import parser.Noun;
package model;
/*-
* #%L
* Zork Clone
* %%
* Copyright (C) 2016 Frederik Kammel
* %%
* 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.
* #L%
*/
/**
* Any item in the game that can be placed in a {@link Room} or in the {@link Player}{@code s} inventory
*/
@SuppressWarnings("unused")
public class Item implements Serializable { | private Noun name; |
vatbub/zorkClone | src/main/java/view/ConnectionLine.java | // Path: src/main/java/model/WalkDirection.java
// public enum WalkDirection implements Serializable {
// NORTH, WEST, EAST, SOUTH, NORTH_WEST, NORTH_EAST, SOUTH_WEST, SOUTH_EAST, NONE
// }
//
// Path: src/main/java/model/WalkDirectionUtils.java
// public class WalkDirectionUtils {
// public static WalkDirection invert(WalkDirection in) {
// if (in == WalkDirection.NORTH) {
// return WalkDirection.SOUTH;
// } else if (in == WalkDirection.NORTH_EAST) {
// return WalkDirection.SOUTH_WEST;
// } else if (in == WalkDirection.EAST) {
// return WalkDirection.WEST;
// } else if (in == WalkDirection.SOUTH_EAST) {
// return WalkDirection.NORTH_WEST;
// } else if (in == WalkDirection.SOUTH) {
// return WalkDirection.NORTH;
// } else if (in == WalkDirection.SOUTH_WEST) {
// return WalkDirection.NORTH_EAST;
// } else if (in == WalkDirection.WEST) {
// return WalkDirection.EAST;
// } else if (in == WalkDirection.NORTH_WEST) {
// return WalkDirection.SOUTH_EAST;
// } else {
// // in is WalkDirection.NONE, but for the compiler, it needs to be else and not else if
// return WalkDirection.NONE;
// }
// }
//
// public static WalkDirection getFromLineAngle(double lineAngle) {
// if (lineAngle <= (Math.PI / 8.0) && lineAngle >= (-Math.PI / 8.0)) {
// // north
// return WalkDirection.NORTH;
// } else if (lineAngle < (Math.PI * 3.0 / 8.0) && lineAngle > (Math.PI / 8.0)) {
// // ne
// return WalkDirection.NORTH_EAST;
// } else if (lineAngle <= (Math.PI * 5.0 / 8.0) && lineAngle >= (Math.PI * 3.0 / 8.0)) {
// // e
// return WalkDirection.EAST;
// } else if (lineAngle < (Math.PI * 7.0 / 8.0) && lineAngle > (Math.PI * 5.0 / 8.0)) {
// // se
// return WalkDirection.SOUTH_EAST;
// } else if ((lineAngle <= (-Math.PI * 7.0 / 8.0) && lineAngle >= (-Math.PI)) || (lineAngle <= (Math.PI) && lineAngle >= (Math.PI * 7.0 / 8.0))) {
// // s
// return WalkDirection.SOUTH;
// } else if (lineAngle < (-Math.PI * 5.0 / 8.0) && lineAngle > (-Math.PI * 7.0 / 8.0)) {
// // sw
// return WalkDirection.SOUTH_WEST;
// } else if (lineAngle <= (-Math.PI * 3.0 / 8.0) && lineAngle >= (-Math.PI * 5.0 / 8.0)) {
// // w
// return WalkDirection.WEST;
// } else {
// // ... if (lineAngle < (-Math.PI * 1.0 / 8.0) && lineAngle > (-Math.PI * 3.0 / 8.0))
// // but the compiler requires else...
// // nw
// return WalkDirection.NORTH_WEST;
// }
// }
//
// public static WalkDirection getFromLine(Line line) {
// double lineAngle = Math.atan2(line.getEndX() - line.getStartX(), line.getStartY() - line.getEndY());
// return getFromLineAngle(lineAngle);
// }
// }
| import java.io.Serializable;
import java.util.Map;
import java.util.logging.Level;
import com.github.vatbub.common.core.logging.FOKLogger;
import com.github.vatbub.common.view.core.CustomGroup;
import javafx.application.Platform;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.scene.paint.Color;
import javafx.scene.shape.Line;
import model.WalkDirection;
import model.WalkDirectionUtils; | public RoomRectangle getStartRoom() {
return startRoom;
}
public void setStartRoom(RoomRectangle startRoom) {
this.startRoom = startRoom;
updateLocation();
}
/**
* Invalidates this line
*/
public void invalidate() {
if (invalidationRunnable != null) {
invalidationRunnable.run(this);
}
}
/**
* Updates the location of this line
*/
public void updateLocation() {
if (getStartRoom() != null && getEndRoom() != null) {
if (!getStartRoom().getRoom().isDirectlyConnectedTo(getEndRoom().getRoom())) {
// rooms not connected, detach this line
invalidate();
return;
}
// get the connection direction | // Path: src/main/java/model/WalkDirection.java
// public enum WalkDirection implements Serializable {
// NORTH, WEST, EAST, SOUTH, NORTH_WEST, NORTH_EAST, SOUTH_WEST, SOUTH_EAST, NONE
// }
//
// Path: src/main/java/model/WalkDirectionUtils.java
// public class WalkDirectionUtils {
// public static WalkDirection invert(WalkDirection in) {
// if (in == WalkDirection.NORTH) {
// return WalkDirection.SOUTH;
// } else if (in == WalkDirection.NORTH_EAST) {
// return WalkDirection.SOUTH_WEST;
// } else if (in == WalkDirection.EAST) {
// return WalkDirection.WEST;
// } else if (in == WalkDirection.SOUTH_EAST) {
// return WalkDirection.NORTH_WEST;
// } else if (in == WalkDirection.SOUTH) {
// return WalkDirection.NORTH;
// } else if (in == WalkDirection.SOUTH_WEST) {
// return WalkDirection.NORTH_EAST;
// } else if (in == WalkDirection.WEST) {
// return WalkDirection.EAST;
// } else if (in == WalkDirection.NORTH_WEST) {
// return WalkDirection.SOUTH_EAST;
// } else {
// // in is WalkDirection.NONE, but for the compiler, it needs to be else and not else if
// return WalkDirection.NONE;
// }
// }
//
// public static WalkDirection getFromLineAngle(double lineAngle) {
// if (lineAngle <= (Math.PI / 8.0) && lineAngle >= (-Math.PI / 8.0)) {
// // north
// return WalkDirection.NORTH;
// } else if (lineAngle < (Math.PI * 3.0 / 8.0) && lineAngle > (Math.PI / 8.0)) {
// // ne
// return WalkDirection.NORTH_EAST;
// } else if (lineAngle <= (Math.PI * 5.0 / 8.0) && lineAngle >= (Math.PI * 3.0 / 8.0)) {
// // e
// return WalkDirection.EAST;
// } else if (lineAngle < (Math.PI * 7.0 / 8.0) && lineAngle > (Math.PI * 5.0 / 8.0)) {
// // se
// return WalkDirection.SOUTH_EAST;
// } else if ((lineAngle <= (-Math.PI * 7.0 / 8.0) && lineAngle >= (-Math.PI)) || (lineAngle <= (Math.PI) && lineAngle >= (Math.PI * 7.0 / 8.0))) {
// // s
// return WalkDirection.SOUTH;
// } else if (lineAngle < (-Math.PI * 5.0 / 8.0) && lineAngle > (-Math.PI * 7.0 / 8.0)) {
// // sw
// return WalkDirection.SOUTH_WEST;
// } else if (lineAngle <= (-Math.PI * 3.0 / 8.0) && lineAngle >= (-Math.PI * 5.0 / 8.0)) {
// // w
// return WalkDirection.WEST;
// } else {
// // ... if (lineAngle < (-Math.PI * 1.0 / 8.0) && lineAngle > (-Math.PI * 3.0 / 8.0))
// // but the compiler requires else...
// // nw
// return WalkDirection.NORTH_WEST;
// }
// }
//
// public static WalkDirection getFromLine(Line line) {
// double lineAngle = Math.atan2(line.getEndX() - line.getStartX(), line.getStartY() - line.getEndY());
// return getFromLineAngle(lineAngle);
// }
// }
// Path: src/main/java/view/ConnectionLine.java
import java.io.Serializable;
import java.util.Map;
import java.util.logging.Level;
import com.github.vatbub.common.core.logging.FOKLogger;
import com.github.vatbub.common.view.core.CustomGroup;
import javafx.application.Platform;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.scene.paint.Color;
import javafx.scene.shape.Line;
import model.WalkDirection;
import model.WalkDirectionUtils;
public RoomRectangle getStartRoom() {
return startRoom;
}
public void setStartRoom(RoomRectangle startRoom) {
this.startRoom = startRoom;
updateLocation();
}
/**
* Invalidates this line
*/
public void invalidate() {
if (invalidationRunnable != null) {
invalidationRunnable.run(this);
}
}
/**
* Updates the location of this line
*/
public void updateLocation() {
if (getStartRoom() != null && getEndRoom() != null) {
if (!getStartRoom().getRoom().isDirectlyConnectedTo(getEndRoom().getRoom())) {
// rooms not connected, detach this line
invalidate();
return;
}
// get the connection direction | WalkDirection dir = null; |
vatbub/zorkClone | src/main/java/view/ConnectionLine.java | // Path: src/main/java/model/WalkDirection.java
// public enum WalkDirection implements Serializable {
// NORTH, WEST, EAST, SOUTH, NORTH_WEST, NORTH_EAST, SOUTH_WEST, SOUTH_EAST, NONE
// }
//
// Path: src/main/java/model/WalkDirectionUtils.java
// public class WalkDirectionUtils {
// public static WalkDirection invert(WalkDirection in) {
// if (in == WalkDirection.NORTH) {
// return WalkDirection.SOUTH;
// } else if (in == WalkDirection.NORTH_EAST) {
// return WalkDirection.SOUTH_WEST;
// } else if (in == WalkDirection.EAST) {
// return WalkDirection.WEST;
// } else if (in == WalkDirection.SOUTH_EAST) {
// return WalkDirection.NORTH_WEST;
// } else if (in == WalkDirection.SOUTH) {
// return WalkDirection.NORTH;
// } else if (in == WalkDirection.SOUTH_WEST) {
// return WalkDirection.NORTH_EAST;
// } else if (in == WalkDirection.WEST) {
// return WalkDirection.EAST;
// } else if (in == WalkDirection.NORTH_WEST) {
// return WalkDirection.SOUTH_EAST;
// } else {
// // in is WalkDirection.NONE, but for the compiler, it needs to be else and not else if
// return WalkDirection.NONE;
// }
// }
//
// public static WalkDirection getFromLineAngle(double lineAngle) {
// if (lineAngle <= (Math.PI / 8.0) && lineAngle >= (-Math.PI / 8.0)) {
// // north
// return WalkDirection.NORTH;
// } else if (lineAngle < (Math.PI * 3.0 / 8.0) && lineAngle > (Math.PI / 8.0)) {
// // ne
// return WalkDirection.NORTH_EAST;
// } else if (lineAngle <= (Math.PI * 5.0 / 8.0) && lineAngle >= (Math.PI * 3.0 / 8.0)) {
// // e
// return WalkDirection.EAST;
// } else if (lineAngle < (Math.PI * 7.0 / 8.0) && lineAngle > (Math.PI * 5.0 / 8.0)) {
// // se
// return WalkDirection.SOUTH_EAST;
// } else if ((lineAngle <= (-Math.PI * 7.0 / 8.0) && lineAngle >= (-Math.PI)) || (lineAngle <= (Math.PI) && lineAngle >= (Math.PI * 7.0 / 8.0))) {
// // s
// return WalkDirection.SOUTH;
// } else if (lineAngle < (-Math.PI * 5.0 / 8.0) && lineAngle > (-Math.PI * 7.0 / 8.0)) {
// // sw
// return WalkDirection.SOUTH_WEST;
// } else if (lineAngle <= (-Math.PI * 3.0 / 8.0) && lineAngle >= (-Math.PI * 5.0 / 8.0)) {
// // w
// return WalkDirection.WEST;
// } else {
// // ... if (lineAngle < (-Math.PI * 1.0 / 8.0) && lineAngle > (-Math.PI * 3.0 / 8.0))
// // but the compiler requires else...
// // nw
// return WalkDirection.NORTH_WEST;
// }
// }
//
// public static WalkDirection getFromLine(Line line) {
// double lineAngle = Math.atan2(line.getEndX() - line.getStartX(), line.getStartY() - line.getEndY());
// return getFromLineAngle(lineAngle);
// }
// }
| import java.io.Serializable;
import java.util.Map;
import java.util.logging.Level;
import com.github.vatbub.common.core.logging.FOKLogger;
import com.github.vatbub.common.view.core.CustomGroup;
import javafx.application.Platform;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.scene.paint.Color;
import javafx.scene.shape.Line;
import model.WalkDirection;
import model.WalkDirectionUtils; | }
return res * Math.PI;
}
/**
* Calculates the angle that the line is pointing in
*
* @return The angle that the line is pointing in
*/
public double getAngle() {
return Math.atan2(this.getEndX() - this.getStartX(), this.getStartY() - this.getEndY());
}
@SuppressWarnings({"unused"})
public boolean isSelected() {
return selected.get();
}
public void setSelected(boolean selected) {
this.selected.set(selected);
}
@SuppressWarnings({"unused"})
public BooleanProperty isSelectedProperty() {
return selected;
}
@Override
public void dispose() { | // Path: src/main/java/model/WalkDirection.java
// public enum WalkDirection implements Serializable {
// NORTH, WEST, EAST, SOUTH, NORTH_WEST, NORTH_EAST, SOUTH_WEST, SOUTH_EAST, NONE
// }
//
// Path: src/main/java/model/WalkDirectionUtils.java
// public class WalkDirectionUtils {
// public static WalkDirection invert(WalkDirection in) {
// if (in == WalkDirection.NORTH) {
// return WalkDirection.SOUTH;
// } else if (in == WalkDirection.NORTH_EAST) {
// return WalkDirection.SOUTH_WEST;
// } else if (in == WalkDirection.EAST) {
// return WalkDirection.WEST;
// } else if (in == WalkDirection.SOUTH_EAST) {
// return WalkDirection.NORTH_WEST;
// } else if (in == WalkDirection.SOUTH) {
// return WalkDirection.NORTH;
// } else if (in == WalkDirection.SOUTH_WEST) {
// return WalkDirection.NORTH_EAST;
// } else if (in == WalkDirection.WEST) {
// return WalkDirection.EAST;
// } else if (in == WalkDirection.NORTH_WEST) {
// return WalkDirection.SOUTH_EAST;
// } else {
// // in is WalkDirection.NONE, but for the compiler, it needs to be else and not else if
// return WalkDirection.NONE;
// }
// }
//
// public static WalkDirection getFromLineAngle(double lineAngle) {
// if (lineAngle <= (Math.PI / 8.0) && lineAngle >= (-Math.PI / 8.0)) {
// // north
// return WalkDirection.NORTH;
// } else if (lineAngle < (Math.PI * 3.0 / 8.0) && lineAngle > (Math.PI / 8.0)) {
// // ne
// return WalkDirection.NORTH_EAST;
// } else if (lineAngle <= (Math.PI * 5.0 / 8.0) && lineAngle >= (Math.PI * 3.0 / 8.0)) {
// // e
// return WalkDirection.EAST;
// } else if (lineAngle < (Math.PI * 7.0 / 8.0) && lineAngle > (Math.PI * 5.0 / 8.0)) {
// // se
// return WalkDirection.SOUTH_EAST;
// } else if ((lineAngle <= (-Math.PI * 7.0 / 8.0) && lineAngle >= (-Math.PI)) || (lineAngle <= (Math.PI) && lineAngle >= (Math.PI * 7.0 / 8.0))) {
// // s
// return WalkDirection.SOUTH;
// } else if (lineAngle < (-Math.PI * 5.0 / 8.0) && lineAngle > (-Math.PI * 7.0 / 8.0)) {
// // sw
// return WalkDirection.SOUTH_WEST;
// } else if (lineAngle <= (-Math.PI * 3.0 / 8.0) && lineAngle >= (-Math.PI * 5.0 / 8.0)) {
// // w
// return WalkDirection.WEST;
// } else {
// // ... if (lineAngle < (-Math.PI * 1.0 / 8.0) && lineAngle > (-Math.PI * 3.0 / 8.0))
// // but the compiler requires else...
// // nw
// return WalkDirection.NORTH_WEST;
// }
// }
//
// public static WalkDirection getFromLine(Line line) {
// double lineAngle = Math.atan2(line.getEndX() - line.getStartX(), line.getStartY() - line.getEndY());
// return getFromLineAngle(lineAngle);
// }
// }
// Path: src/main/java/view/ConnectionLine.java
import java.io.Serializable;
import java.util.Map;
import java.util.logging.Level;
import com.github.vatbub.common.core.logging.FOKLogger;
import com.github.vatbub.common.view.core.CustomGroup;
import javafx.application.Platform;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.scene.paint.Color;
import javafx.scene.shape.Line;
import model.WalkDirection;
import model.WalkDirectionUtils;
}
return res * Math.PI;
}
/**
* Calculates the angle that the line is pointing in
*
* @return The angle that the line is pointing in
*/
public double getAngle() {
return Math.atan2(this.getEndX() - this.getStartX(), this.getStartY() - this.getEndY());
}
@SuppressWarnings({"unused"})
public boolean isSelected() {
return selected.get();
}
public void setSelected(boolean selected) {
this.selected.set(selected);
}
@SuppressWarnings({"unused"})
public BooleanProperty isSelectedProperty() {
return selected;
}
@Override
public void dispose() { | WalkDirection dir = WalkDirectionUtils.getFromLine(this); |
mpostelnicu/wicket-spring-jpa-bootstrap-boilerplate | web/src/main/java/org/sample/web/components/providers/datatable/SortableJpaRepositoryDataProvider.java | // Path: web/src/main/java/org/sample/web/app/WebConstants.java
// public final class WebConstants {
// public static final int PAGE_SIZE=10;
// }
//
// Path: web/src/main/java/org/sample/web/models/PersistableJpaRepositoryModel.java
// public class PersistableJpaRepositoryModel<T extends AbstractPersistable<Long>> extends LoadableDetachableModel<T> {
//
// private static final long serialVersionUID = 1L;
// private Long id;
// private JpaRepository<T, Long> jpaRepository;
//
// public PersistableJpaRepositoryModel(final Long id, final JpaRepository<T, Long> jpaRepository) {
// super();
// this.id = id;
// this.jpaRepository = jpaRepository;
// }
//
// public PersistableJpaRepositoryModel(final T t, final JpaRepository<T, Long> jpaRepository) {
// super(t);
// this.id = t.getId();
// this.jpaRepository = jpaRepository;
// }
//
// @Override
// protected T load() {
// return jpaRepository.findOne(id);
// }
//
//
// @Override
// public int hashCode()
// {
// return Long.valueOf(id).hashCode();
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public boolean equals(final Object obj)
// {
// if (obj == this)
// {
// return true;
// }
// else if (obj == null)
// {
// return false;
// }
// else if (obj instanceof PersistableJpaRepositoryModel)
// {
// PersistableJpaRepositoryModel<T> other = (PersistableJpaRepositoryModel<T>)obj;
// return other.id == id;
// }
// return false;
// }
// }
| import java.util.Iterator;
import org.apache.wicket.extensions.markup.html.repeater.util.SortParam;
import org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider;
import org.apache.wicket.model.IModel;
import org.apache.wicket.spring.injection.annot.SpringBean;
import org.sample.web.app.WebConstants;
import org.sample.web.models.PersistableJpaRepositoryModel;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.jpa.domain.AbstractPersistable;
import org.springframework.data.jpa.repository.JpaRepository;
| /**
*
*/
package org.sample.web.components.providers.datatable;
/**
* @author mpostelnicu
*
* Smart generic {@link SortableDataProvider} that binds to {@link JpaRepository}
*/
public class SortableJpaRepositoryDataProvider<T extends AbstractPersistable<Long>>
extends SortableDataProvider<T, String> {
private static final long serialVersionUID = 1L;
protected JpaRepository<T, Long> jpaRepository;
/**
* Always provide a proxy jpaRepository here! For example one coming from a {@link SpringBean}
*
* @param jpaRepository
*/
public SortableJpaRepositoryDataProvider(
JpaRepository<T, Long> jpaRepository) {
this.jpaRepository = jpaRepository;
}
/**
* Translates from a {@link SortParam} to a Spring {@link Sort}
*
* @return
*/
protected Sort translateSort() {
if(getSort()==null) return null;
return new Sort(getSort().isAscending() ? Direction.ASC
: Direction.DESC, getSort().getProperty());
}
/**
* @see SortableDataProvider#iterator(long, long)
*/
@Override
public Iterator<? extends T> iterator(long first, long count) {
| // Path: web/src/main/java/org/sample/web/app/WebConstants.java
// public final class WebConstants {
// public static final int PAGE_SIZE=10;
// }
//
// Path: web/src/main/java/org/sample/web/models/PersistableJpaRepositoryModel.java
// public class PersistableJpaRepositoryModel<T extends AbstractPersistable<Long>> extends LoadableDetachableModel<T> {
//
// private static final long serialVersionUID = 1L;
// private Long id;
// private JpaRepository<T, Long> jpaRepository;
//
// public PersistableJpaRepositoryModel(final Long id, final JpaRepository<T, Long> jpaRepository) {
// super();
// this.id = id;
// this.jpaRepository = jpaRepository;
// }
//
// public PersistableJpaRepositoryModel(final T t, final JpaRepository<T, Long> jpaRepository) {
// super(t);
// this.id = t.getId();
// this.jpaRepository = jpaRepository;
// }
//
// @Override
// protected T load() {
// return jpaRepository.findOne(id);
// }
//
//
// @Override
// public int hashCode()
// {
// return Long.valueOf(id).hashCode();
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public boolean equals(final Object obj)
// {
// if (obj == this)
// {
// return true;
// }
// else if (obj == null)
// {
// return false;
// }
// else if (obj instanceof PersistableJpaRepositoryModel)
// {
// PersistableJpaRepositoryModel<T> other = (PersistableJpaRepositoryModel<T>)obj;
// return other.id == id;
// }
// return false;
// }
// }
// Path: web/src/main/java/org/sample/web/components/providers/datatable/SortableJpaRepositoryDataProvider.java
import java.util.Iterator;
import org.apache.wicket.extensions.markup.html.repeater.util.SortParam;
import org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider;
import org.apache.wicket.model.IModel;
import org.apache.wicket.spring.injection.annot.SpringBean;
import org.sample.web.app.WebConstants;
import org.sample.web.models.PersistableJpaRepositoryModel;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.jpa.domain.AbstractPersistable;
import org.springframework.data.jpa.repository.JpaRepository;
/**
*
*/
package org.sample.web.components.providers.datatable;
/**
* @author mpostelnicu
*
* Smart generic {@link SortableDataProvider} that binds to {@link JpaRepository}
*/
public class SortableJpaRepositoryDataProvider<T extends AbstractPersistable<Long>>
extends SortableDataProvider<T, String> {
private static final long serialVersionUID = 1L;
protected JpaRepository<T, Long> jpaRepository;
/**
* Always provide a proxy jpaRepository here! For example one coming from a {@link SpringBean}
*
* @param jpaRepository
*/
public SortableJpaRepositoryDataProvider(
JpaRepository<T, Long> jpaRepository) {
this.jpaRepository = jpaRepository;
}
/**
* Translates from a {@link SortParam} to a Spring {@link Sort}
*
* @return
*/
protected Sort translateSort() {
if(getSort()==null) return null;
return new Sort(getSort().isAscending() ? Direction.ASC
: Direction.DESC, getSort().getProperty());
}
/**
* @see SortableDataProvider#iterator(long, long)
*/
@Override
public Iterator<? extends T> iterator(long first, long count) {
| int page = (int)((double) first / WebConstants.PAGE_SIZE);
|
mpostelnicu/wicket-spring-jpa-bootstrap-boilerplate | web/src/main/java/org/sample/web/components/providers/datatable/SortableJpaRepositoryDataProvider.java | // Path: web/src/main/java/org/sample/web/app/WebConstants.java
// public final class WebConstants {
// public static final int PAGE_SIZE=10;
// }
//
// Path: web/src/main/java/org/sample/web/models/PersistableJpaRepositoryModel.java
// public class PersistableJpaRepositoryModel<T extends AbstractPersistable<Long>> extends LoadableDetachableModel<T> {
//
// private static final long serialVersionUID = 1L;
// private Long id;
// private JpaRepository<T, Long> jpaRepository;
//
// public PersistableJpaRepositoryModel(final Long id, final JpaRepository<T, Long> jpaRepository) {
// super();
// this.id = id;
// this.jpaRepository = jpaRepository;
// }
//
// public PersistableJpaRepositoryModel(final T t, final JpaRepository<T, Long> jpaRepository) {
// super(t);
// this.id = t.getId();
// this.jpaRepository = jpaRepository;
// }
//
// @Override
// protected T load() {
// return jpaRepository.findOne(id);
// }
//
//
// @Override
// public int hashCode()
// {
// return Long.valueOf(id).hashCode();
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public boolean equals(final Object obj)
// {
// if (obj == this)
// {
// return true;
// }
// else if (obj == null)
// {
// return false;
// }
// else if (obj instanceof PersistableJpaRepositoryModel)
// {
// PersistableJpaRepositoryModel<T> other = (PersistableJpaRepositoryModel<T>)obj;
// return other.id == id;
// }
// return false;
// }
// }
| import java.util.Iterator;
import org.apache.wicket.extensions.markup.html.repeater.util.SortParam;
import org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider;
import org.apache.wicket.model.IModel;
import org.apache.wicket.spring.injection.annot.SpringBean;
import org.sample.web.app.WebConstants;
import org.sample.web.models.PersistableJpaRepositoryModel;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.jpa.domain.AbstractPersistable;
import org.springframework.data.jpa.repository.JpaRepository;
| /**
*
*/
package org.sample.web.components.providers.datatable;
/**
* @author mpostelnicu
*
* Smart generic {@link SortableDataProvider} that binds to {@link JpaRepository}
*/
public class SortableJpaRepositoryDataProvider<T extends AbstractPersistable<Long>>
extends SortableDataProvider<T, String> {
private static final long serialVersionUID = 1L;
protected JpaRepository<T, Long> jpaRepository;
/**
* Always provide a proxy jpaRepository here! For example one coming from a {@link SpringBean}
*
* @param jpaRepository
*/
public SortableJpaRepositoryDataProvider(
JpaRepository<T, Long> jpaRepository) {
this.jpaRepository = jpaRepository;
}
/**
* Translates from a {@link SortParam} to a Spring {@link Sort}
*
* @return
*/
protected Sort translateSort() {
if(getSort()==null) return null;
return new Sort(getSort().isAscending() ? Direction.ASC
: Direction.DESC, getSort().getProperty());
}
/**
* @see SortableDataProvider#iterator(long, long)
*/
@Override
public Iterator<? extends T> iterator(long first, long count) {
int page = (int)((double) first / WebConstants.PAGE_SIZE);
Page<T> findAll = jpaRepository.findAll(
new PageRequest((int) page, WebConstants.PAGE_SIZE, translateSort()));
return findAll.iterator();
}
@Override
public long size() {
return jpaRepository.count();
}
/**
* This ensures that the object is detached and reloaded after
* deserialization of the page, since the
* {@link PersistableJpaRepositoryModel} is also loadabledetachable
*/
@Override
public IModel<T> model(T object) {
| // Path: web/src/main/java/org/sample/web/app/WebConstants.java
// public final class WebConstants {
// public static final int PAGE_SIZE=10;
// }
//
// Path: web/src/main/java/org/sample/web/models/PersistableJpaRepositoryModel.java
// public class PersistableJpaRepositoryModel<T extends AbstractPersistable<Long>> extends LoadableDetachableModel<T> {
//
// private static final long serialVersionUID = 1L;
// private Long id;
// private JpaRepository<T, Long> jpaRepository;
//
// public PersistableJpaRepositoryModel(final Long id, final JpaRepository<T, Long> jpaRepository) {
// super();
// this.id = id;
// this.jpaRepository = jpaRepository;
// }
//
// public PersistableJpaRepositoryModel(final T t, final JpaRepository<T, Long> jpaRepository) {
// super(t);
// this.id = t.getId();
// this.jpaRepository = jpaRepository;
// }
//
// @Override
// protected T load() {
// return jpaRepository.findOne(id);
// }
//
//
// @Override
// public int hashCode()
// {
// return Long.valueOf(id).hashCode();
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public boolean equals(final Object obj)
// {
// if (obj == this)
// {
// return true;
// }
// else if (obj == null)
// {
// return false;
// }
// else if (obj instanceof PersistableJpaRepositoryModel)
// {
// PersistableJpaRepositoryModel<T> other = (PersistableJpaRepositoryModel<T>)obj;
// return other.id == id;
// }
// return false;
// }
// }
// Path: web/src/main/java/org/sample/web/components/providers/datatable/SortableJpaRepositoryDataProvider.java
import java.util.Iterator;
import org.apache.wicket.extensions.markup.html.repeater.util.SortParam;
import org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider;
import org.apache.wicket.model.IModel;
import org.apache.wicket.spring.injection.annot.SpringBean;
import org.sample.web.app.WebConstants;
import org.sample.web.models.PersistableJpaRepositoryModel;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.jpa.domain.AbstractPersistable;
import org.springframework.data.jpa.repository.JpaRepository;
/**
*
*/
package org.sample.web.components.providers.datatable;
/**
* @author mpostelnicu
*
* Smart generic {@link SortableDataProvider} that binds to {@link JpaRepository}
*/
public class SortableJpaRepositoryDataProvider<T extends AbstractPersistable<Long>>
extends SortableDataProvider<T, String> {
private static final long serialVersionUID = 1L;
protected JpaRepository<T, Long> jpaRepository;
/**
* Always provide a proxy jpaRepository here! For example one coming from a {@link SpringBean}
*
* @param jpaRepository
*/
public SortableJpaRepositoryDataProvider(
JpaRepository<T, Long> jpaRepository) {
this.jpaRepository = jpaRepository;
}
/**
* Translates from a {@link SortParam} to a Spring {@link Sort}
*
* @return
*/
protected Sort translateSort() {
if(getSort()==null) return null;
return new Sort(getSort().isAscending() ? Direction.ASC
: Direction.DESC, getSort().getProperty());
}
/**
* @see SortableDataProvider#iterator(long, long)
*/
@Override
public Iterator<? extends T> iterator(long first, long count) {
int page = (int)((double) first / WebConstants.PAGE_SIZE);
Page<T> findAll = jpaRepository.findAll(
new PageRequest((int) page, WebConstants.PAGE_SIZE, translateSort()));
return findAll.iterator();
}
@Override
public long size() {
return jpaRepository.count();
}
/**
* This ensures that the object is detached and reloaded after
* deserialization of the page, since the
* {@link PersistableJpaRepositoryModel} is also loadabledetachable
*/
@Override
public IModel<T> model(T object) {
| return new PersistableJpaRepositoryModel<T>(object, jpaRepository);
|
mpostelnicu/wicket-spring-jpa-bootstrap-boilerplate | web/src/main/java/org/sample/web/pages/lists/ListDummyPage.java | // Path: persistence/src/main/java/org/sample/persistence/dao/Dummy.java
// @Entity
// public class Dummy extends AbstractPersistable<Long> {
//
// private static final long serialVersionUID = 1L;
// private String name;
//
//
// @ManyToOne
// private CategoryDummy category;
//
// /**
// * @return the cat
// */
// public CategoryDummy getCategory() {
// return category;
// }
//
// /**
// * @param cat the cat to set
// */
// public void setCategory(CategoryDummy cat) {
// this.category = cat;
// }
//
// /**
// * @return the name
// */
// public String getName() {
// return name;
// }
//
// /**
// * @param name
// * the name to set
// */
// public void setName(String name) {
// this.name = name;
// }
//
// }
//
// Path: persistence/src/main/java/org/sample/persistence/repository/DummyRepository.java
// @Transactional
// public interface DummyRepository extends JpaRepository<Dummy, Long> {
//
// @Query("select c from Dummy c where c.name = ?1")
// List<Dummy> findByName(String name);
//
// }
//
// Path: web/src/main/java/org/sample/web/pages/edits/EditDummyPage.java
// public class EditDummyPage extends AbstractEditPage<Dummy> {
//
//
// private static final long serialVersionUID = 1L;
//
//
// /* (non-Javadoc)
// * @see org.devgateway.ccrs.web.wicket.page.AbstractEditPage#newInstance()
// */
// @Override
// protected Dummy newInstance() {
// return new Dummy();
// }
//
// @SpringBean
// private DummyRepository dummyRepository;
//
// @SpringBean
// private CategoryDummyRepository categoryDummyRepository;
//
//
// public EditDummyPage(PageParameters parameters) {
// super(parameters);
// this.jpaRepository = dummyRepository;
// this.listPageClass = ListDummyPage.class;
//
// editForm.add(new TextFieldBootstrapFormComponent<>("name", new Model<>("Name")).required());
//
// editForm.add(new Select2ChoiceBootstrapFormComponent<CategoryDummy>("category", new Model<>(
// "Dummy Category"), new StringJpaTextChoiceProvider<CategoryDummy>(
// categoryDummyRepository)));
//
// }
//
// }
| import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
import org.apache.wicket.model.Model;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.spring.injection.annot.SpringBean;
import org.sample.persistence.dao.Dummy;
import org.sample.persistence.repository.DummyRepository;
import org.sample.web.pages.edits.EditDummyPage;
| /**
*
*/
package org.sample.web.pages.lists;
/**
* @author mpostelnicu
*
*/
public class ListDummyPage extends AbstractListPage<Dummy> {
private static final long serialVersionUID = 1L;
@SpringBean
| // Path: persistence/src/main/java/org/sample/persistence/dao/Dummy.java
// @Entity
// public class Dummy extends AbstractPersistable<Long> {
//
// private static final long serialVersionUID = 1L;
// private String name;
//
//
// @ManyToOne
// private CategoryDummy category;
//
// /**
// * @return the cat
// */
// public CategoryDummy getCategory() {
// return category;
// }
//
// /**
// * @param cat the cat to set
// */
// public void setCategory(CategoryDummy cat) {
// this.category = cat;
// }
//
// /**
// * @return the name
// */
// public String getName() {
// return name;
// }
//
// /**
// * @param name
// * the name to set
// */
// public void setName(String name) {
// this.name = name;
// }
//
// }
//
// Path: persistence/src/main/java/org/sample/persistence/repository/DummyRepository.java
// @Transactional
// public interface DummyRepository extends JpaRepository<Dummy, Long> {
//
// @Query("select c from Dummy c where c.name = ?1")
// List<Dummy> findByName(String name);
//
// }
//
// Path: web/src/main/java/org/sample/web/pages/edits/EditDummyPage.java
// public class EditDummyPage extends AbstractEditPage<Dummy> {
//
//
// private static final long serialVersionUID = 1L;
//
//
// /* (non-Javadoc)
// * @see org.devgateway.ccrs.web.wicket.page.AbstractEditPage#newInstance()
// */
// @Override
// protected Dummy newInstance() {
// return new Dummy();
// }
//
// @SpringBean
// private DummyRepository dummyRepository;
//
// @SpringBean
// private CategoryDummyRepository categoryDummyRepository;
//
//
// public EditDummyPage(PageParameters parameters) {
// super(parameters);
// this.jpaRepository = dummyRepository;
// this.listPageClass = ListDummyPage.class;
//
// editForm.add(new TextFieldBootstrapFormComponent<>("name", new Model<>("Name")).required());
//
// editForm.add(new Select2ChoiceBootstrapFormComponent<CategoryDummy>("category", new Model<>(
// "Dummy Category"), new StringJpaTextChoiceProvider<CategoryDummy>(
// categoryDummyRepository)));
//
// }
//
// }
// Path: web/src/main/java/org/sample/web/pages/lists/ListDummyPage.java
import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
import org.apache.wicket.model.Model;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.spring.injection.annot.SpringBean;
import org.sample.persistence.dao.Dummy;
import org.sample.persistence.repository.DummyRepository;
import org.sample.web.pages.edits.EditDummyPage;
/**
*
*/
package org.sample.web.pages.lists;
/**
* @author mpostelnicu
*
*/
public class ListDummyPage extends AbstractListPage<Dummy> {
private static final long serialVersionUID = 1L;
@SpringBean
| protected DummyRepository dummyRepository;
|
mpostelnicu/wicket-spring-jpa-bootstrap-boilerplate | web/src/main/java/org/sample/web/pages/lists/ListDummyPage.java | // Path: persistence/src/main/java/org/sample/persistence/dao/Dummy.java
// @Entity
// public class Dummy extends AbstractPersistable<Long> {
//
// private static final long serialVersionUID = 1L;
// private String name;
//
//
// @ManyToOne
// private CategoryDummy category;
//
// /**
// * @return the cat
// */
// public CategoryDummy getCategory() {
// return category;
// }
//
// /**
// * @param cat the cat to set
// */
// public void setCategory(CategoryDummy cat) {
// this.category = cat;
// }
//
// /**
// * @return the name
// */
// public String getName() {
// return name;
// }
//
// /**
// * @param name
// * the name to set
// */
// public void setName(String name) {
// this.name = name;
// }
//
// }
//
// Path: persistence/src/main/java/org/sample/persistence/repository/DummyRepository.java
// @Transactional
// public interface DummyRepository extends JpaRepository<Dummy, Long> {
//
// @Query("select c from Dummy c where c.name = ?1")
// List<Dummy> findByName(String name);
//
// }
//
// Path: web/src/main/java/org/sample/web/pages/edits/EditDummyPage.java
// public class EditDummyPage extends AbstractEditPage<Dummy> {
//
//
// private static final long serialVersionUID = 1L;
//
//
// /* (non-Javadoc)
// * @see org.devgateway.ccrs.web.wicket.page.AbstractEditPage#newInstance()
// */
// @Override
// protected Dummy newInstance() {
// return new Dummy();
// }
//
// @SpringBean
// private DummyRepository dummyRepository;
//
// @SpringBean
// private CategoryDummyRepository categoryDummyRepository;
//
//
// public EditDummyPage(PageParameters parameters) {
// super(parameters);
// this.jpaRepository = dummyRepository;
// this.listPageClass = ListDummyPage.class;
//
// editForm.add(new TextFieldBootstrapFormComponent<>("name", new Model<>("Name")).required());
//
// editForm.add(new Select2ChoiceBootstrapFormComponent<CategoryDummy>("category", new Model<>(
// "Dummy Category"), new StringJpaTextChoiceProvider<CategoryDummy>(
// categoryDummyRepository)));
//
// }
//
// }
| import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
import org.apache.wicket.model.Model;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.spring.injection.annot.SpringBean;
import org.sample.persistence.dao.Dummy;
import org.sample.persistence.repository.DummyRepository;
import org.sample.web.pages.edits.EditDummyPage;
| /**
*
*/
package org.sample.web.pages.lists;
/**
* @author mpostelnicu
*
*/
public class ListDummyPage extends AbstractListPage<Dummy> {
private static final long serialVersionUID = 1L;
@SpringBean
protected DummyRepository dummyRepository;
public ListDummyPage(PageParameters pageParameters) {
this.jpaRepository=dummyRepository;
| // Path: persistence/src/main/java/org/sample/persistence/dao/Dummy.java
// @Entity
// public class Dummy extends AbstractPersistable<Long> {
//
// private static final long serialVersionUID = 1L;
// private String name;
//
//
// @ManyToOne
// private CategoryDummy category;
//
// /**
// * @return the cat
// */
// public CategoryDummy getCategory() {
// return category;
// }
//
// /**
// * @param cat the cat to set
// */
// public void setCategory(CategoryDummy cat) {
// this.category = cat;
// }
//
// /**
// * @return the name
// */
// public String getName() {
// return name;
// }
//
// /**
// * @param name
// * the name to set
// */
// public void setName(String name) {
// this.name = name;
// }
//
// }
//
// Path: persistence/src/main/java/org/sample/persistence/repository/DummyRepository.java
// @Transactional
// public interface DummyRepository extends JpaRepository<Dummy, Long> {
//
// @Query("select c from Dummy c where c.name = ?1")
// List<Dummy> findByName(String name);
//
// }
//
// Path: web/src/main/java/org/sample/web/pages/edits/EditDummyPage.java
// public class EditDummyPage extends AbstractEditPage<Dummy> {
//
//
// private static final long serialVersionUID = 1L;
//
//
// /* (non-Javadoc)
// * @see org.devgateway.ccrs.web.wicket.page.AbstractEditPage#newInstance()
// */
// @Override
// protected Dummy newInstance() {
// return new Dummy();
// }
//
// @SpringBean
// private DummyRepository dummyRepository;
//
// @SpringBean
// private CategoryDummyRepository categoryDummyRepository;
//
//
// public EditDummyPage(PageParameters parameters) {
// super(parameters);
// this.jpaRepository = dummyRepository;
// this.listPageClass = ListDummyPage.class;
//
// editForm.add(new TextFieldBootstrapFormComponent<>("name", new Model<>("Name")).required());
//
// editForm.add(new Select2ChoiceBootstrapFormComponent<CategoryDummy>("category", new Model<>(
// "Dummy Category"), new StringJpaTextChoiceProvider<CategoryDummy>(
// categoryDummyRepository)));
//
// }
//
// }
// Path: web/src/main/java/org/sample/web/pages/lists/ListDummyPage.java
import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
import org.apache.wicket.model.Model;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.spring.injection.annot.SpringBean;
import org.sample.persistence.dao.Dummy;
import org.sample.persistence.repository.DummyRepository;
import org.sample.web.pages.edits.EditDummyPage;
/**
*
*/
package org.sample.web.pages.lists;
/**
* @author mpostelnicu
*
*/
public class ListDummyPage extends AbstractListPage<Dummy> {
private static final long serialVersionUID = 1L;
@SpringBean
protected DummyRepository dummyRepository;
public ListDummyPage(PageParameters pageParameters) {
this.jpaRepository=dummyRepository;
| this.editPageClass=EditDummyPage.class;
|
mpostelnicu/wicket-spring-jpa-bootstrap-boilerplate | web/src/main/java/org/sample/web/pages/HomePage.java | // Path: web/src/main/java/org/sample/web/app/security/Roles.java
// public final class Roles {
// public static final String USER="USER";
// public static final String ADMIN="ADMIN";
// }
//
// Path: web/src/main/java/org/sample/web/components/IconPanel.java
// public class IconPanel<C extends Page> extends Panel {
//
//
// private static final long serialVersionUID = 1L;
//
// private final BookmarkablePageLink<Void> bookmarkablePageLink;
// private final Label label;
// private Label image;
//
// public IconPanel(String id, IModel<String> labelModel, Class<C> pageClass, String iconClass) {
// super(id);
// bookmarkablePageLink=new BookmarkablePageLink<Void>("link", pageClass);
// add(bookmarkablePageLink);
// image=new Label("image");
// image.add(AttributeModifier.append("class", "fa fa-5x "+iconClass));
// bookmarkablePageLink.add(image);
// label=new Label("label",labelModel);
// bookmarkablePageLink.add(label);
// }
//
// }
//
// Path: web/src/main/java/org/sample/web/pages/lists/ListCategoryDummyPage.java
// public class ListCategoryDummyPage extends AbstractListPage<CategoryDummy> {
//
// private static final long serialVersionUID = 1L;
//
// @SpringBean
// protected CategoryDummyRepository categoryDummyRepository;
//
// public ListCategoryDummyPage(PageParameters pageParameters) {
//
// this.jpaRepository=categoryDummyRepository;
// this.editPageClass=EditCategoryDummyPage.class;
// columns.add(new PropertyColumn<CategoryDummy,String>(new Model<String>("Name"), "name", "name"));
// }
//
//
// }
//
// Path: web/src/main/java/org/sample/web/pages/lists/ListDummyPage.java
// public class ListDummyPage extends AbstractListPage<Dummy> {
//
// private static final long serialVersionUID = 1L;
//
// @SpringBean
// protected DummyRepository dummyRepository;
//
// public ListDummyPage(PageParameters pageParameters) {
//
// this.jpaRepository=dummyRepository;
// this.editPageClass=EditDummyPage.class;
// columns.add(new PropertyColumn<Dummy,String>(new Model<String>("Name"), "name", "name"));
// }
//
//
// }
//
// Path: web/src/main/java/org/sample/web/pages/nav/AbstractNavPage.java
// public abstract class AbstractNavPage extends HeaderFooter {
//
// private static final long serialVersionUID = 1L;
// protected RepeatingView listIcons;
//
// public AbstractNavPage() {
// super();
//
// add(createPageTitleTag("nav.title"));
// add(createPageHeading("nav.title"));
// add(createPageMessage("nav.message"));
//
// listIcons = new RepeatingView("listIcons");
// add(listIcons);
// }
//
// }
| import org.apache.wicket.authroles.authorization.strategies.role.annotations.AuthorizeInstantiation;
import org.apache.wicket.model.Model;
import org.sample.web.app.security.Roles;
import org.sample.web.components.IconPanel;
import org.sample.web.pages.lists.ListCategoryDummyPage;
import org.sample.web.pages.lists.ListDummyPage;
import org.sample.web.pages.nav.AbstractNavPage;
| package org.sample.web.pages;
/**
* @author mpostelnicu
*
*/
@AuthorizeInstantiation({ Roles.USER })
public class HomePage extends AbstractNavPage {
private static final long serialVersionUID = 1L;
public HomePage() {
super();
| // Path: web/src/main/java/org/sample/web/app/security/Roles.java
// public final class Roles {
// public static final String USER="USER";
// public static final String ADMIN="ADMIN";
// }
//
// Path: web/src/main/java/org/sample/web/components/IconPanel.java
// public class IconPanel<C extends Page> extends Panel {
//
//
// private static final long serialVersionUID = 1L;
//
// private final BookmarkablePageLink<Void> bookmarkablePageLink;
// private final Label label;
// private Label image;
//
// public IconPanel(String id, IModel<String> labelModel, Class<C> pageClass, String iconClass) {
// super(id);
// bookmarkablePageLink=new BookmarkablePageLink<Void>("link", pageClass);
// add(bookmarkablePageLink);
// image=new Label("image");
// image.add(AttributeModifier.append("class", "fa fa-5x "+iconClass));
// bookmarkablePageLink.add(image);
// label=new Label("label",labelModel);
// bookmarkablePageLink.add(label);
// }
//
// }
//
// Path: web/src/main/java/org/sample/web/pages/lists/ListCategoryDummyPage.java
// public class ListCategoryDummyPage extends AbstractListPage<CategoryDummy> {
//
// private static final long serialVersionUID = 1L;
//
// @SpringBean
// protected CategoryDummyRepository categoryDummyRepository;
//
// public ListCategoryDummyPage(PageParameters pageParameters) {
//
// this.jpaRepository=categoryDummyRepository;
// this.editPageClass=EditCategoryDummyPage.class;
// columns.add(new PropertyColumn<CategoryDummy,String>(new Model<String>("Name"), "name", "name"));
// }
//
//
// }
//
// Path: web/src/main/java/org/sample/web/pages/lists/ListDummyPage.java
// public class ListDummyPage extends AbstractListPage<Dummy> {
//
// private static final long serialVersionUID = 1L;
//
// @SpringBean
// protected DummyRepository dummyRepository;
//
// public ListDummyPage(PageParameters pageParameters) {
//
// this.jpaRepository=dummyRepository;
// this.editPageClass=EditDummyPage.class;
// columns.add(new PropertyColumn<Dummy,String>(new Model<String>("Name"), "name", "name"));
// }
//
//
// }
//
// Path: web/src/main/java/org/sample/web/pages/nav/AbstractNavPage.java
// public abstract class AbstractNavPage extends HeaderFooter {
//
// private static final long serialVersionUID = 1L;
// protected RepeatingView listIcons;
//
// public AbstractNavPage() {
// super();
//
// add(createPageTitleTag("nav.title"));
// add(createPageHeading("nav.title"));
// add(createPageMessage("nav.message"));
//
// listIcons = new RepeatingView("listIcons");
// add(listIcons);
// }
//
// }
// Path: web/src/main/java/org/sample/web/pages/HomePage.java
import org.apache.wicket.authroles.authorization.strategies.role.annotations.AuthorizeInstantiation;
import org.apache.wicket.model.Model;
import org.sample.web.app.security.Roles;
import org.sample.web.components.IconPanel;
import org.sample.web.pages.lists.ListCategoryDummyPage;
import org.sample.web.pages.lists.ListDummyPage;
import org.sample.web.pages.nav.AbstractNavPage;
package org.sample.web.pages;
/**
* @author mpostelnicu
*
*/
@AuthorizeInstantiation({ Roles.USER })
public class HomePage extends AbstractNavPage {
private static final long serialVersionUID = 1L;
public HomePage() {
super();
| listIcons.add(new IconPanel<ListDummyPage>(listIcons.newChildId(),
|
mpostelnicu/wicket-spring-jpa-bootstrap-boilerplate | web/src/main/java/org/sample/web/pages/HomePage.java | // Path: web/src/main/java/org/sample/web/app/security/Roles.java
// public final class Roles {
// public static final String USER="USER";
// public static final String ADMIN="ADMIN";
// }
//
// Path: web/src/main/java/org/sample/web/components/IconPanel.java
// public class IconPanel<C extends Page> extends Panel {
//
//
// private static final long serialVersionUID = 1L;
//
// private final BookmarkablePageLink<Void> bookmarkablePageLink;
// private final Label label;
// private Label image;
//
// public IconPanel(String id, IModel<String> labelModel, Class<C> pageClass, String iconClass) {
// super(id);
// bookmarkablePageLink=new BookmarkablePageLink<Void>("link", pageClass);
// add(bookmarkablePageLink);
// image=new Label("image");
// image.add(AttributeModifier.append("class", "fa fa-5x "+iconClass));
// bookmarkablePageLink.add(image);
// label=new Label("label",labelModel);
// bookmarkablePageLink.add(label);
// }
//
// }
//
// Path: web/src/main/java/org/sample/web/pages/lists/ListCategoryDummyPage.java
// public class ListCategoryDummyPage extends AbstractListPage<CategoryDummy> {
//
// private static final long serialVersionUID = 1L;
//
// @SpringBean
// protected CategoryDummyRepository categoryDummyRepository;
//
// public ListCategoryDummyPage(PageParameters pageParameters) {
//
// this.jpaRepository=categoryDummyRepository;
// this.editPageClass=EditCategoryDummyPage.class;
// columns.add(new PropertyColumn<CategoryDummy,String>(new Model<String>("Name"), "name", "name"));
// }
//
//
// }
//
// Path: web/src/main/java/org/sample/web/pages/lists/ListDummyPage.java
// public class ListDummyPage extends AbstractListPage<Dummy> {
//
// private static final long serialVersionUID = 1L;
//
// @SpringBean
// protected DummyRepository dummyRepository;
//
// public ListDummyPage(PageParameters pageParameters) {
//
// this.jpaRepository=dummyRepository;
// this.editPageClass=EditDummyPage.class;
// columns.add(new PropertyColumn<Dummy,String>(new Model<String>("Name"), "name", "name"));
// }
//
//
// }
//
// Path: web/src/main/java/org/sample/web/pages/nav/AbstractNavPage.java
// public abstract class AbstractNavPage extends HeaderFooter {
//
// private static final long serialVersionUID = 1L;
// protected RepeatingView listIcons;
//
// public AbstractNavPage() {
// super();
//
// add(createPageTitleTag("nav.title"));
// add(createPageHeading("nav.title"));
// add(createPageMessage("nav.message"));
//
// listIcons = new RepeatingView("listIcons");
// add(listIcons);
// }
//
// }
| import org.apache.wicket.authroles.authorization.strategies.role.annotations.AuthorizeInstantiation;
import org.apache.wicket.model.Model;
import org.sample.web.app.security.Roles;
import org.sample.web.components.IconPanel;
import org.sample.web.pages.lists.ListCategoryDummyPage;
import org.sample.web.pages.lists.ListDummyPage;
import org.sample.web.pages.nav.AbstractNavPage;
| package org.sample.web.pages;
/**
* @author mpostelnicu
*
*/
@AuthorizeInstantiation({ Roles.USER })
public class HomePage extends AbstractNavPage {
private static final long serialVersionUID = 1L;
public HomePage() {
super();
| // Path: web/src/main/java/org/sample/web/app/security/Roles.java
// public final class Roles {
// public static final String USER="USER";
// public static final String ADMIN="ADMIN";
// }
//
// Path: web/src/main/java/org/sample/web/components/IconPanel.java
// public class IconPanel<C extends Page> extends Panel {
//
//
// private static final long serialVersionUID = 1L;
//
// private final BookmarkablePageLink<Void> bookmarkablePageLink;
// private final Label label;
// private Label image;
//
// public IconPanel(String id, IModel<String> labelModel, Class<C> pageClass, String iconClass) {
// super(id);
// bookmarkablePageLink=new BookmarkablePageLink<Void>("link", pageClass);
// add(bookmarkablePageLink);
// image=new Label("image");
// image.add(AttributeModifier.append("class", "fa fa-5x "+iconClass));
// bookmarkablePageLink.add(image);
// label=new Label("label",labelModel);
// bookmarkablePageLink.add(label);
// }
//
// }
//
// Path: web/src/main/java/org/sample/web/pages/lists/ListCategoryDummyPage.java
// public class ListCategoryDummyPage extends AbstractListPage<CategoryDummy> {
//
// private static final long serialVersionUID = 1L;
//
// @SpringBean
// protected CategoryDummyRepository categoryDummyRepository;
//
// public ListCategoryDummyPage(PageParameters pageParameters) {
//
// this.jpaRepository=categoryDummyRepository;
// this.editPageClass=EditCategoryDummyPage.class;
// columns.add(new PropertyColumn<CategoryDummy,String>(new Model<String>("Name"), "name", "name"));
// }
//
//
// }
//
// Path: web/src/main/java/org/sample/web/pages/lists/ListDummyPage.java
// public class ListDummyPage extends AbstractListPage<Dummy> {
//
// private static final long serialVersionUID = 1L;
//
// @SpringBean
// protected DummyRepository dummyRepository;
//
// public ListDummyPage(PageParameters pageParameters) {
//
// this.jpaRepository=dummyRepository;
// this.editPageClass=EditDummyPage.class;
// columns.add(new PropertyColumn<Dummy,String>(new Model<String>("Name"), "name", "name"));
// }
//
//
// }
//
// Path: web/src/main/java/org/sample/web/pages/nav/AbstractNavPage.java
// public abstract class AbstractNavPage extends HeaderFooter {
//
// private static final long serialVersionUID = 1L;
// protected RepeatingView listIcons;
//
// public AbstractNavPage() {
// super();
//
// add(createPageTitleTag("nav.title"));
// add(createPageHeading("nav.title"));
// add(createPageMessage("nav.message"));
//
// listIcons = new RepeatingView("listIcons");
// add(listIcons);
// }
//
// }
// Path: web/src/main/java/org/sample/web/pages/HomePage.java
import org.apache.wicket.authroles.authorization.strategies.role.annotations.AuthorizeInstantiation;
import org.apache.wicket.model.Model;
import org.sample.web.app.security.Roles;
import org.sample.web.components.IconPanel;
import org.sample.web.pages.lists.ListCategoryDummyPage;
import org.sample.web.pages.lists.ListDummyPage;
import org.sample.web.pages.nav.AbstractNavPage;
package org.sample.web.pages;
/**
* @author mpostelnicu
*
*/
@AuthorizeInstantiation({ Roles.USER })
public class HomePage extends AbstractNavPage {
private static final long serialVersionUID = 1L;
public HomePage() {
super();
| listIcons.add(new IconPanel<ListDummyPage>(listIcons.newChildId(),
|
mpostelnicu/wicket-spring-jpa-bootstrap-boilerplate | web/src/main/java/org/sample/web/pages/HomePage.java | // Path: web/src/main/java/org/sample/web/app/security/Roles.java
// public final class Roles {
// public static final String USER="USER";
// public static final String ADMIN="ADMIN";
// }
//
// Path: web/src/main/java/org/sample/web/components/IconPanel.java
// public class IconPanel<C extends Page> extends Panel {
//
//
// private static final long serialVersionUID = 1L;
//
// private final BookmarkablePageLink<Void> bookmarkablePageLink;
// private final Label label;
// private Label image;
//
// public IconPanel(String id, IModel<String> labelModel, Class<C> pageClass, String iconClass) {
// super(id);
// bookmarkablePageLink=new BookmarkablePageLink<Void>("link", pageClass);
// add(bookmarkablePageLink);
// image=new Label("image");
// image.add(AttributeModifier.append("class", "fa fa-5x "+iconClass));
// bookmarkablePageLink.add(image);
// label=new Label("label",labelModel);
// bookmarkablePageLink.add(label);
// }
//
// }
//
// Path: web/src/main/java/org/sample/web/pages/lists/ListCategoryDummyPage.java
// public class ListCategoryDummyPage extends AbstractListPage<CategoryDummy> {
//
// private static final long serialVersionUID = 1L;
//
// @SpringBean
// protected CategoryDummyRepository categoryDummyRepository;
//
// public ListCategoryDummyPage(PageParameters pageParameters) {
//
// this.jpaRepository=categoryDummyRepository;
// this.editPageClass=EditCategoryDummyPage.class;
// columns.add(new PropertyColumn<CategoryDummy,String>(new Model<String>("Name"), "name", "name"));
// }
//
//
// }
//
// Path: web/src/main/java/org/sample/web/pages/lists/ListDummyPage.java
// public class ListDummyPage extends AbstractListPage<Dummy> {
//
// private static final long serialVersionUID = 1L;
//
// @SpringBean
// protected DummyRepository dummyRepository;
//
// public ListDummyPage(PageParameters pageParameters) {
//
// this.jpaRepository=dummyRepository;
// this.editPageClass=EditDummyPage.class;
// columns.add(new PropertyColumn<Dummy,String>(new Model<String>("Name"), "name", "name"));
// }
//
//
// }
//
// Path: web/src/main/java/org/sample/web/pages/nav/AbstractNavPage.java
// public abstract class AbstractNavPage extends HeaderFooter {
//
// private static final long serialVersionUID = 1L;
// protected RepeatingView listIcons;
//
// public AbstractNavPage() {
// super();
//
// add(createPageTitleTag("nav.title"));
// add(createPageHeading("nav.title"));
// add(createPageMessage("nav.message"));
//
// listIcons = new RepeatingView("listIcons");
// add(listIcons);
// }
//
// }
| import org.apache.wicket.authroles.authorization.strategies.role.annotations.AuthorizeInstantiation;
import org.apache.wicket.model.Model;
import org.sample.web.app.security.Roles;
import org.sample.web.components.IconPanel;
import org.sample.web.pages.lists.ListCategoryDummyPage;
import org.sample.web.pages.lists.ListDummyPage;
import org.sample.web.pages.nav.AbstractNavPage;
| package org.sample.web.pages;
/**
* @author mpostelnicu
*
*/
@AuthorizeInstantiation({ Roles.USER })
public class HomePage extends AbstractNavPage {
private static final long serialVersionUID = 1L;
public HomePage() {
super();
listIcons.add(new IconPanel<ListDummyPage>(listIcons.newChildId(),
Model.of("Dummy"), ListDummyPage.class, "fa-book"));
| // Path: web/src/main/java/org/sample/web/app/security/Roles.java
// public final class Roles {
// public static final String USER="USER";
// public static final String ADMIN="ADMIN";
// }
//
// Path: web/src/main/java/org/sample/web/components/IconPanel.java
// public class IconPanel<C extends Page> extends Panel {
//
//
// private static final long serialVersionUID = 1L;
//
// private final BookmarkablePageLink<Void> bookmarkablePageLink;
// private final Label label;
// private Label image;
//
// public IconPanel(String id, IModel<String> labelModel, Class<C> pageClass, String iconClass) {
// super(id);
// bookmarkablePageLink=new BookmarkablePageLink<Void>("link", pageClass);
// add(bookmarkablePageLink);
// image=new Label("image");
// image.add(AttributeModifier.append("class", "fa fa-5x "+iconClass));
// bookmarkablePageLink.add(image);
// label=new Label("label",labelModel);
// bookmarkablePageLink.add(label);
// }
//
// }
//
// Path: web/src/main/java/org/sample/web/pages/lists/ListCategoryDummyPage.java
// public class ListCategoryDummyPage extends AbstractListPage<CategoryDummy> {
//
// private static final long serialVersionUID = 1L;
//
// @SpringBean
// protected CategoryDummyRepository categoryDummyRepository;
//
// public ListCategoryDummyPage(PageParameters pageParameters) {
//
// this.jpaRepository=categoryDummyRepository;
// this.editPageClass=EditCategoryDummyPage.class;
// columns.add(new PropertyColumn<CategoryDummy,String>(new Model<String>("Name"), "name", "name"));
// }
//
//
// }
//
// Path: web/src/main/java/org/sample/web/pages/lists/ListDummyPage.java
// public class ListDummyPage extends AbstractListPage<Dummy> {
//
// private static final long serialVersionUID = 1L;
//
// @SpringBean
// protected DummyRepository dummyRepository;
//
// public ListDummyPage(PageParameters pageParameters) {
//
// this.jpaRepository=dummyRepository;
// this.editPageClass=EditDummyPage.class;
// columns.add(new PropertyColumn<Dummy,String>(new Model<String>("Name"), "name", "name"));
// }
//
//
// }
//
// Path: web/src/main/java/org/sample/web/pages/nav/AbstractNavPage.java
// public abstract class AbstractNavPage extends HeaderFooter {
//
// private static final long serialVersionUID = 1L;
// protected RepeatingView listIcons;
//
// public AbstractNavPage() {
// super();
//
// add(createPageTitleTag("nav.title"));
// add(createPageHeading("nav.title"));
// add(createPageMessage("nav.message"));
//
// listIcons = new RepeatingView("listIcons");
// add(listIcons);
// }
//
// }
// Path: web/src/main/java/org/sample/web/pages/HomePage.java
import org.apache.wicket.authroles.authorization.strategies.role.annotations.AuthorizeInstantiation;
import org.apache.wicket.model.Model;
import org.sample.web.app.security.Roles;
import org.sample.web.components.IconPanel;
import org.sample.web.pages.lists.ListCategoryDummyPage;
import org.sample.web.pages.lists.ListDummyPage;
import org.sample.web.pages.nav.AbstractNavPage;
package org.sample.web.pages;
/**
* @author mpostelnicu
*
*/
@AuthorizeInstantiation({ Roles.USER })
public class HomePage extends AbstractNavPage {
private static final long serialVersionUID = 1L;
public HomePage() {
super();
listIcons.add(new IconPanel<ListDummyPage>(listIcons.newChildId(),
Model.of("Dummy"), ListDummyPage.class, "fa-book"));
| listIcons.add(new IconPanel<ListCategoryDummyPage>(listIcons.newChildId(),
|
mpostelnicu/wicket-spring-jpa-bootstrap-boilerplate | web/src/main/java/org/sample/web/pages/HeaderFooter.java | // Path: web/src/main/java/org/sample/web/app/security/Roles.java
// public final class Roles {
// public static final String USER="USER";
// public static final String ADMIN="ADMIN";
// }
| import org.apache.wicket.Component;
import org.apache.wicket.authroles.authorization.strategies.role.metadata.MetaDataRoleAuthorizationStrategy;
import org.apache.wicket.model.Model;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.sample.web.app.security.Roles;
import de.agilecoders.wicket.core.markup.html.bootstrap.common.NotificationPanel;
import de.agilecoders.wicket.core.markup.html.bootstrap.image.IconType;
import de.agilecoders.wicket.core.markup.html.bootstrap.navbar.Navbar;
import de.agilecoders.wicket.core.markup.html.bootstrap.navbar.NavbarButton;
import de.agilecoders.wicket.core.markup.html.bootstrap.navbar.NavbarComponents; | package org.sample.web.pages;
/**
* @author mpostelnicu
*/
public abstract class HeaderFooter extends AbstractWebPage {
private static final long serialVersionUID = 1L;
protected NotificationPanel feedbackPanel;
@Override
protected void onInitialize() {
super.onInitialize();
add(createNavbar());
feedbackPanel = createFeedbackPanel();
add(feedbackPanel);
}
public HeaderFooter() {
super();
}
public HeaderFooter(PageParameters parameters) {
super(parameters);
}
protected void addHomePageButton(Navbar navbar) {
NavbarButton<HomePage> navbarButton = new NavbarButton<HomePage>(this.getApplication().getHomePage(),
Model.of("Home")).setIconType(IconType.home);
navbar.addComponents(NavbarComponents.transform(Navbar.ComponentPosition.LEFT, navbarButton));
}
protected void addLogoutButton(Navbar navbar) {
NavbarButton<Logout> navbarButton = new NavbarButton<Logout>(Logout.class, Model.of("Logout"))
.setIconType(IconType.off);
navbar.addComponents(NavbarComponents.transform(Navbar.ComponentPosition.RIGHT, navbarButton)); | // Path: web/src/main/java/org/sample/web/app/security/Roles.java
// public final class Roles {
// public static final String USER="USER";
// public static final String ADMIN="ADMIN";
// }
// Path: web/src/main/java/org/sample/web/pages/HeaderFooter.java
import org.apache.wicket.Component;
import org.apache.wicket.authroles.authorization.strategies.role.metadata.MetaDataRoleAuthorizationStrategy;
import org.apache.wicket.model.Model;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.sample.web.app.security.Roles;
import de.agilecoders.wicket.core.markup.html.bootstrap.common.NotificationPanel;
import de.agilecoders.wicket.core.markup.html.bootstrap.image.IconType;
import de.agilecoders.wicket.core.markup.html.bootstrap.navbar.Navbar;
import de.agilecoders.wicket.core.markup.html.bootstrap.navbar.NavbarButton;
import de.agilecoders.wicket.core.markup.html.bootstrap.navbar.NavbarComponents;
package org.sample.web.pages;
/**
* @author mpostelnicu
*/
public abstract class HeaderFooter extends AbstractWebPage {
private static final long serialVersionUID = 1L;
protected NotificationPanel feedbackPanel;
@Override
protected void onInitialize() {
super.onInitialize();
add(createNavbar());
feedbackPanel = createFeedbackPanel();
add(feedbackPanel);
}
public HeaderFooter() {
super();
}
public HeaderFooter(PageParameters parameters) {
super(parameters);
}
protected void addHomePageButton(Navbar navbar) {
NavbarButton<HomePage> navbarButton = new NavbarButton<HomePage>(this.getApplication().getHomePage(),
Model.of("Home")).setIconType(IconType.home);
navbar.addComponents(NavbarComponents.transform(Navbar.ComponentPosition.LEFT, navbarButton));
}
protected void addLogoutButton(Navbar navbar) {
NavbarButton<Logout> navbarButton = new NavbarButton<Logout>(Logout.class, Model.of("Logout"))
.setIconType(IconType.off);
navbar.addComponents(NavbarComponents.transform(Navbar.ComponentPosition.RIGHT, navbarButton)); | MetaDataRoleAuthorizationStrategy.authorize(navbarButton, Component.RENDER, Roles.USER); |
mpostelnicu/wicket-spring-jpa-bootstrap-boilerplate | web/src/main/java/org/sample/web/pages/lists/ListCategoryDummyPage.java | // Path: persistence/src/main/java/org/sample/persistence/dao/CategoryDummy.java
// @Entity
// public class CategoryDummy extends AbstractPersistable<Long> {
//
// /**
// *
// */
// private static final long serialVersionUID = 1L;
// private String name;
//
// @OneToMany(mappedBy = "category", fetch = FetchType.LAZY)
// private Set<Dummy> dummy = new HashSet<Dummy>();
//
// /**
// * @return the name
// */
// public String getName() {
// return name;
// }
//
// /**
// * @return the dummy
// */
// public Set<Dummy> getDummy() {
// return dummy;
// }
//
// /**
// * @param dummy the dummy to set
// */
// public void setDummy(Set<Dummy> dummy) {
// this.dummy = dummy;
// }
//
// /**
// * @param name
// * the name to set
// */
// public void setName(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
// }
//
// Path: persistence/src/main/java/org/sample/persistence/repository/CategoryDummyRepository.java
// @Transactional
// public interface CategoryDummyRepository extends JpaRepository<CategoryDummy, Long> {
//
// @Query("select c from CategoryDummy c where c.name = ?1")
// List<CategoryDummy> findByName(String name);
//
// }
//
// Path: web/src/main/java/org/sample/web/pages/edits/EditCategoryDummyPage.java
// public class EditCategoryDummyPage extends AbstractEditPage<CategoryDummy> {
//
//
// private static final long serialVersionUID = 1L;
//
//
// /* (non-Javadoc)
// * @see org.devgateway.ccrs.web.wicket.page.AbstractEditPage#newInstance()
// */
// @Override
// protected CategoryDummy newInstance() {
// return new CategoryDummy();
// }
//
// @SpringBean
// private CategoryDummyRepository categoryDummyRepository;
//
//
//
// public EditCategoryDummyPage(PageParameters parameters) {
// super(parameters);
// this.jpaRepository = categoryDummyRepository;
// this.listPageClass = ListCategoryDummyPage.class;
//
// editForm.add(new TextFieldBootstrapFormComponent<>("name", new Model<>("Name")).required());
//
//
// }
//
// }
| import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
import org.apache.wicket.model.Model;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.spring.injection.annot.SpringBean;
import org.sample.persistence.dao.CategoryDummy;
import org.sample.persistence.repository.CategoryDummyRepository;
import org.sample.web.pages.edits.EditCategoryDummyPage;
| /**
*
*/
package org.sample.web.pages.lists;
/**
* @author mpostelnicu
*
*/
public class ListCategoryDummyPage extends AbstractListPage<CategoryDummy> {
private static final long serialVersionUID = 1L;
@SpringBean
| // Path: persistence/src/main/java/org/sample/persistence/dao/CategoryDummy.java
// @Entity
// public class CategoryDummy extends AbstractPersistable<Long> {
//
// /**
// *
// */
// private static final long serialVersionUID = 1L;
// private String name;
//
// @OneToMany(mappedBy = "category", fetch = FetchType.LAZY)
// private Set<Dummy> dummy = new HashSet<Dummy>();
//
// /**
// * @return the name
// */
// public String getName() {
// return name;
// }
//
// /**
// * @return the dummy
// */
// public Set<Dummy> getDummy() {
// return dummy;
// }
//
// /**
// * @param dummy the dummy to set
// */
// public void setDummy(Set<Dummy> dummy) {
// this.dummy = dummy;
// }
//
// /**
// * @param name
// * the name to set
// */
// public void setName(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
// }
//
// Path: persistence/src/main/java/org/sample/persistence/repository/CategoryDummyRepository.java
// @Transactional
// public interface CategoryDummyRepository extends JpaRepository<CategoryDummy, Long> {
//
// @Query("select c from CategoryDummy c where c.name = ?1")
// List<CategoryDummy> findByName(String name);
//
// }
//
// Path: web/src/main/java/org/sample/web/pages/edits/EditCategoryDummyPage.java
// public class EditCategoryDummyPage extends AbstractEditPage<CategoryDummy> {
//
//
// private static final long serialVersionUID = 1L;
//
//
// /* (non-Javadoc)
// * @see org.devgateway.ccrs.web.wicket.page.AbstractEditPage#newInstance()
// */
// @Override
// protected CategoryDummy newInstance() {
// return new CategoryDummy();
// }
//
// @SpringBean
// private CategoryDummyRepository categoryDummyRepository;
//
//
//
// public EditCategoryDummyPage(PageParameters parameters) {
// super(parameters);
// this.jpaRepository = categoryDummyRepository;
// this.listPageClass = ListCategoryDummyPage.class;
//
// editForm.add(new TextFieldBootstrapFormComponent<>("name", new Model<>("Name")).required());
//
//
// }
//
// }
// Path: web/src/main/java/org/sample/web/pages/lists/ListCategoryDummyPage.java
import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
import org.apache.wicket.model.Model;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.spring.injection.annot.SpringBean;
import org.sample.persistence.dao.CategoryDummy;
import org.sample.persistence.repository.CategoryDummyRepository;
import org.sample.web.pages.edits.EditCategoryDummyPage;
/**
*
*/
package org.sample.web.pages.lists;
/**
* @author mpostelnicu
*
*/
public class ListCategoryDummyPage extends AbstractListPage<CategoryDummy> {
private static final long serialVersionUID = 1L;
@SpringBean
| protected CategoryDummyRepository categoryDummyRepository;
|
mpostelnicu/wicket-spring-jpa-bootstrap-boilerplate | web/src/main/java/org/sample/web/pages/lists/ListCategoryDummyPage.java | // Path: persistence/src/main/java/org/sample/persistence/dao/CategoryDummy.java
// @Entity
// public class CategoryDummy extends AbstractPersistable<Long> {
//
// /**
// *
// */
// private static final long serialVersionUID = 1L;
// private String name;
//
// @OneToMany(mappedBy = "category", fetch = FetchType.LAZY)
// private Set<Dummy> dummy = new HashSet<Dummy>();
//
// /**
// * @return the name
// */
// public String getName() {
// return name;
// }
//
// /**
// * @return the dummy
// */
// public Set<Dummy> getDummy() {
// return dummy;
// }
//
// /**
// * @param dummy the dummy to set
// */
// public void setDummy(Set<Dummy> dummy) {
// this.dummy = dummy;
// }
//
// /**
// * @param name
// * the name to set
// */
// public void setName(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
// }
//
// Path: persistence/src/main/java/org/sample/persistence/repository/CategoryDummyRepository.java
// @Transactional
// public interface CategoryDummyRepository extends JpaRepository<CategoryDummy, Long> {
//
// @Query("select c from CategoryDummy c where c.name = ?1")
// List<CategoryDummy> findByName(String name);
//
// }
//
// Path: web/src/main/java/org/sample/web/pages/edits/EditCategoryDummyPage.java
// public class EditCategoryDummyPage extends AbstractEditPage<CategoryDummy> {
//
//
// private static final long serialVersionUID = 1L;
//
//
// /* (non-Javadoc)
// * @see org.devgateway.ccrs.web.wicket.page.AbstractEditPage#newInstance()
// */
// @Override
// protected CategoryDummy newInstance() {
// return new CategoryDummy();
// }
//
// @SpringBean
// private CategoryDummyRepository categoryDummyRepository;
//
//
//
// public EditCategoryDummyPage(PageParameters parameters) {
// super(parameters);
// this.jpaRepository = categoryDummyRepository;
// this.listPageClass = ListCategoryDummyPage.class;
//
// editForm.add(new TextFieldBootstrapFormComponent<>("name", new Model<>("Name")).required());
//
//
// }
//
// }
| import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
import org.apache.wicket.model.Model;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.spring.injection.annot.SpringBean;
import org.sample.persistence.dao.CategoryDummy;
import org.sample.persistence.repository.CategoryDummyRepository;
import org.sample.web.pages.edits.EditCategoryDummyPage;
| /**
*
*/
package org.sample.web.pages.lists;
/**
* @author mpostelnicu
*
*/
public class ListCategoryDummyPage extends AbstractListPage<CategoryDummy> {
private static final long serialVersionUID = 1L;
@SpringBean
protected CategoryDummyRepository categoryDummyRepository;
public ListCategoryDummyPage(PageParameters pageParameters) {
this.jpaRepository=categoryDummyRepository;
| // Path: persistence/src/main/java/org/sample/persistence/dao/CategoryDummy.java
// @Entity
// public class CategoryDummy extends AbstractPersistable<Long> {
//
// /**
// *
// */
// private static final long serialVersionUID = 1L;
// private String name;
//
// @OneToMany(mappedBy = "category", fetch = FetchType.LAZY)
// private Set<Dummy> dummy = new HashSet<Dummy>();
//
// /**
// * @return the name
// */
// public String getName() {
// return name;
// }
//
// /**
// * @return the dummy
// */
// public Set<Dummy> getDummy() {
// return dummy;
// }
//
// /**
// * @param dummy the dummy to set
// */
// public void setDummy(Set<Dummy> dummy) {
// this.dummy = dummy;
// }
//
// /**
// * @param name
// * the name to set
// */
// public void setName(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
// }
//
// Path: persistence/src/main/java/org/sample/persistence/repository/CategoryDummyRepository.java
// @Transactional
// public interface CategoryDummyRepository extends JpaRepository<CategoryDummy, Long> {
//
// @Query("select c from CategoryDummy c where c.name = ?1")
// List<CategoryDummy> findByName(String name);
//
// }
//
// Path: web/src/main/java/org/sample/web/pages/edits/EditCategoryDummyPage.java
// public class EditCategoryDummyPage extends AbstractEditPage<CategoryDummy> {
//
//
// private static final long serialVersionUID = 1L;
//
//
// /* (non-Javadoc)
// * @see org.devgateway.ccrs.web.wicket.page.AbstractEditPage#newInstance()
// */
// @Override
// protected CategoryDummy newInstance() {
// return new CategoryDummy();
// }
//
// @SpringBean
// private CategoryDummyRepository categoryDummyRepository;
//
//
//
// public EditCategoryDummyPage(PageParameters parameters) {
// super(parameters);
// this.jpaRepository = categoryDummyRepository;
// this.listPageClass = ListCategoryDummyPage.class;
//
// editForm.add(new TextFieldBootstrapFormComponent<>("name", new Model<>("Name")).required());
//
//
// }
//
// }
// Path: web/src/main/java/org/sample/web/pages/lists/ListCategoryDummyPage.java
import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
import org.apache.wicket.model.Model;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.spring.injection.annot.SpringBean;
import org.sample.persistence.dao.CategoryDummy;
import org.sample.persistence.repository.CategoryDummyRepository;
import org.sample.web.pages.edits.EditCategoryDummyPage;
/**
*
*/
package org.sample.web.pages.lists;
/**
* @author mpostelnicu
*
*/
public class ListCategoryDummyPage extends AbstractListPage<CategoryDummy> {
private static final long serialVersionUID = 1L;
@SpringBean
protected CategoryDummyRepository categoryDummyRepository;
public ListCategoryDummyPage(PageParameters pageParameters) {
this.jpaRepository=categoryDummyRepository;
| this.editPageClass=EditCategoryDummyPage.class;
|
mpostelnicu/wicket-spring-jpa-bootstrap-boilerplate | web/src/main/java/org/sample/web/pages/Login.java | // Path: web/src/main/java/org/sample/web/app/SSAuthenticatedWebSession.java
// public class SSAuthenticatedWebSession extends AuthenticatedWebSession {
//
// private static final long serialVersionUID = 1L;
//
//
// protected final Logger log = LoggerFactory.getLogger(getClass());
//
//
// @SpringBean(name = "authenticationManagerBean")
// private AuthenticationManager authenticationManager;
//
//
// private HttpSession httpSession;
//
// public SSAuthenticatedWebSession(Request request) {
// super(request);
// Injector.get().inject(this);
// this.httpSession = ((HttpServletRequest) request.getContainerRequest()).getSession();
// if (authenticationManager == null) {
// throw new IllegalStateException("Injection of AuthenticationManager failed.");
// }
//
// }
//
// public static SSAuthenticatedWebSession getSSAuthenticatedWebSession() {
// return (SSAuthenticatedWebSession) Session.get();
// }
//
// @Override
// public boolean authenticate(String username, String password) {
// boolean authenticated;
// try {
// Authentication authentication = authenticationManager.authenticate(
// new UsernamePasswordAuthenticationToken(username, password));
// SecurityContextHolder.getContext().setAuthentication(authentication);
// httpSession.setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY,
// SecurityContextHolder.getContext());
// authenticated = authentication.isAuthenticated();
// } catch (AuthenticationException e) {
// log.warn("User '{}' failed to login. Reason: {}", username, e.getMessage());
// authenticated = false;
// }
// return authenticated;
// }
//
// @Override
// public Roles getRoles() {
// Roles roles = new Roles();
// getRolesIfSignedIn(roles);
// return roles;
// }
//
// private void getRolesIfSignedIn(Roles roles) {
// if (isSignedIn()) {
// Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
// addRolesFromAuthentication(roles, authentication);
// }
// }
//
// private void addRolesFromAuthentication(Roles roles, Authentication authentication) {
// for (GrantedAuthority authority : authentication.getAuthorities()) {
// roles.add(authority.getAuthority().replaceFirst("ROLE_",""));
// }
// }
//
// }
//
// Path: web/src/main/java/org/sample/web/components/PlaceholderBehavior.java
// public class PlaceholderBehavior extends Behavior {
//
//
// private static final long serialVersionUID = 1L;
// private final String placeholder;
//
// public PlaceholderBehavior(String placeholder) {
// this.placeholder = placeholder;
// }
//
// @Override
// public void onComponentTag(Component component, ComponentTag tag) {
// super.onComponentTag(component, tag);
// tag.put("placeholder", placeholder);
// }
// }
//
// Path: web/src/main/java/org/sample/web/components/RequiredBehavior.java
// public class RequiredBehavior extends Behavior {
//
// private static final long serialVersionUID = 1L;
//
// @Override
// public void onComponentTag(Component component, ComponentTag tag) {
// super.onComponentTag(component, tag);
// tag.put("required", "required");
// }
// }
| import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxButton;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.PasswordTextField;
import org.apache.wicket.markup.html.form.RequiredTextField;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.form.validation.FormComponentFeedbackBorder;
import org.apache.wicket.model.Model;
import org.sample.web.app.SSAuthenticatedWebSession;
import org.sample.web.components.PlaceholderBehavior;
import org.sample.web.components.RequiredBehavior;
import org.wicketstuff.annotation.mount.MountPath;
import de.agilecoders.wicket.core.markup.html.bootstrap.form.BootstrapForm; | package org.sample.web.pages;
/**
* @author mpostelnicu
*
*/
@MountPath("/login")
public class Login extends HeaderFooter {
private static final long serialVersionUID = 1L;
class LoginForm extends BootstrapForm<Void> {
private static final long serialVersionUID = 1L;
private TextField<String> usernameField;
private TextField<String> passwordField;
public void createAndAddToLoginFormUsernameAndPasswordFields() {
add(new FormComponentFeedbackBorder("border").add(
(usernameField = new RequiredTextField<String>("username", Model.of(""))))); | // Path: web/src/main/java/org/sample/web/app/SSAuthenticatedWebSession.java
// public class SSAuthenticatedWebSession extends AuthenticatedWebSession {
//
// private static final long serialVersionUID = 1L;
//
//
// protected final Logger log = LoggerFactory.getLogger(getClass());
//
//
// @SpringBean(name = "authenticationManagerBean")
// private AuthenticationManager authenticationManager;
//
//
// private HttpSession httpSession;
//
// public SSAuthenticatedWebSession(Request request) {
// super(request);
// Injector.get().inject(this);
// this.httpSession = ((HttpServletRequest) request.getContainerRequest()).getSession();
// if (authenticationManager == null) {
// throw new IllegalStateException("Injection of AuthenticationManager failed.");
// }
//
// }
//
// public static SSAuthenticatedWebSession getSSAuthenticatedWebSession() {
// return (SSAuthenticatedWebSession) Session.get();
// }
//
// @Override
// public boolean authenticate(String username, String password) {
// boolean authenticated;
// try {
// Authentication authentication = authenticationManager.authenticate(
// new UsernamePasswordAuthenticationToken(username, password));
// SecurityContextHolder.getContext().setAuthentication(authentication);
// httpSession.setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY,
// SecurityContextHolder.getContext());
// authenticated = authentication.isAuthenticated();
// } catch (AuthenticationException e) {
// log.warn("User '{}' failed to login. Reason: {}", username, e.getMessage());
// authenticated = false;
// }
// return authenticated;
// }
//
// @Override
// public Roles getRoles() {
// Roles roles = new Roles();
// getRolesIfSignedIn(roles);
// return roles;
// }
//
// private void getRolesIfSignedIn(Roles roles) {
// if (isSignedIn()) {
// Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
// addRolesFromAuthentication(roles, authentication);
// }
// }
//
// private void addRolesFromAuthentication(Roles roles, Authentication authentication) {
// for (GrantedAuthority authority : authentication.getAuthorities()) {
// roles.add(authority.getAuthority().replaceFirst("ROLE_",""));
// }
// }
//
// }
//
// Path: web/src/main/java/org/sample/web/components/PlaceholderBehavior.java
// public class PlaceholderBehavior extends Behavior {
//
//
// private static final long serialVersionUID = 1L;
// private final String placeholder;
//
// public PlaceholderBehavior(String placeholder) {
// this.placeholder = placeholder;
// }
//
// @Override
// public void onComponentTag(Component component, ComponentTag tag) {
// super.onComponentTag(component, tag);
// tag.put("placeholder", placeholder);
// }
// }
//
// Path: web/src/main/java/org/sample/web/components/RequiredBehavior.java
// public class RequiredBehavior extends Behavior {
//
// private static final long serialVersionUID = 1L;
//
// @Override
// public void onComponentTag(Component component, ComponentTag tag) {
// super.onComponentTag(component, tag);
// tag.put("required", "required");
// }
// }
// Path: web/src/main/java/org/sample/web/pages/Login.java
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxButton;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.PasswordTextField;
import org.apache.wicket.markup.html.form.RequiredTextField;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.form.validation.FormComponentFeedbackBorder;
import org.apache.wicket.model.Model;
import org.sample.web.app.SSAuthenticatedWebSession;
import org.sample.web.components.PlaceholderBehavior;
import org.sample.web.components.RequiredBehavior;
import org.wicketstuff.annotation.mount.MountPath;
import de.agilecoders.wicket.core.markup.html.bootstrap.form.BootstrapForm;
package org.sample.web.pages;
/**
* @author mpostelnicu
*
*/
@MountPath("/login")
public class Login extends HeaderFooter {
private static final long serialVersionUID = 1L;
class LoginForm extends BootstrapForm<Void> {
private static final long serialVersionUID = 1L;
private TextField<String> usernameField;
private TextField<String> passwordField;
public void createAndAddToLoginFormUsernameAndPasswordFields() {
add(new FormComponentFeedbackBorder("border").add(
(usernameField = new RequiredTextField<String>("username", Model.of(""))))); | usernameField.add(new PlaceholderBehavior(getString("label.username"))); |
mpostelnicu/wicket-spring-jpa-bootstrap-boilerplate | web/src/main/java/org/sample/web/pages/Login.java | // Path: web/src/main/java/org/sample/web/app/SSAuthenticatedWebSession.java
// public class SSAuthenticatedWebSession extends AuthenticatedWebSession {
//
// private static final long serialVersionUID = 1L;
//
//
// protected final Logger log = LoggerFactory.getLogger(getClass());
//
//
// @SpringBean(name = "authenticationManagerBean")
// private AuthenticationManager authenticationManager;
//
//
// private HttpSession httpSession;
//
// public SSAuthenticatedWebSession(Request request) {
// super(request);
// Injector.get().inject(this);
// this.httpSession = ((HttpServletRequest) request.getContainerRequest()).getSession();
// if (authenticationManager == null) {
// throw new IllegalStateException("Injection of AuthenticationManager failed.");
// }
//
// }
//
// public static SSAuthenticatedWebSession getSSAuthenticatedWebSession() {
// return (SSAuthenticatedWebSession) Session.get();
// }
//
// @Override
// public boolean authenticate(String username, String password) {
// boolean authenticated;
// try {
// Authentication authentication = authenticationManager.authenticate(
// new UsernamePasswordAuthenticationToken(username, password));
// SecurityContextHolder.getContext().setAuthentication(authentication);
// httpSession.setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY,
// SecurityContextHolder.getContext());
// authenticated = authentication.isAuthenticated();
// } catch (AuthenticationException e) {
// log.warn("User '{}' failed to login. Reason: {}", username, e.getMessage());
// authenticated = false;
// }
// return authenticated;
// }
//
// @Override
// public Roles getRoles() {
// Roles roles = new Roles();
// getRolesIfSignedIn(roles);
// return roles;
// }
//
// private void getRolesIfSignedIn(Roles roles) {
// if (isSignedIn()) {
// Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
// addRolesFromAuthentication(roles, authentication);
// }
// }
//
// private void addRolesFromAuthentication(Roles roles, Authentication authentication) {
// for (GrantedAuthority authority : authentication.getAuthorities()) {
// roles.add(authority.getAuthority().replaceFirst("ROLE_",""));
// }
// }
//
// }
//
// Path: web/src/main/java/org/sample/web/components/PlaceholderBehavior.java
// public class PlaceholderBehavior extends Behavior {
//
//
// private static final long serialVersionUID = 1L;
// private final String placeholder;
//
// public PlaceholderBehavior(String placeholder) {
// this.placeholder = placeholder;
// }
//
// @Override
// public void onComponentTag(Component component, ComponentTag tag) {
// super.onComponentTag(component, tag);
// tag.put("placeholder", placeholder);
// }
// }
//
// Path: web/src/main/java/org/sample/web/components/RequiredBehavior.java
// public class RequiredBehavior extends Behavior {
//
// private static final long serialVersionUID = 1L;
//
// @Override
// public void onComponentTag(Component component, ComponentTag tag) {
// super.onComponentTag(component, tag);
// tag.put("required", "required");
// }
// }
| import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxButton;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.PasswordTextField;
import org.apache.wicket.markup.html.form.RequiredTextField;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.form.validation.FormComponentFeedbackBorder;
import org.apache.wicket.model.Model;
import org.sample.web.app.SSAuthenticatedWebSession;
import org.sample.web.components.PlaceholderBehavior;
import org.sample.web.components.RequiredBehavior;
import org.wicketstuff.annotation.mount.MountPath;
import de.agilecoders.wicket.core.markup.html.bootstrap.form.BootstrapForm; | package org.sample.web.pages;
/**
* @author mpostelnicu
*
*/
@MountPath("/login")
public class Login extends HeaderFooter {
private static final long serialVersionUID = 1L;
class LoginForm extends BootstrapForm<Void> {
private static final long serialVersionUID = 1L;
private TextField<String> usernameField;
private TextField<String> passwordField;
public void createAndAddToLoginFormUsernameAndPasswordFields() {
add(new FormComponentFeedbackBorder("border").add(
(usernameField = new RequiredTextField<String>("username", Model.of("")))));
usernameField.add(new PlaceholderBehavior(getString("label.username"))); | // Path: web/src/main/java/org/sample/web/app/SSAuthenticatedWebSession.java
// public class SSAuthenticatedWebSession extends AuthenticatedWebSession {
//
// private static final long serialVersionUID = 1L;
//
//
// protected final Logger log = LoggerFactory.getLogger(getClass());
//
//
// @SpringBean(name = "authenticationManagerBean")
// private AuthenticationManager authenticationManager;
//
//
// private HttpSession httpSession;
//
// public SSAuthenticatedWebSession(Request request) {
// super(request);
// Injector.get().inject(this);
// this.httpSession = ((HttpServletRequest) request.getContainerRequest()).getSession();
// if (authenticationManager == null) {
// throw new IllegalStateException("Injection of AuthenticationManager failed.");
// }
//
// }
//
// public static SSAuthenticatedWebSession getSSAuthenticatedWebSession() {
// return (SSAuthenticatedWebSession) Session.get();
// }
//
// @Override
// public boolean authenticate(String username, String password) {
// boolean authenticated;
// try {
// Authentication authentication = authenticationManager.authenticate(
// new UsernamePasswordAuthenticationToken(username, password));
// SecurityContextHolder.getContext().setAuthentication(authentication);
// httpSession.setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY,
// SecurityContextHolder.getContext());
// authenticated = authentication.isAuthenticated();
// } catch (AuthenticationException e) {
// log.warn("User '{}' failed to login. Reason: {}", username, e.getMessage());
// authenticated = false;
// }
// return authenticated;
// }
//
// @Override
// public Roles getRoles() {
// Roles roles = new Roles();
// getRolesIfSignedIn(roles);
// return roles;
// }
//
// private void getRolesIfSignedIn(Roles roles) {
// if (isSignedIn()) {
// Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
// addRolesFromAuthentication(roles, authentication);
// }
// }
//
// private void addRolesFromAuthentication(Roles roles, Authentication authentication) {
// for (GrantedAuthority authority : authentication.getAuthorities()) {
// roles.add(authority.getAuthority().replaceFirst("ROLE_",""));
// }
// }
//
// }
//
// Path: web/src/main/java/org/sample/web/components/PlaceholderBehavior.java
// public class PlaceholderBehavior extends Behavior {
//
//
// private static final long serialVersionUID = 1L;
// private final String placeholder;
//
// public PlaceholderBehavior(String placeholder) {
// this.placeholder = placeholder;
// }
//
// @Override
// public void onComponentTag(Component component, ComponentTag tag) {
// super.onComponentTag(component, tag);
// tag.put("placeholder", placeholder);
// }
// }
//
// Path: web/src/main/java/org/sample/web/components/RequiredBehavior.java
// public class RequiredBehavior extends Behavior {
//
// private static final long serialVersionUID = 1L;
//
// @Override
// public void onComponentTag(Component component, ComponentTag tag) {
// super.onComponentTag(component, tag);
// tag.put("required", "required");
// }
// }
// Path: web/src/main/java/org/sample/web/pages/Login.java
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxButton;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.PasswordTextField;
import org.apache.wicket.markup.html.form.RequiredTextField;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.form.validation.FormComponentFeedbackBorder;
import org.apache.wicket.model.Model;
import org.sample.web.app.SSAuthenticatedWebSession;
import org.sample.web.components.PlaceholderBehavior;
import org.sample.web.components.RequiredBehavior;
import org.wicketstuff.annotation.mount.MountPath;
import de.agilecoders.wicket.core.markup.html.bootstrap.form.BootstrapForm;
package org.sample.web.pages;
/**
* @author mpostelnicu
*
*/
@MountPath("/login")
public class Login extends HeaderFooter {
private static final long serialVersionUID = 1L;
class LoginForm extends BootstrapForm<Void> {
private static final long serialVersionUID = 1L;
private TextField<String> usernameField;
private TextField<String> passwordField;
public void createAndAddToLoginFormUsernameAndPasswordFields() {
add(new FormComponentFeedbackBorder("border").add(
(usernameField = new RequiredTextField<String>("username", Model.of("")))));
usernameField.add(new PlaceholderBehavior(getString("label.username"))); | usernameField.add(new RequiredBehavior()); |
mpostelnicu/wicket-spring-jpa-bootstrap-boilerplate | web/src/main/java/org/sample/web/pages/Login.java | // Path: web/src/main/java/org/sample/web/app/SSAuthenticatedWebSession.java
// public class SSAuthenticatedWebSession extends AuthenticatedWebSession {
//
// private static final long serialVersionUID = 1L;
//
//
// protected final Logger log = LoggerFactory.getLogger(getClass());
//
//
// @SpringBean(name = "authenticationManagerBean")
// private AuthenticationManager authenticationManager;
//
//
// private HttpSession httpSession;
//
// public SSAuthenticatedWebSession(Request request) {
// super(request);
// Injector.get().inject(this);
// this.httpSession = ((HttpServletRequest) request.getContainerRequest()).getSession();
// if (authenticationManager == null) {
// throw new IllegalStateException("Injection of AuthenticationManager failed.");
// }
//
// }
//
// public static SSAuthenticatedWebSession getSSAuthenticatedWebSession() {
// return (SSAuthenticatedWebSession) Session.get();
// }
//
// @Override
// public boolean authenticate(String username, String password) {
// boolean authenticated;
// try {
// Authentication authentication = authenticationManager.authenticate(
// new UsernamePasswordAuthenticationToken(username, password));
// SecurityContextHolder.getContext().setAuthentication(authentication);
// httpSession.setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY,
// SecurityContextHolder.getContext());
// authenticated = authentication.isAuthenticated();
// } catch (AuthenticationException e) {
// log.warn("User '{}' failed to login. Reason: {}", username, e.getMessage());
// authenticated = false;
// }
// return authenticated;
// }
//
// @Override
// public Roles getRoles() {
// Roles roles = new Roles();
// getRolesIfSignedIn(roles);
// return roles;
// }
//
// private void getRolesIfSignedIn(Roles roles) {
// if (isSignedIn()) {
// Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
// addRolesFromAuthentication(roles, authentication);
// }
// }
//
// private void addRolesFromAuthentication(Roles roles, Authentication authentication) {
// for (GrantedAuthority authority : authentication.getAuthorities()) {
// roles.add(authority.getAuthority().replaceFirst("ROLE_",""));
// }
// }
//
// }
//
// Path: web/src/main/java/org/sample/web/components/PlaceholderBehavior.java
// public class PlaceholderBehavior extends Behavior {
//
//
// private static final long serialVersionUID = 1L;
// private final String placeholder;
//
// public PlaceholderBehavior(String placeholder) {
// this.placeholder = placeholder;
// }
//
// @Override
// public void onComponentTag(Component component, ComponentTag tag) {
// super.onComponentTag(component, tag);
// tag.put("placeholder", placeholder);
// }
// }
//
// Path: web/src/main/java/org/sample/web/components/RequiredBehavior.java
// public class RequiredBehavior extends Behavior {
//
// private static final long serialVersionUID = 1L;
//
// @Override
// public void onComponentTag(Component component, ComponentTag tag) {
// super.onComponentTag(component, tag);
// tag.put("required", "required");
// }
// }
| import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxButton;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.PasswordTextField;
import org.apache.wicket.markup.html.form.RequiredTextField;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.form.validation.FormComponentFeedbackBorder;
import org.apache.wicket.model.Model;
import org.sample.web.app.SSAuthenticatedWebSession;
import org.sample.web.components.PlaceholderBehavior;
import org.sample.web.components.RequiredBehavior;
import org.wicketstuff.annotation.mount.MountPath;
import de.agilecoders.wicket.core.markup.html.bootstrap.form.BootstrapForm; | package org.sample.web.pages;
/**
* @author mpostelnicu
*
*/
@MountPath("/login")
public class Login extends HeaderFooter {
private static final long serialVersionUID = 1L;
class LoginForm extends BootstrapForm<Void> {
private static final long serialVersionUID = 1L;
private TextField<String> usernameField;
private TextField<String> passwordField;
public void createAndAddToLoginFormUsernameAndPasswordFields() {
add(new FormComponentFeedbackBorder("border").add(
(usernameField = new RequiredTextField<String>("username", Model.of("")))));
usernameField.add(new PlaceholderBehavior(getString("label.username")));
usernameField.add(new RequiredBehavior());
add(passwordField = new PasswordTextField("password", Model.of("")));
passwordField.add(new PlaceholderBehavior(getString("label.password")));
passwordField.add(new RequiredBehavior());
}
public LoginForm(String id) {
super(id);
IndicatingAjaxButton submit = new IndicatingAjaxButton("submit", Model.of("Submit")) {
private static final long serialVersionUID = 1L;
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) { | // Path: web/src/main/java/org/sample/web/app/SSAuthenticatedWebSession.java
// public class SSAuthenticatedWebSession extends AuthenticatedWebSession {
//
// private static final long serialVersionUID = 1L;
//
//
// protected final Logger log = LoggerFactory.getLogger(getClass());
//
//
// @SpringBean(name = "authenticationManagerBean")
// private AuthenticationManager authenticationManager;
//
//
// private HttpSession httpSession;
//
// public SSAuthenticatedWebSession(Request request) {
// super(request);
// Injector.get().inject(this);
// this.httpSession = ((HttpServletRequest) request.getContainerRequest()).getSession();
// if (authenticationManager == null) {
// throw new IllegalStateException("Injection of AuthenticationManager failed.");
// }
//
// }
//
// public static SSAuthenticatedWebSession getSSAuthenticatedWebSession() {
// return (SSAuthenticatedWebSession) Session.get();
// }
//
// @Override
// public boolean authenticate(String username, String password) {
// boolean authenticated;
// try {
// Authentication authentication = authenticationManager.authenticate(
// new UsernamePasswordAuthenticationToken(username, password));
// SecurityContextHolder.getContext().setAuthentication(authentication);
// httpSession.setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY,
// SecurityContextHolder.getContext());
// authenticated = authentication.isAuthenticated();
// } catch (AuthenticationException e) {
// log.warn("User '{}' failed to login. Reason: {}", username, e.getMessage());
// authenticated = false;
// }
// return authenticated;
// }
//
// @Override
// public Roles getRoles() {
// Roles roles = new Roles();
// getRolesIfSignedIn(roles);
// return roles;
// }
//
// private void getRolesIfSignedIn(Roles roles) {
// if (isSignedIn()) {
// Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
// addRolesFromAuthentication(roles, authentication);
// }
// }
//
// private void addRolesFromAuthentication(Roles roles, Authentication authentication) {
// for (GrantedAuthority authority : authentication.getAuthorities()) {
// roles.add(authority.getAuthority().replaceFirst("ROLE_",""));
// }
// }
//
// }
//
// Path: web/src/main/java/org/sample/web/components/PlaceholderBehavior.java
// public class PlaceholderBehavior extends Behavior {
//
//
// private static final long serialVersionUID = 1L;
// private final String placeholder;
//
// public PlaceholderBehavior(String placeholder) {
// this.placeholder = placeholder;
// }
//
// @Override
// public void onComponentTag(Component component, ComponentTag tag) {
// super.onComponentTag(component, tag);
// tag.put("placeholder", placeholder);
// }
// }
//
// Path: web/src/main/java/org/sample/web/components/RequiredBehavior.java
// public class RequiredBehavior extends Behavior {
//
// private static final long serialVersionUID = 1L;
//
// @Override
// public void onComponentTag(Component component, ComponentTag tag) {
// super.onComponentTag(component, tag);
// tag.put("required", "required");
// }
// }
// Path: web/src/main/java/org/sample/web/pages/Login.java
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxButton;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.PasswordTextField;
import org.apache.wicket.markup.html.form.RequiredTextField;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.form.validation.FormComponentFeedbackBorder;
import org.apache.wicket.model.Model;
import org.sample.web.app.SSAuthenticatedWebSession;
import org.sample.web.components.PlaceholderBehavior;
import org.sample.web.components.RequiredBehavior;
import org.wicketstuff.annotation.mount.MountPath;
import de.agilecoders.wicket.core.markup.html.bootstrap.form.BootstrapForm;
package org.sample.web.pages;
/**
* @author mpostelnicu
*
*/
@MountPath("/login")
public class Login extends HeaderFooter {
private static final long serialVersionUID = 1L;
class LoginForm extends BootstrapForm<Void> {
private static final long serialVersionUID = 1L;
private TextField<String> usernameField;
private TextField<String> passwordField;
public void createAndAddToLoginFormUsernameAndPasswordFields() {
add(new FormComponentFeedbackBorder("border").add(
(usernameField = new RequiredTextField<String>("username", Model.of("")))));
usernameField.add(new PlaceholderBehavior(getString("label.username")));
usernameField.add(new RequiredBehavior());
add(passwordField = new PasswordTextField("password", Model.of("")));
passwordField.add(new PlaceholderBehavior(getString("label.password")));
passwordField.add(new RequiredBehavior());
}
public LoginForm(String id) {
super(id);
IndicatingAjaxButton submit = new IndicatingAjaxButton("submit", Model.of("Submit")) {
private static final long serialVersionUID = 1L;
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) { | SSAuthenticatedWebSession session = SSAuthenticatedWebSession.getSSAuthenticatedWebSession(); |
mpostelnicu/wicket-spring-jpa-bootstrap-boilerplate | web/src/main/java/org/sample/web/components/GenericBootstrapFormComponent.java | // Path: web/src/main/java/org/sample/web/models/SubComponentWrapModel.java
// public class SubComponentWrapModel<T> implements IWrapModel<T> {
//
// private static final long serialVersionUID = 1L;
// private Component parent;
//
// public SubComponentWrapModel(Component parent) {
// this.parent=parent;
// }
//
// /* (non-Javadoc)
// * @see org.apache.wicket.model.IWrapModel#getWrappedModel()
// */
// @Override
// public IModel<?> getWrappedModel() {
// return parent.getDefaultModel();
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public T getObject() {
// return (T) parent.getDefaultModelObject();
// }
//
// @Override
// public void setObject(T object) {
// parent.setDefaultModelObject(object);
// }
//
// @Override
// public void detach() {
// IModel<?> wrappedModel = getWrappedModel();
// if(wrappedModel!=null) wrappedModel.detach();
// }
//
// }
| import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.FormComponent;
import org.apache.wicket.markup.html.form.validation.FormComponentFeedbackBorder;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;
import org.sample.web.models.SubComponentWrapModel;
import de.agilecoders.wicket.core.markup.html.bootstrap.form.InputBehavior;
import de.agilecoders.wicket.core.markup.html.bootstrap.form.InputBehavior.Size;
| /**
*
*/
package org.sample.web.components;
/**
* @author mpostelnicu
*
*/
public abstract class GenericBootstrapFormComponent<TYPE, FIELD extends FormComponent<TYPE>> extends Panel {
private static final long serialVersionUID = 1L;
protected FormComponentFeedbackBorder border;
protected FIELD field;
protected InputBehavior sizeBehavior;
@SuppressWarnings("unchecked")
protected IModel<TYPE> initFieldModel() {
if (getDefaultModel() == null)
| // Path: web/src/main/java/org/sample/web/models/SubComponentWrapModel.java
// public class SubComponentWrapModel<T> implements IWrapModel<T> {
//
// private static final long serialVersionUID = 1L;
// private Component parent;
//
// public SubComponentWrapModel(Component parent) {
// this.parent=parent;
// }
//
// /* (non-Javadoc)
// * @see org.apache.wicket.model.IWrapModel#getWrappedModel()
// */
// @Override
// public IModel<?> getWrappedModel() {
// return parent.getDefaultModel();
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public T getObject() {
// return (T) parent.getDefaultModelObject();
// }
//
// @Override
// public void setObject(T object) {
// parent.setDefaultModelObject(object);
// }
//
// @Override
// public void detach() {
// IModel<?> wrappedModel = getWrappedModel();
// if(wrappedModel!=null) wrappedModel.detach();
// }
//
// }
// Path: web/src/main/java/org/sample/web/components/GenericBootstrapFormComponent.java
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.FormComponent;
import org.apache.wicket.markup.html.form.validation.FormComponentFeedbackBorder;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;
import org.sample.web.models.SubComponentWrapModel;
import de.agilecoders.wicket.core.markup.html.bootstrap.form.InputBehavior;
import de.agilecoders.wicket.core.markup.html.bootstrap.form.InputBehavior.Size;
/**
*
*/
package org.sample.web.components;
/**
* @author mpostelnicu
*
*/
public abstract class GenericBootstrapFormComponent<TYPE, FIELD extends FormComponent<TYPE>> extends Panel {
private static final long serialVersionUID = 1L;
protected FormComponentFeedbackBorder border;
protected FIELD field;
protected InputBehavior sizeBehavior;
@SuppressWarnings("unchecked")
protected IModel<TYPE> initFieldModel() {
if (getDefaultModel() == null)
| return new SubComponentWrapModel<TYPE>(this);
|
mpostelnicu/wicket-spring-jpa-bootstrap-boilerplate | web/src/main/java/org/sample/web/components/providers/textchoice/AbstractJpaRepositoryTextChoiceProvider.java | // Path: web/src/main/java/org/sample/web/app/WebConstants.java
// public final class WebConstants {
// public static final int PAGE_SIZE=10;
// }
| import java.util.ArrayList;
import java.util.Collection;
import org.apache.wicket.model.IModel;
import org.sample.web.app.WebConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.AbstractPersistable;
import org.springframework.data.jpa.repository.JpaRepository;
import com.vaynberg.wicket.select2.Response;
import com.vaynberg.wicket.select2.TextChoiceProvider;
| package org.sample.web.components.providers.textchoice;
/**
* @author mpostelnicu
*
*/
public abstract class AbstractJpaRepositoryTextChoiceProvider<T extends AbstractPersistable<Long>>
extends TextChoiceProvider<T> {
private static final long serialVersionUID = 1L;
private static final Logger log = LoggerFactory.getLogger(AbstractJpaRepositoryTextChoiceProvider.class);
protected Sort sort;
@Override
public Object getId(T choice) {
return choice.getId();
}
protected IModel<Collection<T>> restrictedToItemsModel;
protected JpaRepository<T, Long> jpaRepository;
public AbstractJpaRepositoryTextChoiceProvider(JpaRepository<T, Long> jpaRepository) {
this.jpaRepository=jpaRepository;
}
public AbstractJpaRepositoryTextChoiceProvider(JpaRepository<T, Long> jpaRepository,IModel<Collection<T>> restrictedToItemsModel) {
this(jpaRepository);
this.restrictedToItemsModel=restrictedToItemsModel;
}
public JpaRepository<T, Long> getJpaRepository() {
return jpaRepository;
}
@Override
public void query(String term, int page, Response<T> response) {
| // Path: web/src/main/java/org/sample/web/app/WebConstants.java
// public final class WebConstants {
// public static final int PAGE_SIZE=10;
// }
// Path: web/src/main/java/org/sample/web/components/providers/textchoice/AbstractJpaRepositoryTextChoiceProvider.java
import java.util.ArrayList;
import java.util.Collection;
import org.apache.wicket.model.IModel;
import org.sample.web.app.WebConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.AbstractPersistable;
import org.springframework.data.jpa.repository.JpaRepository;
import com.vaynberg.wicket.select2.Response;
import com.vaynberg.wicket.select2.TextChoiceProvider;
package org.sample.web.components.providers.textchoice;
/**
* @author mpostelnicu
*
*/
public abstract class AbstractJpaRepositoryTextChoiceProvider<T extends AbstractPersistable<Long>>
extends TextChoiceProvider<T> {
private static final long serialVersionUID = 1L;
private static final Logger log = LoggerFactory.getLogger(AbstractJpaRepositoryTextChoiceProvider.class);
protected Sort sort;
@Override
public Object getId(T choice) {
return choice.getId();
}
protected IModel<Collection<T>> restrictedToItemsModel;
protected JpaRepository<T, Long> jpaRepository;
public AbstractJpaRepositoryTextChoiceProvider(JpaRepository<T, Long> jpaRepository) {
this.jpaRepository=jpaRepository;
}
public AbstractJpaRepositoryTextChoiceProvider(JpaRepository<T, Long> jpaRepository,IModel<Collection<T>> restrictedToItemsModel) {
this(jpaRepository);
this.restrictedToItemsModel=restrictedToItemsModel;
}
public JpaRepository<T, Long> getJpaRepository() {
return jpaRepository;
}
@Override
public void query(String term, int page, Response<T> response) {
| PageRequest pageRequest = new PageRequest(page, WebConstants.PAGE_SIZE,sort);
|
mpostelnicu/wicket-spring-jpa-bootstrap-boilerplate | persistence/src/main/java/org/sample/persistence/spring/PersistenceApplicationConfiguration.java | // Path: persistence/src/main/java/org/sample/persistence/repository/DummyRepository.java
// @Transactional
// public interface DummyRepository extends JpaRepository<Dummy, Long> {
//
// @Query("select c from Dummy c where c.name = ?1")
// List<Dummy> findByName(String name);
//
// }
| import java.util.Properties;
import javax.management.MBeanServer;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import net.sf.ehcache.CacheManager;
import net.sf.ehcache.management.ManagementService;
import org.apache.tomcat.jdbc.pool.DataSource;
import org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory;
import org.hibernate.dialect.DerbyTenSevenDialect;
import org.sample.persistence.repository.DummyRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.ehcache.EhCacheManagerFactoryBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
import org.springframework.context.annotation.Lazy;
import org.springframework.core.io.ClassPathResource;
import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.jmx.support.MBeanServerFactoryBean;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.JpaVendorAdapter;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
| /**
*
*/
package org.sample.persistence.spring;
/**
* @author mpostelnicu
*
*/
@Configuration
@Lazy
| // Path: persistence/src/main/java/org/sample/persistence/repository/DummyRepository.java
// @Transactional
// public interface DummyRepository extends JpaRepository<Dummy, Long> {
//
// @Query("select c from Dummy c where c.name = ?1")
// List<Dummy> findByName(String name);
//
// }
// Path: persistence/src/main/java/org/sample/persistence/spring/PersistenceApplicationConfiguration.java
import java.util.Properties;
import javax.management.MBeanServer;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import net.sf.ehcache.CacheManager;
import net.sf.ehcache.management.ManagementService;
import org.apache.tomcat.jdbc.pool.DataSource;
import org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory;
import org.hibernate.dialect.DerbyTenSevenDialect;
import org.sample.persistence.repository.DummyRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.ehcache.EhCacheManagerFactoryBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
import org.springframework.context.annotation.Lazy;
import org.springframework.core.io.ClassPathResource;
import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.jmx.support.MBeanServerFactoryBean;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.JpaVendorAdapter;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
/**
*
*/
package org.sample.persistence.spring;
/**
* @author mpostelnicu
*
*/
@Configuration
@Lazy
| @EnableJpaRepositories(basePackageClasses = DummyRepository.class)
|
mpostelnicu/wicket-spring-jpa-bootstrap-boilerplate | web/src/main/java/org/sample/web/components/providers/textchoice/SortableJpaRepositoryDataProvider.java | // Path: web/src/main/java/org/sample/web/app/WebConstants.java
// public final class WebConstants {
// public static final int PAGE_SIZE=10;
// }
//
// Path: web/src/main/java/org/sample/web/models/PersistableJpaRepositoryModel.java
// public class PersistableJpaRepositoryModel<T extends AbstractPersistable<Long>> extends LoadableDetachableModel<T> {
//
// private static final long serialVersionUID = 1L;
// private Long id;
// private JpaRepository<T, Long> jpaRepository;
//
// public PersistableJpaRepositoryModel(final Long id, final JpaRepository<T, Long> jpaRepository) {
// super();
// this.id = id;
// this.jpaRepository = jpaRepository;
// }
//
// public PersistableJpaRepositoryModel(final T t, final JpaRepository<T, Long> jpaRepository) {
// super(t);
// this.id = t.getId();
// this.jpaRepository = jpaRepository;
// }
//
// @Override
// protected T load() {
// return jpaRepository.findOne(id);
// }
//
//
// @Override
// public int hashCode()
// {
// return Long.valueOf(id).hashCode();
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public boolean equals(final Object obj)
// {
// if (obj == this)
// {
// return true;
// }
// else if (obj == null)
// {
// return false;
// }
// else if (obj instanceof PersistableJpaRepositoryModel)
// {
// PersistableJpaRepositoryModel<T> other = (PersistableJpaRepositoryModel<T>)obj;
// return other.id == id;
// }
// return false;
// }
// }
| import java.util.Iterator;
import org.apache.wicket.extensions.markup.html.repeater.util.SortParam;
import org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider;
import org.apache.wicket.model.IModel;
import org.apache.wicket.spring.injection.annot.SpringBean;
import org.sample.web.app.WebConstants;
import org.sample.web.models.PersistableJpaRepositoryModel;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.jpa.domain.AbstractPersistable;
import org.springframework.data.jpa.repository.JpaRepository;
| /**
*
*/
package org.sample.web.components.providers.textchoice;
/**
* @author mpostelnicu
*
* Smart generic {@link SortableDataProvider} that binds to {@link JpaRepository}
*/
public class SortableJpaRepositoryDataProvider<T extends AbstractPersistable<Long>>
extends SortableDataProvider<T, String> {
private static final long serialVersionUID = 1L;
protected JpaRepository<T, Long> jpaRepository;
/**
* Always provide a proxy jpaRepository here! For example one coming from a {@link SpringBean}
*
* @param jpaRepository
*/
public SortableJpaRepositoryDataProvider(
JpaRepository<T, Long> jpaRepository) {
this.jpaRepository = jpaRepository;
}
/**
* Translates from a {@link SortParam} to a Spring {@link Sort}
*
* @return
*/
protected Sort translateSort() {
if(getSort()==null) return null;
return new Sort(getSort().isAscending() ? Direction.ASC
: Direction.DESC, getSort().getProperty());
}
/**
* @see SortableDataProvider#iterator(long, long)
*/
@Override
public Iterator<? extends T> iterator(long first, long count) {
| // Path: web/src/main/java/org/sample/web/app/WebConstants.java
// public final class WebConstants {
// public static final int PAGE_SIZE=10;
// }
//
// Path: web/src/main/java/org/sample/web/models/PersistableJpaRepositoryModel.java
// public class PersistableJpaRepositoryModel<T extends AbstractPersistable<Long>> extends LoadableDetachableModel<T> {
//
// private static final long serialVersionUID = 1L;
// private Long id;
// private JpaRepository<T, Long> jpaRepository;
//
// public PersistableJpaRepositoryModel(final Long id, final JpaRepository<T, Long> jpaRepository) {
// super();
// this.id = id;
// this.jpaRepository = jpaRepository;
// }
//
// public PersistableJpaRepositoryModel(final T t, final JpaRepository<T, Long> jpaRepository) {
// super(t);
// this.id = t.getId();
// this.jpaRepository = jpaRepository;
// }
//
// @Override
// protected T load() {
// return jpaRepository.findOne(id);
// }
//
//
// @Override
// public int hashCode()
// {
// return Long.valueOf(id).hashCode();
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public boolean equals(final Object obj)
// {
// if (obj == this)
// {
// return true;
// }
// else if (obj == null)
// {
// return false;
// }
// else if (obj instanceof PersistableJpaRepositoryModel)
// {
// PersistableJpaRepositoryModel<T> other = (PersistableJpaRepositoryModel<T>)obj;
// return other.id == id;
// }
// return false;
// }
// }
// Path: web/src/main/java/org/sample/web/components/providers/textchoice/SortableJpaRepositoryDataProvider.java
import java.util.Iterator;
import org.apache.wicket.extensions.markup.html.repeater.util.SortParam;
import org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider;
import org.apache.wicket.model.IModel;
import org.apache.wicket.spring.injection.annot.SpringBean;
import org.sample.web.app.WebConstants;
import org.sample.web.models.PersistableJpaRepositoryModel;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.jpa.domain.AbstractPersistable;
import org.springframework.data.jpa.repository.JpaRepository;
/**
*
*/
package org.sample.web.components.providers.textchoice;
/**
* @author mpostelnicu
*
* Smart generic {@link SortableDataProvider} that binds to {@link JpaRepository}
*/
public class SortableJpaRepositoryDataProvider<T extends AbstractPersistable<Long>>
extends SortableDataProvider<T, String> {
private static final long serialVersionUID = 1L;
protected JpaRepository<T, Long> jpaRepository;
/**
* Always provide a proxy jpaRepository here! For example one coming from a {@link SpringBean}
*
* @param jpaRepository
*/
public SortableJpaRepositoryDataProvider(
JpaRepository<T, Long> jpaRepository) {
this.jpaRepository = jpaRepository;
}
/**
* Translates from a {@link SortParam} to a Spring {@link Sort}
*
* @return
*/
protected Sort translateSort() {
if(getSort()==null) return null;
return new Sort(getSort().isAscending() ? Direction.ASC
: Direction.DESC, getSort().getProperty());
}
/**
* @see SortableDataProvider#iterator(long, long)
*/
@Override
public Iterator<? extends T> iterator(long first, long count) {
| int page = (int)((double) first / WebConstants.PAGE_SIZE);
|
mpostelnicu/wicket-spring-jpa-bootstrap-boilerplate | web/src/main/java/org/sample/web/components/providers/textchoice/SortableJpaRepositoryDataProvider.java | // Path: web/src/main/java/org/sample/web/app/WebConstants.java
// public final class WebConstants {
// public static final int PAGE_SIZE=10;
// }
//
// Path: web/src/main/java/org/sample/web/models/PersistableJpaRepositoryModel.java
// public class PersistableJpaRepositoryModel<T extends AbstractPersistable<Long>> extends LoadableDetachableModel<T> {
//
// private static final long serialVersionUID = 1L;
// private Long id;
// private JpaRepository<T, Long> jpaRepository;
//
// public PersistableJpaRepositoryModel(final Long id, final JpaRepository<T, Long> jpaRepository) {
// super();
// this.id = id;
// this.jpaRepository = jpaRepository;
// }
//
// public PersistableJpaRepositoryModel(final T t, final JpaRepository<T, Long> jpaRepository) {
// super(t);
// this.id = t.getId();
// this.jpaRepository = jpaRepository;
// }
//
// @Override
// protected T load() {
// return jpaRepository.findOne(id);
// }
//
//
// @Override
// public int hashCode()
// {
// return Long.valueOf(id).hashCode();
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public boolean equals(final Object obj)
// {
// if (obj == this)
// {
// return true;
// }
// else if (obj == null)
// {
// return false;
// }
// else if (obj instanceof PersistableJpaRepositoryModel)
// {
// PersistableJpaRepositoryModel<T> other = (PersistableJpaRepositoryModel<T>)obj;
// return other.id == id;
// }
// return false;
// }
// }
| import java.util.Iterator;
import org.apache.wicket.extensions.markup.html.repeater.util.SortParam;
import org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider;
import org.apache.wicket.model.IModel;
import org.apache.wicket.spring.injection.annot.SpringBean;
import org.sample.web.app.WebConstants;
import org.sample.web.models.PersistableJpaRepositoryModel;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.jpa.domain.AbstractPersistable;
import org.springframework.data.jpa.repository.JpaRepository;
| /**
*
*/
package org.sample.web.components.providers.textchoice;
/**
* @author mpostelnicu
*
* Smart generic {@link SortableDataProvider} that binds to {@link JpaRepository}
*/
public class SortableJpaRepositoryDataProvider<T extends AbstractPersistable<Long>>
extends SortableDataProvider<T, String> {
private static final long serialVersionUID = 1L;
protected JpaRepository<T, Long> jpaRepository;
/**
* Always provide a proxy jpaRepository here! For example one coming from a {@link SpringBean}
*
* @param jpaRepository
*/
public SortableJpaRepositoryDataProvider(
JpaRepository<T, Long> jpaRepository) {
this.jpaRepository = jpaRepository;
}
/**
* Translates from a {@link SortParam} to a Spring {@link Sort}
*
* @return
*/
protected Sort translateSort() {
if(getSort()==null) return null;
return new Sort(getSort().isAscending() ? Direction.ASC
: Direction.DESC, getSort().getProperty());
}
/**
* @see SortableDataProvider#iterator(long, long)
*/
@Override
public Iterator<? extends T> iterator(long first, long count) {
int page = (int)((double) first / WebConstants.PAGE_SIZE);
Page<T> findAll = jpaRepository.findAll(
new PageRequest((int) page, WebConstants.PAGE_SIZE, translateSort()));
return findAll.iterator();
}
@Override
public long size() {
return jpaRepository.count();
}
/**
* This ensures that the object is detached and reloaded after
* deserialization of the page, since the
* {@link PersistableJpaRepositoryModel} is also loadabledetachable
*/
@Override
public IModel<T> model(T object) {
| // Path: web/src/main/java/org/sample/web/app/WebConstants.java
// public final class WebConstants {
// public static final int PAGE_SIZE=10;
// }
//
// Path: web/src/main/java/org/sample/web/models/PersistableJpaRepositoryModel.java
// public class PersistableJpaRepositoryModel<T extends AbstractPersistable<Long>> extends LoadableDetachableModel<T> {
//
// private static final long serialVersionUID = 1L;
// private Long id;
// private JpaRepository<T, Long> jpaRepository;
//
// public PersistableJpaRepositoryModel(final Long id, final JpaRepository<T, Long> jpaRepository) {
// super();
// this.id = id;
// this.jpaRepository = jpaRepository;
// }
//
// public PersistableJpaRepositoryModel(final T t, final JpaRepository<T, Long> jpaRepository) {
// super(t);
// this.id = t.getId();
// this.jpaRepository = jpaRepository;
// }
//
// @Override
// protected T load() {
// return jpaRepository.findOne(id);
// }
//
//
// @Override
// public int hashCode()
// {
// return Long.valueOf(id).hashCode();
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public boolean equals(final Object obj)
// {
// if (obj == this)
// {
// return true;
// }
// else if (obj == null)
// {
// return false;
// }
// else if (obj instanceof PersistableJpaRepositoryModel)
// {
// PersistableJpaRepositoryModel<T> other = (PersistableJpaRepositoryModel<T>)obj;
// return other.id == id;
// }
// return false;
// }
// }
// Path: web/src/main/java/org/sample/web/components/providers/textchoice/SortableJpaRepositoryDataProvider.java
import java.util.Iterator;
import org.apache.wicket.extensions.markup.html.repeater.util.SortParam;
import org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider;
import org.apache.wicket.model.IModel;
import org.apache.wicket.spring.injection.annot.SpringBean;
import org.sample.web.app.WebConstants;
import org.sample.web.models.PersistableJpaRepositoryModel;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.jpa.domain.AbstractPersistable;
import org.springframework.data.jpa.repository.JpaRepository;
/**
*
*/
package org.sample.web.components.providers.textchoice;
/**
* @author mpostelnicu
*
* Smart generic {@link SortableDataProvider} that binds to {@link JpaRepository}
*/
public class SortableJpaRepositoryDataProvider<T extends AbstractPersistable<Long>>
extends SortableDataProvider<T, String> {
private static final long serialVersionUID = 1L;
protected JpaRepository<T, Long> jpaRepository;
/**
* Always provide a proxy jpaRepository here! For example one coming from a {@link SpringBean}
*
* @param jpaRepository
*/
public SortableJpaRepositoryDataProvider(
JpaRepository<T, Long> jpaRepository) {
this.jpaRepository = jpaRepository;
}
/**
* Translates from a {@link SortParam} to a Spring {@link Sort}
*
* @return
*/
protected Sort translateSort() {
if(getSort()==null) return null;
return new Sort(getSort().isAscending() ? Direction.ASC
: Direction.DESC, getSort().getProperty());
}
/**
* @see SortableDataProvider#iterator(long, long)
*/
@Override
public Iterator<? extends T> iterator(long first, long count) {
int page = (int)((double) first / WebConstants.PAGE_SIZE);
Page<T> findAll = jpaRepository.findAll(
new PageRequest((int) page, WebConstants.PAGE_SIZE, translateSort()));
return findAll.iterator();
}
@Override
public long size() {
return jpaRepository.count();
}
/**
* This ensures that the object is detached and reloaded after
* deserialization of the page, since the
* {@link PersistableJpaRepositoryModel} is also loadabledetachable
*/
@Override
public IModel<T> model(T object) {
| return new PersistableJpaRepositoryModel<T>(object, jpaRepository);
|
mpostelnicu/wicket-spring-jpa-bootstrap-boilerplate | web/src/main/java/org/sample/web/pages/edits/EditCategoryDummyPage.java | // Path: persistence/src/main/java/org/sample/persistence/dao/CategoryDummy.java
// @Entity
// public class CategoryDummy extends AbstractPersistable<Long> {
//
// /**
// *
// */
// private static final long serialVersionUID = 1L;
// private String name;
//
// @OneToMany(mappedBy = "category", fetch = FetchType.LAZY)
// private Set<Dummy> dummy = new HashSet<Dummy>();
//
// /**
// * @return the name
// */
// public String getName() {
// return name;
// }
//
// /**
// * @return the dummy
// */
// public Set<Dummy> getDummy() {
// return dummy;
// }
//
// /**
// * @param dummy the dummy to set
// */
// public void setDummy(Set<Dummy> dummy) {
// this.dummy = dummy;
// }
//
// /**
// * @param name
// * the name to set
// */
// public void setName(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
// }
//
// Path: persistence/src/main/java/org/sample/persistence/repository/CategoryDummyRepository.java
// @Transactional
// public interface CategoryDummyRepository extends JpaRepository<CategoryDummy, Long> {
//
// @Query("select c from CategoryDummy c where c.name = ?1")
// List<CategoryDummy> findByName(String name);
//
// }
//
// Path: web/src/main/java/org/sample/web/components/TextFieldBootstrapFormComponent.java
// public class TextFieldBootstrapFormComponent<TYPE> extends GenericBootstrapFormComponent<TYPE, TextField<TYPE>> {
// private static final long serialVersionUID = 1L;
//
// public TextFieldBootstrapFormComponent(String id, IModel<String> labelModel, IModel<TYPE> model) {
// super(id, labelModel, model);
// }
//
// public TextFieldBootstrapFormComponent(String id, IModel<String> labelModel) {
// super(id, labelModel, null);
// }
//
// @Override
// protected TextField<TYPE> inputField(String id, IModel<TYPE> model) {
// return (TextField<TYPE>) new TextField<TYPE>(id,initFieldModel());
// }
//
// public TextFieldBootstrapFormComponent<TYPE> integer() {
// field.setType(Integer.class);
// return this;
// }
//
// public TextFieldBootstrapFormComponent<TYPE> decimal() {
// field.setType(BigDecimal.class);
// return this;
// }
// }
//
// Path: web/src/main/java/org/sample/web/pages/lists/ListCategoryDummyPage.java
// public class ListCategoryDummyPage extends AbstractListPage<CategoryDummy> {
//
// private static final long serialVersionUID = 1L;
//
// @SpringBean
// protected CategoryDummyRepository categoryDummyRepository;
//
// public ListCategoryDummyPage(PageParameters pageParameters) {
//
// this.jpaRepository=categoryDummyRepository;
// this.editPageClass=EditCategoryDummyPage.class;
// columns.add(new PropertyColumn<CategoryDummy,String>(new Model<String>("Name"), "name", "name"));
// }
//
//
// }
| import org.apache.wicket.model.Model;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.spring.injection.annot.SpringBean;
import org.sample.persistence.dao.CategoryDummy;
import org.sample.persistence.repository.CategoryDummyRepository;
import org.sample.web.components.TextFieldBootstrapFormComponent;
import org.sample.web.pages.lists.ListCategoryDummyPage;
| /**
*
*/
package org.sample.web.pages.edits;
/**
* @author mpostelnicu
*
*/
public class EditCategoryDummyPage extends AbstractEditPage<CategoryDummy> {
private static final long serialVersionUID = 1L;
/* (non-Javadoc)
* @see org.devgateway.ccrs.web.wicket.page.AbstractEditPage#newInstance()
*/
@Override
protected CategoryDummy newInstance() {
return new CategoryDummy();
}
@SpringBean
| // Path: persistence/src/main/java/org/sample/persistence/dao/CategoryDummy.java
// @Entity
// public class CategoryDummy extends AbstractPersistable<Long> {
//
// /**
// *
// */
// private static final long serialVersionUID = 1L;
// private String name;
//
// @OneToMany(mappedBy = "category", fetch = FetchType.LAZY)
// private Set<Dummy> dummy = new HashSet<Dummy>();
//
// /**
// * @return the name
// */
// public String getName() {
// return name;
// }
//
// /**
// * @return the dummy
// */
// public Set<Dummy> getDummy() {
// return dummy;
// }
//
// /**
// * @param dummy the dummy to set
// */
// public void setDummy(Set<Dummy> dummy) {
// this.dummy = dummy;
// }
//
// /**
// * @param name
// * the name to set
// */
// public void setName(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
// }
//
// Path: persistence/src/main/java/org/sample/persistence/repository/CategoryDummyRepository.java
// @Transactional
// public interface CategoryDummyRepository extends JpaRepository<CategoryDummy, Long> {
//
// @Query("select c from CategoryDummy c where c.name = ?1")
// List<CategoryDummy> findByName(String name);
//
// }
//
// Path: web/src/main/java/org/sample/web/components/TextFieldBootstrapFormComponent.java
// public class TextFieldBootstrapFormComponent<TYPE> extends GenericBootstrapFormComponent<TYPE, TextField<TYPE>> {
// private static final long serialVersionUID = 1L;
//
// public TextFieldBootstrapFormComponent(String id, IModel<String> labelModel, IModel<TYPE> model) {
// super(id, labelModel, model);
// }
//
// public TextFieldBootstrapFormComponent(String id, IModel<String> labelModel) {
// super(id, labelModel, null);
// }
//
// @Override
// protected TextField<TYPE> inputField(String id, IModel<TYPE> model) {
// return (TextField<TYPE>) new TextField<TYPE>(id,initFieldModel());
// }
//
// public TextFieldBootstrapFormComponent<TYPE> integer() {
// field.setType(Integer.class);
// return this;
// }
//
// public TextFieldBootstrapFormComponent<TYPE> decimal() {
// field.setType(BigDecimal.class);
// return this;
// }
// }
//
// Path: web/src/main/java/org/sample/web/pages/lists/ListCategoryDummyPage.java
// public class ListCategoryDummyPage extends AbstractListPage<CategoryDummy> {
//
// private static final long serialVersionUID = 1L;
//
// @SpringBean
// protected CategoryDummyRepository categoryDummyRepository;
//
// public ListCategoryDummyPage(PageParameters pageParameters) {
//
// this.jpaRepository=categoryDummyRepository;
// this.editPageClass=EditCategoryDummyPage.class;
// columns.add(new PropertyColumn<CategoryDummy,String>(new Model<String>("Name"), "name", "name"));
// }
//
//
// }
// Path: web/src/main/java/org/sample/web/pages/edits/EditCategoryDummyPage.java
import org.apache.wicket.model.Model;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.spring.injection.annot.SpringBean;
import org.sample.persistence.dao.CategoryDummy;
import org.sample.persistence.repository.CategoryDummyRepository;
import org.sample.web.components.TextFieldBootstrapFormComponent;
import org.sample.web.pages.lists.ListCategoryDummyPage;
/**
*
*/
package org.sample.web.pages.edits;
/**
* @author mpostelnicu
*
*/
public class EditCategoryDummyPage extends AbstractEditPage<CategoryDummy> {
private static final long serialVersionUID = 1L;
/* (non-Javadoc)
* @see org.devgateway.ccrs.web.wicket.page.AbstractEditPage#newInstance()
*/
@Override
protected CategoryDummy newInstance() {
return new CategoryDummy();
}
@SpringBean
| private CategoryDummyRepository categoryDummyRepository;
|
mpostelnicu/wicket-spring-jpa-bootstrap-boilerplate | web/src/main/java/org/sample/web/pages/edits/EditCategoryDummyPage.java | // Path: persistence/src/main/java/org/sample/persistence/dao/CategoryDummy.java
// @Entity
// public class CategoryDummy extends AbstractPersistable<Long> {
//
// /**
// *
// */
// private static final long serialVersionUID = 1L;
// private String name;
//
// @OneToMany(mappedBy = "category", fetch = FetchType.LAZY)
// private Set<Dummy> dummy = new HashSet<Dummy>();
//
// /**
// * @return the name
// */
// public String getName() {
// return name;
// }
//
// /**
// * @return the dummy
// */
// public Set<Dummy> getDummy() {
// return dummy;
// }
//
// /**
// * @param dummy the dummy to set
// */
// public void setDummy(Set<Dummy> dummy) {
// this.dummy = dummy;
// }
//
// /**
// * @param name
// * the name to set
// */
// public void setName(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
// }
//
// Path: persistence/src/main/java/org/sample/persistence/repository/CategoryDummyRepository.java
// @Transactional
// public interface CategoryDummyRepository extends JpaRepository<CategoryDummy, Long> {
//
// @Query("select c from CategoryDummy c where c.name = ?1")
// List<CategoryDummy> findByName(String name);
//
// }
//
// Path: web/src/main/java/org/sample/web/components/TextFieldBootstrapFormComponent.java
// public class TextFieldBootstrapFormComponent<TYPE> extends GenericBootstrapFormComponent<TYPE, TextField<TYPE>> {
// private static final long serialVersionUID = 1L;
//
// public TextFieldBootstrapFormComponent(String id, IModel<String> labelModel, IModel<TYPE> model) {
// super(id, labelModel, model);
// }
//
// public TextFieldBootstrapFormComponent(String id, IModel<String> labelModel) {
// super(id, labelModel, null);
// }
//
// @Override
// protected TextField<TYPE> inputField(String id, IModel<TYPE> model) {
// return (TextField<TYPE>) new TextField<TYPE>(id,initFieldModel());
// }
//
// public TextFieldBootstrapFormComponent<TYPE> integer() {
// field.setType(Integer.class);
// return this;
// }
//
// public TextFieldBootstrapFormComponent<TYPE> decimal() {
// field.setType(BigDecimal.class);
// return this;
// }
// }
//
// Path: web/src/main/java/org/sample/web/pages/lists/ListCategoryDummyPage.java
// public class ListCategoryDummyPage extends AbstractListPage<CategoryDummy> {
//
// private static final long serialVersionUID = 1L;
//
// @SpringBean
// protected CategoryDummyRepository categoryDummyRepository;
//
// public ListCategoryDummyPage(PageParameters pageParameters) {
//
// this.jpaRepository=categoryDummyRepository;
// this.editPageClass=EditCategoryDummyPage.class;
// columns.add(new PropertyColumn<CategoryDummy,String>(new Model<String>("Name"), "name", "name"));
// }
//
//
// }
| import org.apache.wicket.model.Model;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.spring.injection.annot.SpringBean;
import org.sample.persistence.dao.CategoryDummy;
import org.sample.persistence.repository.CategoryDummyRepository;
import org.sample.web.components.TextFieldBootstrapFormComponent;
import org.sample.web.pages.lists.ListCategoryDummyPage;
| /**
*
*/
package org.sample.web.pages.edits;
/**
* @author mpostelnicu
*
*/
public class EditCategoryDummyPage extends AbstractEditPage<CategoryDummy> {
private static final long serialVersionUID = 1L;
/* (non-Javadoc)
* @see org.devgateway.ccrs.web.wicket.page.AbstractEditPage#newInstance()
*/
@Override
protected CategoryDummy newInstance() {
return new CategoryDummy();
}
@SpringBean
private CategoryDummyRepository categoryDummyRepository;
public EditCategoryDummyPage(PageParameters parameters) {
super(parameters);
this.jpaRepository = categoryDummyRepository;
| // Path: persistence/src/main/java/org/sample/persistence/dao/CategoryDummy.java
// @Entity
// public class CategoryDummy extends AbstractPersistable<Long> {
//
// /**
// *
// */
// private static final long serialVersionUID = 1L;
// private String name;
//
// @OneToMany(mappedBy = "category", fetch = FetchType.LAZY)
// private Set<Dummy> dummy = new HashSet<Dummy>();
//
// /**
// * @return the name
// */
// public String getName() {
// return name;
// }
//
// /**
// * @return the dummy
// */
// public Set<Dummy> getDummy() {
// return dummy;
// }
//
// /**
// * @param dummy the dummy to set
// */
// public void setDummy(Set<Dummy> dummy) {
// this.dummy = dummy;
// }
//
// /**
// * @param name
// * the name to set
// */
// public void setName(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
// }
//
// Path: persistence/src/main/java/org/sample/persistence/repository/CategoryDummyRepository.java
// @Transactional
// public interface CategoryDummyRepository extends JpaRepository<CategoryDummy, Long> {
//
// @Query("select c from CategoryDummy c where c.name = ?1")
// List<CategoryDummy> findByName(String name);
//
// }
//
// Path: web/src/main/java/org/sample/web/components/TextFieldBootstrapFormComponent.java
// public class TextFieldBootstrapFormComponent<TYPE> extends GenericBootstrapFormComponent<TYPE, TextField<TYPE>> {
// private static final long serialVersionUID = 1L;
//
// public TextFieldBootstrapFormComponent(String id, IModel<String> labelModel, IModel<TYPE> model) {
// super(id, labelModel, model);
// }
//
// public TextFieldBootstrapFormComponent(String id, IModel<String> labelModel) {
// super(id, labelModel, null);
// }
//
// @Override
// protected TextField<TYPE> inputField(String id, IModel<TYPE> model) {
// return (TextField<TYPE>) new TextField<TYPE>(id,initFieldModel());
// }
//
// public TextFieldBootstrapFormComponent<TYPE> integer() {
// field.setType(Integer.class);
// return this;
// }
//
// public TextFieldBootstrapFormComponent<TYPE> decimal() {
// field.setType(BigDecimal.class);
// return this;
// }
// }
//
// Path: web/src/main/java/org/sample/web/pages/lists/ListCategoryDummyPage.java
// public class ListCategoryDummyPage extends AbstractListPage<CategoryDummy> {
//
// private static final long serialVersionUID = 1L;
//
// @SpringBean
// protected CategoryDummyRepository categoryDummyRepository;
//
// public ListCategoryDummyPage(PageParameters pageParameters) {
//
// this.jpaRepository=categoryDummyRepository;
// this.editPageClass=EditCategoryDummyPage.class;
// columns.add(new PropertyColumn<CategoryDummy,String>(new Model<String>("Name"), "name", "name"));
// }
//
//
// }
// Path: web/src/main/java/org/sample/web/pages/edits/EditCategoryDummyPage.java
import org.apache.wicket.model.Model;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.spring.injection.annot.SpringBean;
import org.sample.persistence.dao.CategoryDummy;
import org.sample.persistence.repository.CategoryDummyRepository;
import org.sample.web.components.TextFieldBootstrapFormComponent;
import org.sample.web.pages.lists.ListCategoryDummyPage;
/**
*
*/
package org.sample.web.pages.edits;
/**
* @author mpostelnicu
*
*/
public class EditCategoryDummyPage extends AbstractEditPage<CategoryDummy> {
private static final long serialVersionUID = 1L;
/* (non-Javadoc)
* @see org.devgateway.ccrs.web.wicket.page.AbstractEditPage#newInstance()
*/
@Override
protected CategoryDummy newInstance() {
return new CategoryDummy();
}
@SpringBean
private CategoryDummyRepository categoryDummyRepository;
public EditCategoryDummyPage(PageParameters parameters) {
super(parameters);
this.jpaRepository = categoryDummyRepository;
| this.listPageClass = ListCategoryDummyPage.class;
|
mpostelnicu/wicket-spring-jpa-bootstrap-boilerplate | web/src/main/java/org/sample/web/pages/edits/EditCategoryDummyPage.java | // Path: persistence/src/main/java/org/sample/persistence/dao/CategoryDummy.java
// @Entity
// public class CategoryDummy extends AbstractPersistable<Long> {
//
// /**
// *
// */
// private static final long serialVersionUID = 1L;
// private String name;
//
// @OneToMany(mappedBy = "category", fetch = FetchType.LAZY)
// private Set<Dummy> dummy = new HashSet<Dummy>();
//
// /**
// * @return the name
// */
// public String getName() {
// return name;
// }
//
// /**
// * @return the dummy
// */
// public Set<Dummy> getDummy() {
// return dummy;
// }
//
// /**
// * @param dummy the dummy to set
// */
// public void setDummy(Set<Dummy> dummy) {
// this.dummy = dummy;
// }
//
// /**
// * @param name
// * the name to set
// */
// public void setName(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
// }
//
// Path: persistence/src/main/java/org/sample/persistence/repository/CategoryDummyRepository.java
// @Transactional
// public interface CategoryDummyRepository extends JpaRepository<CategoryDummy, Long> {
//
// @Query("select c from CategoryDummy c where c.name = ?1")
// List<CategoryDummy> findByName(String name);
//
// }
//
// Path: web/src/main/java/org/sample/web/components/TextFieldBootstrapFormComponent.java
// public class TextFieldBootstrapFormComponent<TYPE> extends GenericBootstrapFormComponent<TYPE, TextField<TYPE>> {
// private static final long serialVersionUID = 1L;
//
// public TextFieldBootstrapFormComponent(String id, IModel<String> labelModel, IModel<TYPE> model) {
// super(id, labelModel, model);
// }
//
// public TextFieldBootstrapFormComponent(String id, IModel<String> labelModel) {
// super(id, labelModel, null);
// }
//
// @Override
// protected TextField<TYPE> inputField(String id, IModel<TYPE> model) {
// return (TextField<TYPE>) new TextField<TYPE>(id,initFieldModel());
// }
//
// public TextFieldBootstrapFormComponent<TYPE> integer() {
// field.setType(Integer.class);
// return this;
// }
//
// public TextFieldBootstrapFormComponent<TYPE> decimal() {
// field.setType(BigDecimal.class);
// return this;
// }
// }
//
// Path: web/src/main/java/org/sample/web/pages/lists/ListCategoryDummyPage.java
// public class ListCategoryDummyPage extends AbstractListPage<CategoryDummy> {
//
// private static final long serialVersionUID = 1L;
//
// @SpringBean
// protected CategoryDummyRepository categoryDummyRepository;
//
// public ListCategoryDummyPage(PageParameters pageParameters) {
//
// this.jpaRepository=categoryDummyRepository;
// this.editPageClass=EditCategoryDummyPage.class;
// columns.add(new PropertyColumn<CategoryDummy,String>(new Model<String>("Name"), "name", "name"));
// }
//
//
// }
| import org.apache.wicket.model.Model;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.spring.injection.annot.SpringBean;
import org.sample.persistence.dao.CategoryDummy;
import org.sample.persistence.repository.CategoryDummyRepository;
import org.sample.web.components.TextFieldBootstrapFormComponent;
import org.sample.web.pages.lists.ListCategoryDummyPage;
| /**
*
*/
package org.sample.web.pages.edits;
/**
* @author mpostelnicu
*
*/
public class EditCategoryDummyPage extends AbstractEditPage<CategoryDummy> {
private static final long serialVersionUID = 1L;
/* (non-Javadoc)
* @see org.devgateway.ccrs.web.wicket.page.AbstractEditPage#newInstance()
*/
@Override
protected CategoryDummy newInstance() {
return new CategoryDummy();
}
@SpringBean
private CategoryDummyRepository categoryDummyRepository;
public EditCategoryDummyPage(PageParameters parameters) {
super(parameters);
this.jpaRepository = categoryDummyRepository;
this.listPageClass = ListCategoryDummyPage.class;
| // Path: persistence/src/main/java/org/sample/persistence/dao/CategoryDummy.java
// @Entity
// public class CategoryDummy extends AbstractPersistable<Long> {
//
// /**
// *
// */
// private static final long serialVersionUID = 1L;
// private String name;
//
// @OneToMany(mappedBy = "category", fetch = FetchType.LAZY)
// private Set<Dummy> dummy = new HashSet<Dummy>();
//
// /**
// * @return the name
// */
// public String getName() {
// return name;
// }
//
// /**
// * @return the dummy
// */
// public Set<Dummy> getDummy() {
// return dummy;
// }
//
// /**
// * @param dummy the dummy to set
// */
// public void setDummy(Set<Dummy> dummy) {
// this.dummy = dummy;
// }
//
// /**
// * @param name
// * the name to set
// */
// public void setName(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
// }
//
// Path: persistence/src/main/java/org/sample/persistence/repository/CategoryDummyRepository.java
// @Transactional
// public interface CategoryDummyRepository extends JpaRepository<CategoryDummy, Long> {
//
// @Query("select c from CategoryDummy c where c.name = ?1")
// List<CategoryDummy> findByName(String name);
//
// }
//
// Path: web/src/main/java/org/sample/web/components/TextFieldBootstrapFormComponent.java
// public class TextFieldBootstrapFormComponent<TYPE> extends GenericBootstrapFormComponent<TYPE, TextField<TYPE>> {
// private static final long serialVersionUID = 1L;
//
// public TextFieldBootstrapFormComponent(String id, IModel<String> labelModel, IModel<TYPE> model) {
// super(id, labelModel, model);
// }
//
// public TextFieldBootstrapFormComponent(String id, IModel<String> labelModel) {
// super(id, labelModel, null);
// }
//
// @Override
// protected TextField<TYPE> inputField(String id, IModel<TYPE> model) {
// return (TextField<TYPE>) new TextField<TYPE>(id,initFieldModel());
// }
//
// public TextFieldBootstrapFormComponent<TYPE> integer() {
// field.setType(Integer.class);
// return this;
// }
//
// public TextFieldBootstrapFormComponent<TYPE> decimal() {
// field.setType(BigDecimal.class);
// return this;
// }
// }
//
// Path: web/src/main/java/org/sample/web/pages/lists/ListCategoryDummyPage.java
// public class ListCategoryDummyPage extends AbstractListPage<CategoryDummy> {
//
// private static final long serialVersionUID = 1L;
//
// @SpringBean
// protected CategoryDummyRepository categoryDummyRepository;
//
// public ListCategoryDummyPage(PageParameters pageParameters) {
//
// this.jpaRepository=categoryDummyRepository;
// this.editPageClass=EditCategoryDummyPage.class;
// columns.add(new PropertyColumn<CategoryDummy,String>(new Model<String>("Name"), "name", "name"));
// }
//
//
// }
// Path: web/src/main/java/org/sample/web/pages/edits/EditCategoryDummyPage.java
import org.apache.wicket.model.Model;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.spring.injection.annot.SpringBean;
import org.sample.persistence.dao.CategoryDummy;
import org.sample.persistence.repository.CategoryDummyRepository;
import org.sample.web.components.TextFieldBootstrapFormComponent;
import org.sample.web.pages.lists.ListCategoryDummyPage;
/**
*
*/
package org.sample.web.pages.edits;
/**
* @author mpostelnicu
*
*/
public class EditCategoryDummyPage extends AbstractEditPage<CategoryDummy> {
private static final long serialVersionUID = 1L;
/* (non-Javadoc)
* @see org.devgateway.ccrs.web.wicket.page.AbstractEditPage#newInstance()
*/
@Override
protected CategoryDummy newInstance() {
return new CategoryDummy();
}
@SpringBean
private CategoryDummyRepository categoryDummyRepository;
public EditCategoryDummyPage(PageParameters parameters) {
super(parameters);
this.jpaRepository = categoryDummyRepository;
this.listPageClass = ListCategoryDummyPage.class;
| editForm.add(new TextFieldBootstrapFormComponent<>("name", new Model<>("Name")).required());
|
runsoftdev/bVnc | bVNC/src/com/iiordanov/runsoft/bVNC/Decoder.java | // Path: bVNC/src/com/iiordanov/runsoft/bVNC/input/RemotePointer.java
// public abstract class RemotePointer {
//
// /**
// * Current and previous state of "mouse" buttons
// */
// protected int pointerMask = 0;
// protected int prevPointerMask = 0;
//
// protected RemoteCanvas vncCanvas;
// protected Context context;
// protected Handler handler;
// protected RfbConnectable rfb;
//
// /**
// * Indicates where the mouse pointer is located.
// */
// public int mouseX, mouseY;
//
// public RemotePointer (RfbConnectable r, RemoteCanvas v, Handler h) {
// rfb = r;
// mouseX=rfb.framebufferWidth()/2;
// mouseY=rfb.framebufferHeight()/2;
// vncCanvas = v;
// handler = h;
// context = v.getContext();
// }
//
// protected boolean shouldBeRightClick (KeyEvent e) {
// boolean result = false;
// int keyCode = e.getKeyCode();
//
// // If the camera button is pressed
// if (keyCode == KeyEvent.KEYCODE_CAMERA) {
// result = true;
// // Or the back button is pressed
// } else if (keyCode == KeyEvent.KEYCODE_BACK) {
// // Determine SDK
// boolean preGingerBread = android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD;
// // Whether the source is a mouse (getSource() is not available pre-Gingerbread)
// boolean mouseSource = (!preGingerBread && e.getSource() == InputDevice.SOURCE_MOUSE);
// // Whether the device has a qwerty keyboard
// boolean noQwertyKbd = (context.getResources().getConfiguration().keyboard != Configuration.KEYBOARD_QWERTY);
// // Whether the device is pre-Gingerbread or the event came from the "hard buttons"
// boolean fromVirtualHardKey = preGingerBread || (e.getFlags() & KeyEvent.FLAG_VIRTUAL_HARD_KEY) != 0;
// if (mouseSource || noQwertyKbd || fromVirtualHardKey) {
// result = true;
// }
// }
//
// return result;
// }
//
// abstract public int getX();
// abstract public int getY();
// abstract public void setX(int newX);
// abstract public void setY(int newY);
// abstract public void warpMouse(int x, int y);
// abstract public void mouseFollowPan();
// abstract boolean handleHardwareButtons(int keyCode, KeyEvent evt, int combinedMetastate);
// abstract public boolean processPointerEvent(MotionEvent evt, boolean downEvent,
// boolean useRightButton, boolean useMiddleButton, boolean useScrollButton, int direction);
// abstract public boolean processPointerEvent(MotionEvent evt, boolean downEvent,
// boolean useRightButton, boolean useMiddleButton);
// abstract public boolean processPointerEvent(MotionEvent evt, boolean downEvent, boolean useRightButton);
// abstract public boolean processPointerEvent(int x, int y, int action, int modifiers, boolean mouseIsDown, boolean useRightButton);
//
// abstract public boolean processPointerEvent(int x, int y, int action, int modifiers, boolean mouseIsDown, boolean useRightButton,
// boolean useMiddleButton, boolean useScrollButton, int direction);
// }
| import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.RectF;
import android.util.Log;
import java.io.IOException;
import java.util.zip.DataFormatException;
import java.util.zip.Inflater;
import com.iiordanov.runsoft.bVNC.input.RemotePointer; | }
pixels[offset++] = (pix[0] & 0xFF) << 16 | (pix[1] & 0xFF) << 8 | (pix[2] & 0xFF);
/* Remaining pixels of a row */
for (dx = 1; dx < w; dx++) {
for (c = 0; c < 3; c++) {
est[c] = ((prevRow[dx * 3 + c] & 0xFF) + (pix[c] & 0xFF) -
(prevRow[(dx-1) * 3 + c] & 0xFF));
if (est[c] > 0xFF) {
est[c] = 0xFF;
} else if (est[c] < 0x00) {
est[c] = 0x00;
}
pix[c] = (byte)(est[c] + buf[(dy * w + dx) * 3 + c]);
thisRow[dx * 3 + c] = pix[c];
}
pixels[offset++] = (pix[0] & 0xFF) << 16 | (pix[1] & 0xFF) << 8 | (pix[2] & 0xFF);
}
System.arraycopy(thisRow, 0, prevRow, 0, w * 3);
offset += (bitmapData.bitmapwidth - w);
}
}
/**
* Handles cursor shape update (XCursor and RichCursor encodings).
*/
synchronized void
handleCursorShapeUpdate(RfbProto rfb, int encodingType, int hotX, int hotY, int w, int h) throws IOException {
| // Path: bVNC/src/com/iiordanov/runsoft/bVNC/input/RemotePointer.java
// public abstract class RemotePointer {
//
// /**
// * Current and previous state of "mouse" buttons
// */
// protected int pointerMask = 0;
// protected int prevPointerMask = 0;
//
// protected RemoteCanvas vncCanvas;
// protected Context context;
// protected Handler handler;
// protected RfbConnectable rfb;
//
// /**
// * Indicates where the mouse pointer is located.
// */
// public int mouseX, mouseY;
//
// public RemotePointer (RfbConnectable r, RemoteCanvas v, Handler h) {
// rfb = r;
// mouseX=rfb.framebufferWidth()/2;
// mouseY=rfb.framebufferHeight()/2;
// vncCanvas = v;
// handler = h;
// context = v.getContext();
// }
//
// protected boolean shouldBeRightClick (KeyEvent e) {
// boolean result = false;
// int keyCode = e.getKeyCode();
//
// // If the camera button is pressed
// if (keyCode == KeyEvent.KEYCODE_CAMERA) {
// result = true;
// // Or the back button is pressed
// } else if (keyCode == KeyEvent.KEYCODE_BACK) {
// // Determine SDK
// boolean preGingerBread = android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD;
// // Whether the source is a mouse (getSource() is not available pre-Gingerbread)
// boolean mouseSource = (!preGingerBread && e.getSource() == InputDevice.SOURCE_MOUSE);
// // Whether the device has a qwerty keyboard
// boolean noQwertyKbd = (context.getResources().getConfiguration().keyboard != Configuration.KEYBOARD_QWERTY);
// // Whether the device is pre-Gingerbread or the event came from the "hard buttons"
// boolean fromVirtualHardKey = preGingerBread || (e.getFlags() & KeyEvent.FLAG_VIRTUAL_HARD_KEY) != 0;
// if (mouseSource || noQwertyKbd || fromVirtualHardKey) {
// result = true;
// }
// }
//
// return result;
// }
//
// abstract public int getX();
// abstract public int getY();
// abstract public void setX(int newX);
// abstract public void setY(int newY);
// abstract public void warpMouse(int x, int y);
// abstract public void mouseFollowPan();
// abstract boolean handleHardwareButtons(int keyCode, KeyEvent evt, int combinedMetastate);
// abstract public boolean processPointerEvent(MotionEvent evt, boolean downEvent,
// boolean useRightButton, boolean useMiddleButton, boolean useScrollButton, int direction);
// abstract public boolean processPointerEvent(MotionEvent evt, boolean downEvent,
// boolean useRightButton, boolean useMiddleButton);
// abstract public boolean processPointerEvent(MotionEvent evt, boolean downEvent, boolean useRightButton);
// abstract public boolean processPointerEvent(int x, int y, int action, int modifiers, boolean mouseIsDown, boolean useRightButton);
//
// abstract public boolean processPointerEvent(int x, int y, int action, int modifiers, boolean mouseIsDown, boolean useRightButton,
// boolean useMiddleButton, boolean useScrollButton, int direction);
// }
// Path: bVNC/src/com/iiordanov/runsoft/bVNC/Decoder.java
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.RectF;
import android.util.Log;
import java.io.IOException;
import java.util.zip.DataFormatException;
import java.util.zip.Inflater;
import com.iiordanov.runsoft.bVNC.input.RemotePointer;
}
pixels[offset++] = (pix[0] & 0xFF) << 16 | (pix[1] & 0xFF) << 8 | (pix[2] & 0xFF);
/* Remaining pixels of a row */
for (dx = 1; dx < w; dx++) {
for (c = 0; c < 3; c++) {
est[c] = ((prevRow[dx * 3 + c] & 0xFF) + (pix[c] & 0xFF) -
(prevRow[(dx-1) * 3 + c] & 0xFF));
if (est[c] > 0xFF) {
est[c] = 0xFF;
} else if (est[c] < 0x00) {
est[c] = 0x00;
}
pix[c] = (byte)(est[c] + buf[(dy * w + dx) * 3 + c]);
thisRow[dx * 3 + c] = pix[c];
}
pixels[offset++] = (pix[0] & 0xFF) << 16 | (pix[1] & 0xFF) << 8 | (pix[2] & 0xFF);
}
System.arraycopy(thisRow, 0, prevRow, 0, w * 3);
offset += (bitmapData.bitmapwidth - w);
}
}
/**
* Handles cursor shape update (XCursor and RichCursor encodings).
*/
synchronized void
handleCursorShapeUpdate(RfbProto rfb, int encodingType, int hotX, int hotY, int w, int h) throws IOException {
| RemotePointer p = vncCanvas.getPointer(); |
runsoftdev/bVnc | bVNC/src/com/iiordanov/tigervnc/rfb/ZRLEDecoder.java | // Path: bVNC/src/com/iiordanov/tigervnc/rdr/ZlibInStream.java
// public class ZlibInStream extends InStream {
//
// static final int defaultBufSize = 16384;
//
// public ZlibInStream(int bufSize_)
// {
// bufSize = bufSize_;
// b = new byte[bufSize];
// bytesIn = offset = 0;
// zs = new ZStream();
// zs.next_in = null;
// zs.next_in_index = 0;
// zs.avail_in = 0;
// if (zs.inflateInit() != JZlib.Z_OK) {
// zs = null;
// throw new Exception("ZlinInStream: inflateInit failed");
// }
// ptr = end = start = 0;
// }
//
// public ZlibInStream() { this(defaultBufSize); }
//
// protected void finalize() throws Throwable {
// try {
// b = null;
// zs.inflateEnd();
// } finally {
// super.finalize();
// }
// }
//
// public void setUnderlying(InStream is, int bytesIn_)
// {
// underlying = is;
// bytesIn = bytesIn_;
// ptr = end = start;
// }
//
// public int pos()
// {
// return offset + ptr - start;
// }
//
// public void reset()
// {
// ptr = end = start;
// if (underlying == null) return;
//
// while (bytesIn > 0) {
// decompress(true);
// end = start; // throw away any data
// }
// underlying = null;
// }
//
// protected int overrun(int itemSize, int nItems, boolean wait)
// {
// if (itemSize > bufSize)
// throw new Exception("ZlibInStream overrun: max itemSize exceeded");
// if (underlying == null)
// throw new Exception("ZlibInStream overrun: no underlying stream");
//
// if (end - ptr != 0)
// System.arraycopy(b, ptr, b, start, end - ptr);
//
// offset += ptr - start;
// end -= ptr - start;
// ptr = start;
//
// while (end - ptr < itemSize) {
// if (!decompress(wait))
// return 0;
// }
//
// if (itemSize * nItems > end - ptr)
// nItems = (end - ptr) / itemSize;
//
// return nItems;
// }
//
// // decompress() calls the decompressor once. Note that this won't
// // necessarily generate any output data - it may just consume some input
// // data. Returns false if wait is false and we would block on the underlying
// // stream.
//
// private boolean decompress(boolean wait)
// {
// zs.next_out = b;
// zs.next_out_index = end;
// zs.avail_out = start + bufSize - end;
//
// int n = underlying.check(1, 1, wait);
// if (n == 0) return false;
// zs.next_in = underlying.getbuf();
// zs.next_in_index = underlying.getptr();
// zs.avail_in = underlying.getend() - underlying.getptr();
// if (zs.avail_in > bytesIn)
// zs.avail_in = bytesIn;
//
// int rc = zs.inflate(JZlib.Z_SYNC_FLUSH);
// if (rc != JZlib.Z_OK) {
// throw new Exception("ZlibInStream: inflate failed");
// }
//
// bytesIn -= zs.next_in_index - underlying.getptr();
// end = zs.next_out_index;
// underlying.setptr(zs.next_in_index);
// return true;
// }
//
// private InStream underlying;
// private int bufSize;
// private int offset;
// private ZStream zs;
// private int bytesIn;
// private int start;
// }
| import com.iiordanov.tigervnc.rdr.InStream;
import com.iiordanov.tigervnc.rdr.ZlibInStream; | /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This software 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*/
package com.iiordanov.tigervnc.rfb;
public class ZRLEDecoder extends Decoder {
public ZRLEDecoder(CMsgReader reader_) {
reader = reader_; | // Path: bVNC/src/com/iiordanov/tigervnc/rdr/ZlibInStream.java
// public class ZlibInStream extends InStream {
//
// static final int defaultBufSize = 16384;
//
// public ZlibInStream(int bufSize_)
// {
// bufSize = bufSize_;
// b = new byte[bufSize];
// bytesIn = offset = 0;
// zs = new ZStream();
// zs.next_in = null;
// zs.next_in_index = 0;
// zs.avail_in = 0;
// if (zs.inflateInit() != JZlib.Z_OK) {
// zs = null;
// throw new Exception("ZlinInStream: inflateInit failed");
// }
// ptr = end = start = 0;
// }
//
// public ZlibInStream() { this(defaultBufSize); }
//
// protected void finalize() throws Throwable {
// try {
// b = null;
// zs.inflateEnd();
// } finally {
// super.finalize();
// }
// }
//
// public void setUnderlying(InStream is, int bytesIn_)
// {
// underlying = is;
// bytesIn = bytesIn_;
// ptr = end = start;
// }
//
// public int pos()
// {
// return offset + ptr - start;
// }
//
// public void reset()
// {
// ptr = end = start;
// if (underlying == null) return;
//
// while (bytesIn > 0) {
// decompress(true);
// end = start; // throw away any data
// }
// underlying = null;
// }
//
// protected int overrun(int itemSize, int nItems, boolean wait)
// {
// if (itemSize > bufSize)
// throw new Exception("ZlibInStream overrun: max itemSize exceeded");
// if (underlying == null)
// throw new Exception("ZlibInStream overrun: no underlying stream");
//
// if (end - ptr != 0)
// System.arraycopy(b, ptr, b, start, end - ptr);
//
// offset += ptr - start;
// end -= ptr - start;
// ptr = start;
//
// while (end - ptr < itemSize) {
// if (!decompress(wait))
// return 0;
// }
//
// if (itemSize * nItems > end - ptr)
// nItems = (end - ptr) / itemSize;
//
// return nItems;
// }
//
// // decompress() calls the decompressor once. Note that this won't
// // necessarily generate any output data - it may just consume some input
// // data. Returns false if wait is false and we would block on the underlying
// // stream.
//
// private boolean decompress(boolean wait)
// {
// zs.next_out = b;
// zs.next_out_index = end;
// zs.avail_out = start + bufSize - end;
//
// int n = underlying.check(1, 1, wait);
// if (n == 0) return false;
// zs.next_in = underlying.getbuf();
// zs.next_in_index = underlying.getptr();
// zs.avail_in = underlying.getend() - underlying.getptr();
// if (zs.avail_in > bytesIn)
// zs.avail_in = bytesIn;
//
// int rc = zs.inflate(JZlib.Z_SYNC_FLUSH);
// if (rc != JZlib.Z_OK) {
// throw new Exception("ZlibInStream: inflate failed");
// }
//
// bytesIn -= zs.next_in_index - underlying.getptr();
// end = zs.next_out_index;
// underlying.setptr(zs.next_in_index);
// return true;
// }
//
// private InStream underlying;
// private int bufSize;
// private int offset;
// private ZStream zs;
// private int bytesIn;
// private int start;
// }
// Path: bVNC/src/com/iiordanov/tigervnc/rfb/ZRLEDecoder.java
import com.iiordanov.tigervnc.rdr.InStream;
import com.iiordanov.tigervnc.rdr.ZlibInStream;
/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This software 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*/
package com.iiordanov.tigervnc.rfb;
public class ZRLEDecoder extends Decoder {
public ZRLEDecoder(CMsgReader reader_) {
reader = reader_; | zis = new ZlibInStream(); |
Lengchuan/SpringBoot-Study | SpringBoot-Mybatis/src/test/java/com/lengchuan/springBoot/druid/service/UserServiceTest.java | // Path: SpringBoot-SpringDataJPA/src/main/java/com/App.java
// @SpringBootApplication()
// public class App {
//
// public static void main(String[] args) {
// SpringApplication.run(App.class, args);
// }
// }
//
// Path: SpringBoot-FastJson/src/main/java/com/lengchuan/springBoot/druid/model/User.java
// public class User implements Serializable{
// // @JSONField(serialize = false)
// private String name;
// private int age;
// private String email;
// private List<User> friends;
//
// public User(String name, int age, String email) {
// this.name = name;
// this.age = age;
// this.email = email;
// }
//
// public User() {
// friends = new ArrayList<User>();
// friends.add(new User("lengchuan1", 25, "123@123.test"));
// friends.add(new User("lengchuan2", 25, "1234@123.test"));
// friends.add(new User("lengchuan3", 25, "12345@123.test"));
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public int getAge() {
// return age;
// }
//
// public void setAge(int age) {
// this.age = age;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public List<User> getFriends() {
// return friends;
// }
//
// public void setFriends(List<User> friends) {
// this.friends = friends;
// }
// }
| import com.App;
import com.lengchuan.springBoot.druid.model.User;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.Date; | package com.lengchuan.springBoot.druid.service;
/**
* @author lengchuan <lishuijun1992@gmail.com>
* @date 17-4-4
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = App.class)
public class UserServiceTest {
@Autowired
private UserService userService;
@Test
public void createUser() throws Exception { | // Path: SpringBoot-SpringDataJPA/src/main/java/com/App.java
// @SpringBootApplication()
// public class App {
//
// public static void main(String[] args) {
// SpringApplication.run(App.class, args);
// }
// }
//
// Path: SpringBoot-FastJson/src/main/java/com/lengchuan/springBoot/druid/model/User.java
// public class User implements Serializable{
// // @JSONField(serialize = false)
// private String name;
// private int age;
// private String email;
// private List<User> friends;
//
// public User(String name, int age, String email) {
// this.name = name;
// this.age = age;
// this.email = email;
// }
//
// public User() {
// friends = new ArrayList<User>();
// friends.add(new User("lengchuan1", 25, "123@123.test"));
// friends.add(new User("lengchuan2", 25, "1234@123.test"));
// friends.add(new User("lengchuan3", 25, "12345@123.test"));
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public int getAge() {
// return age;
// }
//
// public void setAge(int age) {
// this.age = age;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public List<User> getFriends() {
// return friends;
// }
//
// public void setFriends(List<User> friends) {
// this.friends = friends;
// }
// }
// Path: SpringBoot-Mybatis/src/test/java/com/lengchuan/springBoot/druid/service/UserServiceTest.java
import com.App;
import com.lengchuan.springBoot.druid.model.User;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.Date;
package com.lengchuan.springBoot.druid.service;
/**
* @author lengchuan <lishuijun1992@gmail.com>
* @date 17-4-4
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = App.class)
public class UserServiceTest {
@Autowired
private UserService userService;
@Test
public void createUser() throws Exception { | User user = new User(); |
Lengchuan/SpringBoot-Study | SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/service/StudentService.java | // Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/mapper/master/StudentMapper.java
// public interface StudentMapper {
//
// int insert(Student student);
//
// List<Student> getBypage();
// }
//
// Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/model/Student.java
// public class Student implements Serializable {
// private Integer id;
//
// private String name;
//
// private String email;
//
// private Integer age;
//
// private Date birthday;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public Integer getAge() {
// return age;
// }
//
// public void setAge(Integer age) {
// this.age = age;
// }
//
// public Date getBirthday() {
// return birthday;
// }
//
// public void setBirthday(Date birthday) {
// this.birthday = birthday;
// }
// }
| import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.lengchuan.springBoot.druid.ReadAndWrite.annotation.TargetDataSource;
import com.lengchuan.springBoot.druid.mapper.master.StudentMapper;
import com.lengchuan.springBoot.druid.model.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List; | package com.lengchuan.springBoot.druid.service;
/**
* @author lengchuan <lishuijun1992@gmail.com>
* @date 17-4-4
*/
@Service
public class StudentService {
@Autowired | // Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/mapper/master/StudentMapper.java
// public interface StudentMapper {
//
// int insert(Student student);
//
// List<Student> getBypage();
// }
//
// Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/model/Student.java
// public class Student implements Serializable {
// private Integer id;
//
// private String name;
//
// private String email;
//
// private Integer age;
//
// private Date birthday;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public Integer getAge() {
// return age;
// }
//
// public void setAge(Integer age) {
// this.age = age;
// }
//
// public Date getBirthday() {
// return birthday;
// }
//
// public void setBirthday(Date birthday) {
// this.birthday = birthday;
// }
// }
// Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/service/StudentService.java
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.lengchuan.springBoot.druid.ReadAndWrite.annotation.TargetDataSource;
import com.lengchuan.springBoot.druid.mapper.master.StudentMapper;
import com.lengchuan.springBoot.druid.model.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
package com.lengchuan.springBoot.druid.service;
/**
* @author lengchuan <lishuijun1992@gmail.com>
* @date 17-4-4
*/
@Service
public class StudentService {
@Autowired | private StudentMapper studentMapper; |
Lengchuan/SpringBoot-Study | SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/service/StudentService.java | // Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/mapper/master/StudentMapper.java
// public interface StudentMapper {
//
// int insert(Student student);
//
// List<Student> getBypage();
// }
//
// Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/model/Student.java
// public class Student implements Serializable {
// private Integer id;
//
// private String name;
//
// private String email;
//
// private Integer age;
//
// private Date birthday;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public Integer getAge() {
// return age;
// }
//
// public void setAge(Integer age) {
// this.age = age;
// }
//
// public Date getBirthday() {
// return birthday;
// }
//
// public void setBirthday(Date birthday) {
// this.birthday = birthday;
// }
// }
| import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.lengchuan.springBoot.druid.ReadAndWrite.annotation.TargetDataSource;
import com.lengchuan.springBoot.druid.mapper.master.StudentMapper;
import com.lengchuan.springBoot.druid.model.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List; | package com.lengchuan.springBoot.druid.service;
/**
* @author lengchuan <lishuijun1992@gmail.com>
* @date 17-4-4
*/
@Service
public class StudentService {
@Autowired
private StudentMapper studentMapper;
@Transactional
@TargetDataSource(dataSource = "writeDataSource") | // Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/mapper/master/StudentMapper.java
// public interface StudentMapper {
//
// int insert(Student student);
//
// List<Student> getBypage();
// }
//
// Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/model/Student.java
// public class Student implements Serializable {
// private Integer id;
//
// private String name;
//
// private String email;
//
// private Integer age;
//
// private Date birthday;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public Integer getAge() {
// return age;
// }
//
// public void setAge(Integer age) {
// this.age = age;
// }
//
// public Date getBirthday() {
// return birthday;
// }
//
// public void setBirthday(Date birthday) {
// this.birthday = birthday;
// }
// }
// Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/service/StudentService.java
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.lengchuan.springBoot.druid.ReadAndWrite.annotation.TargetDataSource;
import com.lengchuan.springBoot.druid.mapper.master.StudentMapper;
import com.lengchuan.springBoot.druid.model.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
package com.lengchuan.springBoot.druid.service;
/**
* @author lengchuan <lishuijun1992@gmail.com>
* @date 17-4-4
*/
@Service
public class StudentService {
@Autowired
private StudentMapper studentMapper;
@Transactional
@TargetDataSource(dataSource = "writeDataSource") | public boolean createUser(Student student) { |
Lengchuan/SpringBoot-Study | SpringBoot-Druid/src/test/java/com/lengchuan/springBoot/druid/service/ClassServiceTest.java | // Path: SpringBoot-Redis/src/test/java/com/BaseTest.java
// @RunWith(SpringJUnit4ClassRunner.class)
// @SpringBootTest(classes = App.class)
// public class BaseTest {
//
// private final static Logger logger = LoggerFactory.getLogger(BaseTest.class);
//
// @Autowired
// private UserService userService;
//
// @Test
// public void add() {
//
// User u = new User();
// u.setId(1);
// u.setName("lengchuan");
// u.setEmail("lishuijun1992@gmail.com");
//
// userService.createUser(u);
//
// }
//
// @Test
// public void get() {
//
// logger.info("获取到用户信息:{}", userService.getUser(1));
//
// }
// }
//
// Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/model/Class.java
// public class Class implements Serializable {
//
// private int id;
//
// private String className;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getClassName() {
// return className;
// }
//
// public void setClassName(String className) {
// this.className = className;
// }
// }
| import com.BaseTest;
import com.lengchuan.springBoot.druid.model.Class;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired; | package com.lengchuan.springBoot.druid.service;
/**
* @author lengchuan <lishuijun1992@gmail.com>
* @date 17-4-4
*/
public class ClassServiceTest extends BaseTest{
@Autowired
private ClassService classService;
@Test
public void createClass() throws Exception { | // Path: SpringBoot-Redis/src/test/java/com/BaseTest.java
// @RunWith(SpringJUnit4ClassRunner.class)
// @SpringBootTest(classes = App.class)
// public class BaseTest {
//
// private final static Logger logger = LoggerFactory.getLogger(BaseTest.class);
//
// @Autowired
// private UserService userService;
//
// @Test
// public void add() {
//
// User u = new User();
// u.setId(1);
// u.setName("lengchuan");
// u.setEmail("lishuijun1992@gmail.com");
//
// userService.createUser(u);
//
// }
//
// @Test
// public void get() {
//
// logger.info("获取到用户信息:{}", userService.getUser(1));
//
// }
// }
//
// Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/model/Class.java
// public class Class implements Serializable {
//
// private int id;
//
// private String className;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getClassName() {
// return className;
// }
//
// public void setClassName(String className) {
// this.className = className;
// }
// }
// Path: SpringBoot-Druid/src/test/java/com/lengchuan/springBoot/druid/service/ClassServiceTest.java
import com.BaseTest;
import com.lengchuan.springBoot.druid.model.Class;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
package com.lengchuan.springBoot.druid.service;
/**
* @author lengchuan <lishuijun1992@gmail.com>
* @date 17-4-4
*/
public class ClassServiceTest extends BaseTest{
@Autowired
private ClassService classService;
@Test
public void createClass() throws Exception { | Class c = new Class(); |
Lengchuan/SpringBoot-Study | SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/service/TeacherService.java | // Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/mapper/cluster1/TeacherMapper.java
// public interface TeacherMapper {
//
// int insert(Teacher teacher);
// }
//
// Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/model/Teacher.java
// public class Teacher implements Serializable {
//
// private Integer id;
//
// private String name;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
// }
| import com.lengchuan.springBoot.druid.mapper.cluster1.TeacherMapper;
import com.lengchuan.springBoot.druid.model.Teacher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; | package com.lengchuan.springBoot.druid.service;
/**
* @author lengchuan <lishuijun1992@gmail.com>
* @date 17-4-4
*/
@Service
public class TeacherService {
@Autowired | // Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/mapper/cluster1/TeacherMapper.java
// public interface TeacherMapper {
//
// int insert(Teacher teacher);
// }
//
// Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/model/Teacher.java
// public class Teacher implements Serializable {
//
// private Integer id;
//
// private String name;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
// }
// Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/service/TeacherService.java
import com.lengchuan.springBoot.druid.mapper.cluster1.TeacherMapper;
import com.lengchuan.springBoot.druid.model.Teacher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
package com.lengchuan.springBoot.druid.service;
/**
* @author lengchuan <lishuijun1992@gmail.com>
* @date 17-4-4
*/
@Service
public class TeacherService {
@Autowired | private TeacherMapper teacherMapper; |
Lengchuan/SpringBoot-Study | SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/service/TeacherService.java | // Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/mapper/cluster1/TeacherMapper.java
// public interface TeacherMapper {
//
// int insert(Teacher teacher);
// }
//
// Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/model/Teacher.java
// public class Teacher implements Serializable {
//
// private Integer id;
//
// private String name;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
// }
| import com.lengchuan.springBoot.druid.mapper.cluster1.TeacherMapper;
import com.lengchuan.springBoot.druid.model.Teacher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; | package com.lengchuan.springBoot.druid.service;
/**
* @author lengchuan <lishuijun1992@gmail.com>
* @date 17-4-4
*/
@Service
public class TeacherService {
@Autowired
private TeacherMapper teacherMapper;
@Transactional | // Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/mapper/cluster1/TeacherMapper.java
// public interface TeacherMapper {
//
// int insert(Teacher teacher);
// }
//
// Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/model/Teacher.java
// public class Teacher implements Serializable {
//
// private Integer id;
//
// private String name;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
// }
// Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/service/TeacherService.java
import com.lengchuan.springBoot.druid.mapper.cluster1.TeacherMapper;
import com.lengchuan.springBoot.druid.model.Teacher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
package com.lengchuan.springBoot.druid.service;
/**
* @author lengchuan <lishuijun1992@gmail.com>
* @date 17-4-4
*/
@Service
public class TeacherService {
@Autowired
private TeacherMapper teacherMapper;
@Transactional | public boolean createTeacher(Teacher teacher) { |
Lengchuan/SpringBoot-Study | SpringBoot-GlobalExceptionHandler/src/main/java/com/lengchuan/springBoot/controller/DemoController.java | // Path: SpringBoot-GlobalExceptionHandler/src/main/java/com/lengchuan/springBoot/Exception/MyException1.java
// public class MyException1 extends Exception {
// public MyException1() {
// super();
// }
//
// public MyException1(String msg) {
// super(msg);
// }
// }
| import com.lengchuan.springBoot.Exception.MyException1;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; | package com.lengchuan.springBoot.controller;
/**
* @author lengchuan <lishuijun1992@gmail.com>
* @date 17-3-27
*/
@RestController
@RequestMapping("/demo")
public class DemoController {
@RequestMapping("/default")
public String defaultException() {
throw new NullPointerException();
}
@RequestMapping("/my") | // Path: SpringBoot-GlobalExceptionHandler/src/main/java/com/lengchuan/springBoot/Exception/MyException1.java
// public class MyException1 extends Exception {
// public MyException1() {
// super();
// }
//
// public MyException1(String msg) {
// super(msg);
// }
// }
// Path: SpringBoot-GlobalExceptionHandler/src/main/java/com/lengchuan/springBoot/controller/DemoController.java
import com.lengchuan.springBoot.Exception.MyException1;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
package com.lengchuan.springBoot.controller;
/**
* @author lengchuan <lishuijun1992@gmail.com>
* @date 17-3-27
*/
@RestController
@RequestMapping("/demo")
public class DemoController {
@RequestMapping("/default")
public String defaultException() {
throw new NullPointerException();
}
@RequestMapping("/my") | public String MyException() throws MyException1 { |
Lengchuan/SpringBoot-Study | SpringBoot-Redis/src/main/java/com/lengchuan/springBoot/redis/dao/UserDao.java | // Path: SpringBoot-Redis/src/main/java/com/lengchuan/springBoot/redis/model/User.java
// public class User extends Entity {
//
// private Integer id;
// private String name;
// private String email;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", name='" + name + '\'' +
// ", email='" + email + '\'' +
// '}';
// }
// }
| import com.lengchuan.springBoot.redis.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Repository; | package com.lengchuan.springBoot.redis.dao;
/**
* @author lengchuan <lishuijun1992@gmail.com>
* @date 17-5-8
*/
@Repository
public class UserDao {
private final static String USER_PREFIX = "User:";
@Autowired
private RedisTemplate redisTemplate;
| // Path: SpringBoot-Redis/src/main/java/com/lengchuan/springBoot/redis/model/User.java
// public class User extends Entity {
//
// private Integer id;
// private String name;
// private String email;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", name='" + name + '\'' +
// ", email='" + email + '\'' +
// '}';
// }
// }
// Path: SpringBoot-Redis/src/main/java/com/lengchuan/springBoot/redis/dao/UserDao.java
import com.lengchuan.springBoot.redis.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Repository;
package com.lengchuan.springBoot.redis.dao;
/**
* @author lengchuan <lishuijun1992@gmail.com>
* @date 17-5-8
*/
@Repository
public class UserDao {
private final static String USER_PREFIX = "User:";
@Autowired
private RedisTemplate redisTemplate;
| public void insertUser(User user) { |
Lengchuan/SpringBoot-Study | SpringBoot-Redis/src/test/java/com/BaseTest.java | // Path: SpringBoot-Redis/src/main/java/com/lengchuan/springBoot/redis/model/User.java
// public class User extends Entity {
//
// private Integer id;
// private String name;
// private String email;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", name='" + name + '\'' +
// ", email='" + email + '\'' +
// '}';
// }
// }
//
// Path: SpringBoot-Redis/src/main/java/com/lengchuan/springBoot/redis/service/UserService.java
// public interface UserService {
//
// void createUser(User user);
//
// User getUser(Integer id);
// }
| import com.lengchuan.springBoot.redis.model.User;
import com.lengchuan.springBoot.redis.service.UserService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; | package com;
/**
* @author lengchuan <lishuijun1992@gmail.com>
* @date 17-4-5
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = App.class)
public class BaseTest {
private final static Logger logger = LoggerFactory.getLogger(BaseTest.class);
@Autowired | // Path: SpringBoot-Redis/src/main/java/com/lengchuan/springBoot/redis/model/User.java
// public class User extends Entity {
//
// private Integer id;
// private String name;
// private String email;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", name='" + name + '\'' +
// ", email='" + email + '\'' +
// '}';
// }
// }
//
// Path: SpringBoot-Redis/src/main/java/com/lengchuan/springBoot/redis/service/UserService.java
// public interface UserService {
//
// void createUser(User user);
//
// User getUser(Integer id);
// }
// Path: SpringBoot-Redis/src/test/java/com/BaseTest.java
import com.lengchuan.springBoot.redis.model.User;
import com.lengchuan.springBoot.redis.service.UserService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
package com;
/**
* @author lengchuan <lishuijun1992@gmail.com>
* @date 17-4-5
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = App.class)
public class BaseTest {
private final static Logger logger = LoggerFactory.getLogger(BaseTest.class);
@Autowired | private UserService userService; |
Lengchuan/SpringBoot-Study | SpringBoot-Redis/src/test/java/com/BaseTest.java | // Path: SpringBoot-Redis/src/main/java/com/lengchuan/springBoot/redis/model/User.java
// public class User extends Entity {
//
// private Integer id;
// private String name;
// private String email;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", name='" + name + '\'' +
// ", email='" + email + '\'' +
// '}';
// }
// }
//
// Path: SpringBoot-Redis/src/main/java/com/lengchuan/springBoot/redis/service/UserService.java
// public interface UserService {
//
// void createUser(User user);
//
// User getUser(Integer id);
// }
| import com.lengchuan.springBoot.redis.model.User;
import com.lengchuan.springBoot.redis.service.UserService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; | package com;
/**
* @author lengchuan <lishuijun1992@gmail.com>
* @date 17-4-5
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = App.class)
public class BaseTest {
private final static Logger logger = LoggerFactory.getLogger(BaseTest.class);
@Autowired
private UserService userService;
@Test
public void add() {
| // Path: SpringBoot-Redis/src/main/java/com/lengchuan/springBoot/redis/model/User.java
// public class User extends Entity {
//
// private Integer id;
// private String name;
// private String email;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", name='" + name + '\'' +
// ", email='" + email + '\'' +
// '}';
// }
// }
//
// Path: SpringBoot-Redis/src/main/java/com/lengchuan/springBoot/redis/service/UserService.java
// public interface UserService {
//
// void createUser(User user);
//
// User getUser(Integer id);
// }
// Path: SpringBoot-Redis/src/test/java/com/BaseTest.java
import com.lengchuan.springBoot.redis.model.User;
import com.lengchuan.springBoot.redis.service.UserService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
package com;
/**
* @author lengchuan <lishuijun1992@gmail.com>
* @date 17-4-5
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = App.class)
public class BaseTest {
private final static Logger logger = LoggerFactory.getLogger(BaseTest.class);
@Autowired
private UserService userService;
@Test
public void add() {
| User u = new User(); |
Lengchuan/SpringBoot-Study | SpringBoot-Mybatis/src/main/java/com/lengchuan/springBoot/druid/service/UserService.java | // Path: SpringBoot-Mybatis/src/main/java/com/lengchuan/springBoot/druid/mapper/UserMapper.java
// public interface UserMapper {
//
// int insert(User user);
//
// // int update(User user);
//
// // int delete(User user);
//
// // User getById(int userId);
//
// List<User> getBypage();
// }
//
// Path: SpringBoot-FastJson/src/main/java/com/lengchuan/springBoot/druid/model/User.java
// public class User implements Serializable{
// // @JSONField(serialize = false)
// private String name;
// private int age;
// private String email;
// private List<User> friends;
//
// public User(String name, int age, String email) {
// this.name = name;
// this.age = age;
// this.email = email;
// }
//
// public User() {
// friends = new ArrayList<User>();
// friends.add(new User("lengchuan1", 25, "123@123.test"));
// friends.add(new User("lengchuan2", 25, "1234@123.test"));
// friends.add(new User("lengchuan3", 25, "12345@123.test"));
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public int getAge() {
// return age;
// }
//
// public void setAge(int age) {
// this.age = age;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public List<User> getFriends() {
// return friends;
// }
//
// public void setFriends(List<User> friends) {
// this.friends = friends;
// }
// }
| import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.lengchuan.springBoot.druid.mapper.UserMapper;
import com.lengchuan.springBoot.druid.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List; | package com.lengchuan.springBoot.druid.service;
/**
* @author lengchuan <lishuijun1992@gmail.com>
* @date 17-4-4
*/
@Service
public class UserService {
@Autowired | // Path: SpringBoot-Mybatis/src/main/java/com/lengchuan/springBoot/druid/mapper/UserMapper.java
// public interface UserMapper {
//
// int insert(User user);
//
// // int update(User user);
//
// // int delete(User user);
//
// // User getById(int userId);
//
// List<User> getBypage();
// }
//
// Path: SpringBoot-FastJson/src/main/java/com/lengchuan/springBoot/druid/model/User.java
// public class User implements Serializable{
// // @JSONField(serialize = false)
// private String name;
// private int age;
// private String email;
// private List<User> friends;
//
// public User(String name, int age, String email) {
// this.name = name;
// this.age = age;
// this.email = email;
// }
//
// public User() {
// friends = new ArrayList<User>();
// friends.add(new User("lengchuan1", 25, "123@123.test"));
// friends.add(new User("lengchuan2", 25, "1234@123.test"));
// friends.add(new User("lengchuan3", 25, "12345@123.test"));
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public int getAge() {
// return age;
// }
//
// public void setAge(int age) {
// this.age = age;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public List<User> getFriends() {
// return friends;
// }
//
// public void setFriends(List<User> friends) {
// this.friends = friends;
// }
// }
// Path: SpringBoot-Mybatis/src/main/java/com/lengchuan/springBoot/druid/service/UserService.java
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.lengchuan.springBoot.druid.mapper.UserMapper;
import com.lengchuan.springBoot.druid.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
package com.lengchuan.springBoot.druid.service;
/**
* @author lengchuan <lishuijun1992@gmail.com>
* @date 17-4-4
*/
@Service
public class UserService {
@Autowired | private UserMapper userMapper; |
Lengchuan/SpringBoot-Study | SpringBoot-Mybatis/src/main/java/com/lengchuan/springBoot/druid/service/UserService.java | // Path: SpringBoot-Mybatis/src/main/java/com/lengchuan/springBoot/druid/mapper/UserMapper.java
// public interface UserMapper {
//
// int insert(User user);
//
// // int update(User user);
//
// // int delete(User user);
//
// // User getById(int userId);
//
// List<User> getBypage();
// }
//
// Path: SpringBoot-FastJson/src/main/java/com/lengchuan/springBoot/druid/model/User.java
// public class User implements Serializable{
// // @JSONField(serialize = false)
// private String name;
// private int age;
// private String email;
// private List<User> friends;
//
// public User(String name, int age, String email) {
// this.name = name;
// this.age = age;
// this.email = email;
// }
//
// public User() {
// friends = new ArrayList<User>();
// friends.add(new User("lengchuan1", 25, "123@123.test"));
// friends.add(new User("lengchuan2", 25, "1234@123.test"));
// friends.add(new User("lengchuan3", 25, "12345@123.test"));
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public int getAge() {
// return age;
// }
//
// public void setAge(int age) {
// this.age = age;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public List<User> getFriends() {
// return friends;
// }
//
// public void setFriends(List<User> friends) {
// this.friends = friends;
// }
// }
| import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.lengchuan.springBoot.druid.mapper.UserMapper;
import com.lengchuan.springBoot.druid.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List; | package com.lengchuan.springBoot.druid.service;
/**
* @author lengchuan <lishuijun1992@gmail.com>
* @date 17-4-4
*/
@Service
public class UserService {
@Autowired
private UserMapper userMapper;
@Transactional | // Path: SpringBoot-Mybatis/src/main/java/com/lengchuan/springBoot/druid/mapper/UserMapper.java
// public interface UserMapper {
//
// int insert(User user);
//
// // int update(User user);
//
// // int delete(User user);
//
// // User getById(int userId);
//
// List<User> getBypage();
// }
//
// Path: SpringBoot-FastJson/src/main/java/com/lengchuan/springBoot/druid/model/User.java
// public class User implements Serializable{
// // @JSONField(serialize = false)
// private String name;
// private int age;
// private String email;
// private List<User> friends;
//
// public User(String name, int age, String email) {
// this.name = name;
// this.age = age;
// this.email = email;
// }
//
// public User() {
// friends = new ArrayList<User>();
// friends.add(new User("lengchuan1", 25, "123@123.test"));
// friends.add(new User("lengchuan2", 25, "1234@123.test"));
// friends.add(new User("lengchuan3", 25, "12345@123.test"));
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public int getAge() {
// return age;
// }
//
// public void setAge(int age) {
// this.age = age;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public List<User> getFriends() {
// return friends;
// }
//
// public void setFriends(List<User> friends) {
// this.friends = friends;
// }
// }
// Path: SpringBoot-Mybatis/src/main/java/com/lengchuan/springBoot/druid/service/UserService.java
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.lengchuan.springBoot.druid.mapper.UserMapper;
import com.lengchuan.springBoot.druid.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
package com.lengchuan.springBoot.druid.service;
/**
* @author lengchuan <lishuijun1992@gmail.com>
* @date 17-4-4
*/
@Service
public class UserService {
@Autowired
private UserMapper userMapper;
@Transactional | public boolean createUser(User user) { |
Lengchuan/SpringBoot-Study | SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/ReadAndWrite/aspect/DynamicDataSourceAspect.java | // Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/ReadAndWrite/config/DynamicDataSourceHolder.java
// public class DynamicDataSourceHolder {
// //使用ThreadLocal把数据源与当前线程绑定
// private static final ThreadLocal<String> dataSources = new ThreadLocal<String>();
//
// public static void setDataSource(String dataSourceName) {
// dataSources.set(dataSourceName);
// }
//
// public static String getDataSource() {
// return dataSources.get();
// }
//
// public static void clearDataSource() {
// dataSources.remove();
// }
// }
| import com.lengchuan.springBoot.druid.ReadAndWrite.annotation.TargetDataSource;
import com.lengchuan.springBoot.druid.ReadAndWrite.config.DynamicDataSourceHolder;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.stereotype.Component;
import java.lang.reflect.Method; | package com.lengchuan.springBoot.druid.ReadAndWrite.aspect;
/**
* aop 配置动态切换数据源
*
* @author lengchuan <lishuijun1992@gmail.com>
* @date 17-4-5
*/
@Aspect
@Component
public class DynamicDataSourceAspect {
@Around("execution(public * com.lengchuan.springBoot.druid.service..*.*(..))")
public Object around(ProceedingJoinPoint pjp) throws Throwable {
MethodSignature methodSignature = (MethodSignature) pjp.getSignature();
Method targetMethod = methodSignature.getMethod();
if (targetMethod.isAnnotationPresent(TargetDataSource.class)) {
String targetDataSource = targetMethod.getAnnotation(TargetDataSource.class).dataSource();
System.out.println("----------数据源是:" + targetDataSource + "------"); | // Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/ReadAndWrite/config/DynamicDataSourceHolder.java
// public class DynamicDataSourceHolder {
// //使用ThreadLocal把数据源与当前线程绑定
// private static final ThreadLocal<String> dataSources = new ThreadLocal<String>();
//
// public static void setDataSource(String dataSourceName) {
// dataSources.set(dataSourceName);
// }
//
// public static String getDataSource() {
// return dataSources.get();
// }
//
// public static void clearDataSource() {
// dataSources.remove();
// }
// }
// Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/ReadAndWrite/aspect/DynamicDataSourceAspect.java
import com.lengchuan.springBoot.druid.ReadAndWrite.annotation.TargetDataSource;
import com.lengchuan.springBoot.druid.ReadAndWrite.config.DynamicDataSourceHolder;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.stereotype.Component;
import java.lang.reflect.Method;
package com.lengchuan.springBoot.druid.ReadAndWrite.aspect;
/**
* aop 配置动态切换数据源
*
* @author lengchuan <lishuijun1992@gmail.com>
* @date 17-4-5
*/
@Aspect
@Component
public class DynamicDataSourceAspect {
@Around("execution(public * com.lengchuan.springBoot.druid.service..*.*(..))")
public Object around(ProceedingJoinPoint pjp) throws Throwable {
MethodSignature methodSignature = (MethodSignature) pjp.getSignature();
Method targetMethod = methodSignature.getMethod();
if (targetMethod.isAnnotationPresent(TargetDataSource.class)) {
String targetDataSource = targetMethod.getAnnotation(TargetDataSource.class).dataSource();
System.out.println("----------数据源是:" + targetDataSource + "------"); | DynamicDataSourceHolder.setDataSource(targetDataSource); |
Lengchuan/SpringBoot-Study | SpringBoot-Druid/src/main/java/com/App.java | // Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/model/Class.java
// public class Class implements Serializable {
//
// private int id;
//
// private String className;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getClassName() {
// return className;
// }
//
// public void setClassName(String className) {
// this.className = className;
// }
// }
//
// Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/model/Student.java
// public class Student implements Serializable {
// private Integer id;
//
// private String name;
//
// private String email;
//
// private Integer age;
//
// private Date birthday;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public Integer getAge() {
// return age;
// }
//
// public void setAge(Integer age) {
// this.age = age;
// }
//
// public Date getBirthday() {
// return birthday;
// }
//
// public void setBirthday(Date birthday) {
// this.birthday = birthday;
// }
// }
//
// Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/service/ClassService.java
// @Service
// public class ClassService {
//
// @Autowired
// private ClassMapper classMapper;
//
// @Transactional
// public boolean createClass(Class c) {
// classMapper.insert(c);
// return true;
// }
// }
//
// Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/service/StudentService.java
// @Service
// public class StudentService {
//
// @Autowired
// private StudentMapper studentMapper;
//
// @Transactional
// @TargetDataSource(dataSource = "writeDataSource")
// public boolean createUser(Student student) {
// studentMapper.insert(student);
//
// //事务测试
// // int i = 1 / 0;
// return true;
// }
//
// @TargetDataSource(dataSource = "read1DataSource")
// public List<Student> getByPage(int page, int rows) {
// Page<Student> studentPage = PageHelper.startPage(page, rows, true);
// List<Student> students = studentMapper.getBypage();
// System.out.println("-------------------" + studentPage.toString() + "-----------");
// return students;
// }
// }
| import com.lengchuan.springBoot.druid.model.Class;
import com.lengchuan.springBoot.druid.model.Student;
import com.lengchuan.springBoot.druid.service.ClassService;
import com.lengchuan.springBoot.druid.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import java.util.Date; | package com;
/**
* @author lengchuan <lishuijun1992@gmail.com>
* @date 17-4-4
*/
@SpringBootApplication
@ServletComponentScan("com.lengchuan.springBoot.dataSource.monitor")//扫描servlet配置
public class App implements CommandLineRunner {
@Autowired | // Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/model/Class.java
// public class Class implements Serializable {
//
// private int id;
//
// private String className;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getClassName() {
// return className;
// }
//
// public void setClassName(String className) {
// this.className = className;
// }
// }
//
// Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/model/Student.java
// public class Student implements Serializable {
// private Integer id;
//
// private String name;
//
// private String email;
//
// private Integer age;
//
// private Date birthday;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public Integer getAge() {
// return age;
// }
//
// public void setAge(Integer age) {
// this.age = age;
// }
//
// public Date getBirthday() {
// return birthday;
// }
//
// public void setBirthday(Date birthday) {
// this.birthday = birthday;
// }
// }
//
// Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/service/ClassService.java
// @Service
// public class ClassService {
//
// @Autowired
// private ClassMapper classMapper;
//
// @Transactional
// public boolean createClass(Class c) {
// classMapper.insert(c);
// return true;
// }
// }
//
// Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/service/StudentService.java
// @Service
// public class StudentService {
//
// @Autowired
// private StudentMapper studentMapper;
//
// @Transactional
// @TargetDataSource(dataSource = "writeDataSource")
// public boolean createUser(Student student) {
// studentMapper.insert(student);
//
// //事务测试
// // int i = 1 / 0;
// return true;
// }
//
// @TargetDataSource(dataSource = "read1DataSource")
// public List<Student> getByPage(int page, int rows) {
// Page<Student> studentPage = PageHelper.startPage(page, rows, true);
// List<Student> students = studentMapper.getBypage();
// System.out.println("-------------------" + studentPage.toString() + "-----------");
// return students;
// }
// }
// Path: SpringBoot-Druid/src/main/java/com/App.java
import com.lengchuan.springBoot.druid.model.Class;
import com.lengchuan.springBoot.druid.model.Student;
import com.lengchuan.springBoot.druid.service.ClassService;
import com.lengchuan.springBoot.druid.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import java.util.Date;
package com;
/**
* @author lengchuan <lishuijun1992@gmail.com>
* @date 17-4-4
*/
@SpringBootApplication
@ServletComponentScan("com.lengchuan.springBoot.dataSource.monitor")//扫描servlet配置
public class App implements CommandLineRunner {
@Autowired | private StudentService studentService; |
Lengchuan/SpringBoot-Study | SpringBoot-Druid/src/main/java/com/App.java | // Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/model/Class.java
// public class Class implements Serializable {
//
// private int id;
//
// private String className;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getClassName() {
// return className;
// }
//
// public void setClassName(String className) {
// this.className = className;
// }
// }
//
// Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/model/Student.java
// public class Student implements Serializable {
// private Integer id;
//
// private String name;
//
// private String email;
//
// private Integer age;
//
// private Date birthday;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public Integer getAge() {
// return age;
// }
//
// public void setAge(Integer age) {
// this.age = age;
// }
//
// public Date getBirthday() {
// return birthday;
// }
//
// public void setBirthday(Date birthday) {
// this.birthday = birthday;
// }
// }
//
// Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/service/ClassService.java
// @Service
// public class ClassService {
//
// @Autowired
// private ClassMapper classMapper;
//
// @Transactional
// public boolean createClass(Class c) {
// classMapper.insert(c);
// return true;
// }
// }
//
// Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/service/StudentService.java
// @Service
// public class StudentService {
//
// @Autowired
// private StudentMapper studentMapper;
//
// @Transactional
// @TargetDataSource(dataSource = "writeDataSource")
// public boolean createUser(Student student) {
// studentMapper.insert(student);
//
// //事务测试
// // int i = 1 / 0;
// return true;
// }
//
// @TargetDataSource(dataSource = "read1DataSource")
// public List<Student> getByPage(int page, int rows) {
// Page<Student> studentPage = PageHelper.startPage(page, rows, true);
// List<Student> students = studentMapper.getBypage();
// System.out.println("-------------------" + studentPage.toString() + "-----------");
// return students;
// }
// }
| import com.lengchuan.springBoot.druid.model.Class;
import com.lengchuan.springBoot.druid.model.Student;
import com.lengchuan.springBoot.druid.service.ClassService;
import com.lengchuan.springBoot.druid.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import java.util.Date; | package com;
/**
* @author lengchuan <lishuijun1992@gmail.com>
* @date 17-4-4
*/
@SpringBootApplication
@ServletComponentScan("com.lengchuan.springBoot.dataSource.monitor")//扫描servlet配置
public class App implements CommandLineRunner {
@Autowired
private StudentService studentService;
@Autowired | // Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/model/Class.java
// public class Class implements Serializable {
//
// private int id;
//
// private String className;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getClassName() {
// return className;
// }
//
// public void setClassName(String className) {
// this.className = className;
// }
// }
//
// Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/model/Student.java
// public class Student implements Serializable {
// private Integer id;
//
// private String name;
//
// private String email;
//
// private Integer age;
//
// private Date birthday;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public Integer getAge() {
// return age;
// }
//
// public void setAge(Integer age) {
// this.age = age;
// }
//
// public Date getBirthday() {
// return birthday;
// }
//
// public void setBirthday(Date birthday) {
// this.birthday = birthday;
// }
// }
//
// Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/service/ClassService.java
// @Service
// public class ClassService {
//
// @Autowired
// private ClassMapper classMapper;
//
// @Transactional
// public boolean createClass(Class c) {
// classMapper.insert(c);
// return true;
// }
// }
//
// Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/service/StudentService.java
// @Service
// public class StudentService {
//
// @Autowired
// private StudentMapper studentMapper;
//
// @Transactional
// @TargetDataSource(dataSource = "writeDataSource")
// public boolean createUser(Student student) {
// studentMapper.insert(student);
//
// //事务测试
// // int i = 1 / 0;
// return true;
// }
//
// @TargetDataSource(dataSource = "read1DataSource")
// public List<Student> getByPage(int page, int rows) {
// Page<Student> studentPage = PageHelper.startPage(page, rows, true);
// List<Student> students = studentMapper.getBypage();
// System.out.println("-------------------" + studentPage.toString() + "-----------");
// return students;
// }
// }
// Path: SpringBoot-Druid/src/main/java/com/App.java
import com.lengchuan.springBoot.druid.model.Class;
import com.lengchuan.springBoot.druid.model.Student;
import com.lengchuan.springBoot.druid.service.ClassService;
import com.lengchuan.springBoot.druid.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import java.util.Date;
package com;
/**
* @author lengchuan <lishuijun1992@gmail.com>
* @date 17-4-4
*/
@SpringBootApplication
@ServletComponentScan("com.lengchuan.springBoot.dataSource.monitor")//扫描servlet配置
public class App implements CommandLineRunner {
@Autowired
private StudentService studentService;
@Autowired | private ClassService classService; |
Lengchuan/SpringBoot-Study | SpringBoot-Druid/src/main/java/com/App.java | // Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/model/Class.java
// public class Class implements Serializable {
//
// private int id;
//
// private String className;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getClassName() {
// return className;
// }
//
// public void setClassName(String className) {
// this.className = className;
// }
// }
//
// Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/model/Student.java
// public class Student implements Serializable {
// private Integer id;
//
// private String name;
//
// private String email;
//
// private Integer age;
//
// private Date birthday;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public Integer getAge() {
// return age;
// }
//
// public void setAge(Integer age) {
// this.age = age;
// }
//
// public Date getBirthday() {
// return birthday;
// }
//
// public void setBirthday(Date birthday) {
// this.birthday = birthday;
// }
// }
//
// Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/service/ClassService.java
// @Service
// public class ClassService {
//
// @Autowired
// private ClassMapper classMapper;
//
// @Transactional
// public boolean createClass(Class c) {
// classMapper.insert(c);
// return true;
// }
// }
//
// Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/service/StudentService.java
// @Service
// public class StudentService {
//
// @Autowired
// private StudentMapper studentMapper;
//
// @Transactional
// @TargetDataSource(dataSource = "writeDataSource")
// public boolean createUser(Student student) {
// studentMapper.insert(student);
//
// //事务测试
// // int i = 1 / 0;
// return true;
// }
//
// @TargetDataSource(dataSource = "read1DataSource")
// public List<Student> getByPage(int page, int rows) {
// Page<Student> studentPage = PageHelper.startPage(page, rows, true);
// List<Student> students = studentMapper.getBypage();
// System.out.println("-------------------" + studentPage.toString() + "-----------");
// return students;
// }
// }
| import com.lengchuan.springBoot.druid.model.Class;
import com.lengchuan.springBoot.druid.model.Student;
import com.lengchuan.springBoot.druid.service.ClassService;
import com.lengchuan.springBoot.druid.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import java.util.Date; | package com;
/**
* @author lengchuan <lishuijun1992@gmail.com>
* @date 17-4-4
*/
@SpringBootApplication
@ServletComponentScan("com.lengchuan.springBoot.dataSource.monitor")//扫描servlet配置
public class App implements CommandLineRunner {
@Autowired
private StudentService studentService;
@Autowired
private ClassService classService;
/**
* Callback used to run the bean.
*
* @param args incoming main method arguments
* @throws Exception on error
*/
public void run(String... args) throws Exception { | // Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/model/Class.java
// public class Class implements Serializable {
//
// private int id;
//
// private String className;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getClassName() {
// return className;
// }
//
// public void setClassName(String className) {
// this.className = className;
// }
// }
//
// Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/model/Student.java
// public class Student implements Serializable {
// private Integer id;
//
// private String name;
//
// private String email;
//
// private Integer age;
//
// private Date birthday;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public Integer getAge() {
// return age;
// }
//
// public void setAge(Integer age) {
// this.age = age;
// }
//
// public Date getBirthday() {
// return birthday;
// }
//
// public void setBirthday(Date birthday) {
// this.birthday = birthday;
// }
// }
//
// Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/service/ClassService.java
// @Service
// public class ClassService {
//
// @Autowired
// private ClassMapper classMapper;
//
// @Transactional
// public boolean createClass(Class c) {
// classMapper.insert(c);
// return true;
// }
// }
//
// Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/service/StudentService.java
// @Service
// public class StudentService {
//
// @Autowired
// private StudentMapper studentMapper;
//
// @Transactional
// @TargetDataSource(dataSource = "writeDataSource")
// public boolean createUser(Student student) {
// studentMapper.insert(student);
//
// //事务测试
// // int i = 1 / 0;
// return true;
// }
//
// @TargetDataSource(dataSource = "read1DataSource")
// public List<Student> getByPage(int page, int rows) {
// Page<Student> studentPage = PageHelper.startPage(page, rows, true);
// List<Student> students = studentMapper.getBypage();
// System.out.println("-------------------" + studentPage.toString() + "-----------");
// return students;
// }
// }
// Path: SpringBoot-Druid/src/main/java/com/App.java
import com.lengchuan.springBoot.druid.model.Class;
import com.lengchuan.springBoot.druid.model.Student;
import com.lengchuan.springBoot.druid.service.ClassService;
import com.lengchuan.springBoot.druid.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import java.util.Date;
package com;
/**
* @author lengchuan <lishuijun1992@gmail.com>
* @date 17-4-4
*/
@SpringBootApplication
@ServletComponentScan("com.lengchuan.springBoot.dataSource.monitor")//扫描servlet配置
public class App implements CommandLineRunner {
@Autowired
private StudentService studentService;
@Autowired
private ClassService classService;
/**
* Callback used to run the bean.
*
* @param args incoming main method arguments
* @throws Exception on error
*/
public void run(String... args) throws Exception { | Student student = new Student(); |
Lengchuan/SpringBoot-Study | SpringBoot-Druid/src/main/java/com/App.java | // Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/model/Class.java
// public class Class implements Serializable {
//
// private int id;
//
// private String className;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getClassName() {
// return className;
// }
//
// public void setClassName(String className) {
// this.className = className;
// }
// }
//
// Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/model/Student.java
// public class Student implements Serializable {
// private Integer id;
//
// private String name;
//
// private String email;
//
// private Integer age;
//
// private Date birthday;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public Integer getAge() {
// return age;
// }
//
// public void setAge(Integer age) {
// this.age = age;
// }
//
// public Date getBirthday() {
// return birthday;
// }
//
// public void setBirthday(Date birthday) {
// this.birthday = birthday;
// }
// }
//
// Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/service/ClassService.java
// @Service
// public class ClassService {
//
// @Autowired
// private ClassMapper classMapper;
//
// @Transactional
// public boolean createClass(Class c) {
// classMapper.insert(c);
// return true;
// }
// }
//
// Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/service/StudentService.java
// @Service
// public class StudentService {
//
// @Autowired
// private StudentMapper studentMapper;
//
// @Transactional
// @TargetDataSource(dataSource = "writeDataSource")
// public boolean createUser(Student student) {
// studentMapper.insert(student);
//
// //事务测试
// // int i = 1 / 0;
// return true;
// }
//
// @TargetDataSource(dataSource = "read1DataSource")
// public List<Student> getByPage(int page, int rows) {
// Page<Student> studentPage = PageHelper.startPage(page, rows, true);
// List<Student> students = studentMapper.getBypage();
// System.out.println("-------------------" + studentPage.toString() + "-----------");
// return students;
// }
// }
| import com.lengchuan.springBoot.druid.model.Class;
import com.lengchuan.springBoot.druid.model.Student;
import com.lengchuan.springBoot.druid.service.ClassService;
import com.lengchuan.springBoot.druid.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import java.util.Date; | package com;
/**
* @author lengchuan <lishuijun1992@gmail.com>
* @date 17-4-4
*/
@SpringBootApplication
@ServletComponentScan("com.lengchuan.springBoot.dataSource.monitor")//扫描servlet配置
public class App implements CommandLineRunner {
@Autowired
private StudentService studentService;
@Autowired
private ClassService classService;
/**
* Callback used to run the bean.
*
* @param args incoming main method arguments
* @throws Exception on error
*/
public void run(String... args) throws Exception {
Student student = new Student();
student.setAge(1);
student.setBirthday(new Date());
student.setEmail("123@123.com");
student.setName("test");
//studentService.createUser(student);
//studentService.getByPage(1,2);
// | // Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/model/Class.java
// public class Class implements Serializable {
//
// private int id;
//
// private String className;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getClassName() {
// return className;
// }
//
// public void setClassName(String className) {
// this.className = className;
// }
// }
//
// Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/model/Student.java
// public class Student implements Serializable {
// private Integer id;
//
// private String name;
//
// private String email;
//
// private Integer age;
//
// private Date birthday;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public Integer getAge() {
// return age;
// }
//
// public void setAge(Integer age) {
// this.age = age;
// }
//
// public Date getBirthday() {
// return birthday;
// }
//
// public void setBirthday(Date birthday) {
// this.birthday = birthday;
// }
// }
//
// Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/service/ClassService.java
// @Service
// public class ClassService {
//
// @Autowired
// private ClassMapper classMapper;
//
// @Transactional
// public boolean createClass(Class c) {
// classMapper.insert(c);
// return true;
// }
// }
//
// Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/service/StudentService.java
// @Service
// public class StudentService {
//
// @Autowired
// private StudentMapper studentMapper;
//
// @Transactional
// @TargetDataSource(dataSource = "writeDataSource")
// public boolean createUser(Student student) {
// studentMapper.insert(student);
//
// //事务测试
// // int i = 1 / 0;
// return true;
// }
//
// @TargetDataSource(dataSource = "read1DataSource")
// public List<Student> getByPage(int page, int rows) {
// Page<Student> studentPage = PageHelper.startPage(page, rows, true);
// List<Student> students = studentMapper.getBypage();
// System.out.println("-------------------" + studentPage.toString() + "-----------");
// return students;
// }
// }
// Path: SpringBoot-Druid/src/main/java/com/App.java
import com.lengchuan.springBoot.druid.model.Class;
import com.lengchuan.springBoot.druid.model.Student;
import com.lengchuan.springBoot.druid.service.ClassService;
import com.lengchuan.springBoot.druid.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import java.util.Date;
package com;
/**
* @author lengchuan <lishuijun1992@gmail.com>
* @date 17-4-4
*/
@SpringBootApplication
@ServletComponentScan("com.lengchuan.springBoot.dataSource.monitor")//扫描servlet配置
public class App implements CommandLineRunner {
@Autowired
private StudentService studentService;
@Autowired
private ClassService classService;
/**
* Callback used to run the bean.
*
* @param args incoming main method arguments
* @throws Exception on error
*/
public void run(String... args) throws Exception {
Student student = new Student();
student.setAge(1);
student.setBirthday(new Date());
student.setEmail("123@123.com");
student.setName("test");
//studentService.createUser(student);
//studentService.getByPage(1,2);
// | Class c = new Class(); |
Lengchuan/SpringBoot-Study | SpringBoot-Druid/src/test/java/com/lengchuan/springBoot/druid/service/StudentServiceTest.java | // Path: SpringBoot-Redis/src/test/java/com/BaseTest.java
// @RunWith(SpringJUnit4ClassRunner.class)
// @SpringBootTest(classes = App.class)
// public class BaseTest {
//
// private final static Logger logger = LoggerFactory.getLogger(BaseTest.class);
//
// @Autowired
// private UserService userService;
//
// @Test
// public void add() {
//
// User u = new User();
// u.setId(1);
// u.setName("lengchuan");
// u.setEmail("lishuijun1992@gmail.com");
//
// userService.createUser(u);
//
// }
//
// @Test
// public void get() {
//
// logger.info("获取到用户信息:{}", userService.getUser(1));
//
// }
// }
//
// Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/model/Student.java
// public class Student implements Serializable {
// private Integer id;
//
// private String name;
//
// private String email;
//
// private Integer age;
//
// private Date birthday;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public Integer getAge() {
// return age;
// }
//
// public void setAge(Integer age) {
// this.age = age;
// }
//
// public Date getBirthday() {
// return birthday;
// }
//
// public void setBirthday(Date birthday) {
// this.birthday = birthday;
// }
// }
| import com.BaseTest;
import com.lengchuan.springBoot.druid.model.Student;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Date; | package com.lengchuan.springBoot.druid.service;
/**
* @author lengchuan <lishuijun1992@gmail.com>
* @date 17-4-4
*/
public class StudentServiceTest extends BaseTest{
@Autowired
private StudentService studentService;
@Test
public void createUser() throws Exception { | // Path: SpringBoot-Redis/src/test/java/com/BaseTest.java
// @RunWith(SpringJUnit4ClassRunner.class)
// @SpringBootTest(classes = App.class)
// public class BaseTest {
//
// private final static Logger logger = LoggerFactory.getLogger(BaseTest.class);
//
// @Autowired
// private UserService userService;
//
// @Test
// public void add() {
//
// User u = new User();
// u.setId(1);
// u.setName("lengchuan");
// u.setEmail("lishuijun1992@gmail.com");
//
// userService.createUser(u);
//
// }
//
// @Test
// public void get() {
//
// logger.info("获取到用户信息:{}", userService.getUser(1));
//
// }
// }
//
// Path: SpringBoot-Druid/src/main/java/com/lengchuan/springBoot/druid/model/Student.java
// public class Student implements Serializable {
// private Integer id;
//
// private String name;
//
// private String email;
//
// private Integer age;
//
// private Date birthday;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public Integer getAge() {
// return age;
// }
//
// public void setAge(Integer age) {
// this.age = age;
// }
//
// public Date getBirthday() {
// return birthday;
// }
//
// public void setBirthday(Date birthday) {
// this.birthday = birthday;
// }
// }
// Path: SpringBoot-Druid/src/test/java/com/lengchuan/springBoot/druid/service/StudentServiceTest.java
import com.BaseTest;
import com.lengchuan.springBoot.druid.model.Student;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Date;
package com.lengchuan.springBoot.druid.service;
/**
* @author lengchuan <lishuijun1992@gmail.com>
* @date 17-4-4
*/
public class StudentServiceTest extends BaseTest{
@Autowired
private StudentService studentService;
@Test
public void createUser() throws Exception { | Student student = new Student(); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.