id stringlengths 36 36 | text stringlengths 1 1.25M |
|---|---|
72802ffa-2201-4ca2-b961-7e9f4a21987c | public static void main(String[] args) throws Exception {
RandomAccessFile file = new RandomAccessFile("/tmp/tmp.txt", "rw");
FileChannel fc = file.getChannel();
// map first 1024 bytes of file '/tmp/tmp.txt' into memory
MappedByteBuffer mbb = fc.map(FileChannel.MapMode.READ_WRITE, STAR... |
0bae280e-3cb4-4441-8cf6-b3a008914e88 | public static void main(String[] args) throws Exception {
String infile = args[0];
String outfile = args[1];
// file -> stream
FileInputStream fin = new FileInputStream(infile);
FileOutputStream fout = new FileOutputStream(outfile);
// stream -> channel
FileChan... |
3f97dfaa-9175-4c9d-ae4d-9cc684fb2813 | public ParseTreeExecutor(String expression) {
this.inputeCode = expression;
// Settings operators list, that must be lexically understood
addNewSymbols();
} |
269bee88-62b0-4d7d-85a1-73b365dd38b1 | private void addNewSymbols() {
addSymbol(new Operator("+", 20, true) {
@Override
public String execute(final Integer a, final Integer b) {
return String.valueOf(a + b);
}
@Override
public String execute(Integer a) {
// TODO Auto-generated method stub
return null;
}
});
addSymbol(ne... |
be1a1631-b44f-46f5-985f-9d75d1612c8a | @Override
public String execute(final Integer a, final Integer b) {
return String.valueOf(a + b);
} |
30aa25c2-4d9b-4474-8236-675ef4137751 | @Override
public String execute(Integer a) {
// TODO Auto-generated method stub
return null;
} |
b1a420b3-c160-4e75-9b5f-5e023ace0cc7 | @Override
public String execute(final Integer a, final Integer b) {
return String.valueOf(b - a);
} |
e96e3ce9-e35e-4923-9c0f-bc51eda30425 | @Override
public String execute(Integer a) {
// TODO Auto-generated method stub
return null;
} |
3f971200-06f8-4e06-ad5f-402cdecb97aa | @Override
public String execute(final Integer a, final Integer b) {
return String.valueOf(a * b);
} |
bb40d223-7cef-4c9b-a337-d3374ab3518a | @Override
public String execute(Integer a) {
// TODO Auto-generated method stub
return null;
} |
b7746121-d6f9-408c-a38a-ee41e3387c85 | @Override
public String execute(final Integer a, final Integer b) {
return String.valueOf(b / a);
} |
a16e9faf-1789-47da-9fad-023119a573fc | @Override
public String execute(Integer a) {
// TODO Auto-generated method stub
return null;
} |
57dd5426-f351-45b9-a06e-d7d45a9c8828 | @Override
public String execute(final Integer a, final Integer b) {
return String.valueOf(b % a);
} |
991797a5-71b3-4ce7-83d9-a2cbb1d3d590 | @Override
public String execute(Integer a) {
// TODO Auto-generated method stub
return null;
} |
852fcbf3-b76c-48c2-9645-764cfffac955 | @Override
public String execute(final Integer a, final Integer b) {
return (b > a) ? String.valueOf(1) : String.valueOf(0);
} |
17dd32a7-4f4b-4ae4-8022-151b689d45bb | @Override
public String execute(Integer a) {
// TODO Auto-generated method stub
return null;
} |
e2349df5-7697-430d-bd1d-39b5e73fee69 | @Override
public String execute(final Integer a, final Integer b) {
return (b >= a) ? String.valueOf(1) : String.valueOf(0);
} |
dc9b08ae-9bc4-4121-93a4-0a67b97b5239 | @Override
public String execute(Integer a) {
// TODO Auto-generated method stub
return null;
} |
002bc206-1187-4f37-af10-b27bbc426ed0 | @Override
public String execute(final Integer a, final Integer b) {
return (b < a) ? String.valueOf(1) : String.valueOf(0);
} |
424c03b8-96c7-4a7a-bc67-528a52f98e27 | @Override
public String execute(Integer a) {
// TODO Auto-generated method stub
return null;
} |
db0e3260-1f21-4478-9815-7312a12933ff | @Override
public String execute(final Integer a, final Integer b) {
return (b <= a) ? String.valueOf(1) : String.valueOf(0);
} |
286d791a-02d4-4ab2-9d08-dfa14432f530 | @Override
public String execute(Integer a) {
// TODO Auto-generated method stub
return null;
} |
fea666d6-152b-4fcc-a0d8-eaaf5388f3ff | @Override
public String execute(final Integer a, final Integer b) {
return (a == b) ? String.valueOf(1) : String.valueOf(0);
} |
ffa99343-c7cf-4e66-affe-9c51e27a0922 | @Override
public String execute(Integer a) {
// TODO Auto-generated method stub
return null;
} |
239c51f6-1876-40f4-92cc-984aec2da543 | @Override
public String execute(final Integer a, final Integer b) {
return (a != b) ? String.valueOf(1) : String.valueOf(0);
} |
8945f489-b5c1-4dc1-9125-e28119dfbb4a | @Override
public String execute(Integer a) {
// TODO Auto-generated method stub
return null;
} |
2222000f-db0f-4b54-84a4-ab2de9ffacfb | @Override
public String execute(final Integer a) {
if (a > 0) {
int result = 1;
for (int i = 1; i <= a; i++) {
result *= i;
}
return String.valueOf(result);
}
return "Factorial must be calculated for unsigned number";
} |
e4fc0cac-7fbf-42fe-a160-08f684cb5f45 | @Override
public String execute(Integer a, Integer b) {
// TODO Auto-generated method stub
return null;
} |
49db4661-7e4b-49ce-bb2d-1011be17e492 | private boolean isNumber(final String characterString) {
if (characterString.charAt(0) == '-' && characterString.length() == 1)
return false;
for (char character : characterString.toCharArray()) {
if (!Character.isDigit(character) && character != '-'
&& character != '.')
return false;
}
return tr... |
3ee59ebe-346b-4f4a-9f2d-85175b51488b | private List<String> parse(String expression) {
List<String> result = new ArrayList<String>();
Stack<String> stack = new Stack<String>();
InterpreterLanguageLexing tokenizer = new InterpreterLanguageLexing(
expression, operators);
while (tokenizer.hasNext()) {
String token = tokenizer.next();
if (... |
31a0a353-a354-482f-8f4c-a3ac0b6980d6 | public String execute() {
final Stack<String> stack = new Stack<String>();
for (String token : toListString()) {
if (operators.containsKey(token)) {
final String leftVar = stack.pop();
String rightVar = null;
if(stack.size() > 0) {
rightVar = stack.pop();
}
if(rightVar != null) {
... |
674d4a53-a901-4286-a724-b1e52a447c21 | public Operator addSymbol(final Operator operator) {
return operators.put(operator.getOperatorName(), operator);
} |
00ade772-cb3f-4854-a3ad-8772b8ff701a | private List<String> toListString() {
if (reversePolishNotation == null) {
reversePolishNotation = parse(this.inputeCode);
}
return reversePolishNotation;
} |
142af255-d62d-4be3-ba65-ae2211a24d97 | public static void main(String[] args) {
// NOTE: For calculating factorial, type : "0 FACTORIAL 5" where 5 is a
// number of which factorial will be calculated
ParseTreeExecutor parseTreeExecutor = new ParseTreeExecutor(
" 0 FACTORIAL 5");
System.out.println(parseTreeExecutor.execute());
} |
2ecfa908-7658-42fa-a4ae-7d401f89f393 | public static boolean isOperator(final String value) {
return checkbyPattern(value);
} |
07bea006-9228-41b5-8d88-9142eae594a0 | public static boolean isDigit(final String value) {
Pattern p = Pattern.compile(DIGITS_COLLECTION);
Matcher result = p.matcher(value);
return result.find();
} |
f41df77a-5c71-4905-93eb-cc37a45c8e64 | public static boolean isWhiteSpace(final String value) {
Pattern p = Pattern.compile(WHITESPACE);
Matcher result = p.matcher(value);
return result.find();
} |
34120a12-3e11-44a1-962e-0bbc7f5a940d | public static boolean isIdentifier(final String value) {
return (!isOperator(value) && !isWhiteSpace(value) && !isDigit(value));
} |
61fdf156-c251-4010-9451-39d9da60ea79 | private static boolean checkbyPattern(final String value) {
Pattern p = Pattern.compile(OPERATORS_COLLECTION);
boolean hasSpecialChar = p.matcher(value).find();
return hasSpecialChar;
} |
3aad2edf-066f-4a37-9025-61e02c89439d | public CustomInterpreterException(String message) {
super(message);
} |
6f48b0ab-253b-439f-a031-74402a3a09cb | public Operator(final String operatorName, int precedence, boolean leftBinded) {
this.operatorName = operatorName;
this.precedence = precedence;
this.leftBinded = leftBinded;
} |
3b4b9d7b-5907-4982-b0dc-c7aea3c44cfc | public String getOperatorName() {
return operatorName;
} |
a36e115e-9f64-43c6-a77d-6a3a2ed19117 | public int getPrecedence() {
return precedence;
} |
3aab669f-eb9d-4c19-8739-bfe87061c5f6 | public boolean isLeftBinded() {
return leftBinded;
} |
026a85eb-d74b-4ca3-b3a7-ddd0d4fe4a16 | public abstract String execute(final Integer a, final Integer b); |
9f63159a-e134-46d4-b018-d5eed82336e8 | public abstract String execute(final Integer a); |
b9452957-f753-4c4f-a980-41b2c32091fa | public InterpreterLanguageLexing(String input, Map<String, Operator> operators) {
this.input = input;
this.operators = operators;
} |
4ff4d424-2f1e-45f4-91a0-95527096f23f | @Override
public boolean hasNext() {
return (pos < input.length());
} |
6e94823b-5d56-4760-9ee8-f2c8385f6e1e | @Override
public String next() {
StringBuilder token = new StringBuilder();
if (pos >= input.length()) {
return previousToken = null;
}
char ch = input.charAt(pos);
while (Character.isWhitespace(ch) && pos < input.length()) {
ch = input.charAt(++pos);
}
if (Character.isDigit(ch)) {
w... |
68b76664-821f-419f-88b0-050f41def026 | private char hitnextCharacter() {
if (pos < (input.length() - 1)) {
return input.charAt(pos + 1);
} else {
return 0;
}
} |
f1a1375c-b5e4-4943-ab81-cfed36b8ebe5 | @Override
public void remove() {
// TODO Auto-generated method stub
} |
29f25583-9afc-47a1-94e3-f7d5bb9cbe34 | public ClojureExecutorImpl() {
// empty
} |
dd2a23c2-7d4c-4c92-beb2-59ece9bb0408 | @Override
public void executeCloverageInvoker(List<String> params) {
try {
RT.loadResourceScript(CLOJURE_INVOKER_CLJ);
} catch (IOException e) {
e.printStackTrace();
getLog().error(READING_CLJ_EXCEPTION_MSG);
return;
}
IFn cloverageInvo... |
a62b30fa-82bd-499a-92c8-f3870cc57633 | @Override
public Object executeFindNamespacesInDir(File directory) {
try {
RT.loadResourceScript(CLOJURE_INVOKER_CLJ);
} catch (IOException e) {
e.printStackTrace();
System.out.println(READING_CLJ_EXCEPTION_MSG);
return null;
}
IFn find... |
2f3c8da0-7fa2-438f-a610-da5818b652e9 | public Logger getLog() {
return log;
} |
040f6424-5234-4577-beb4-acd9a5857bb3 | public static Collection<String> getResources(
final Pattern pattern){
final ArrayList<String> retval = new ArrayList<String>();
final String classPath = System.getProperty("java.class.path", ".");
final String[] classPathElements = classPath.split(":");
for(final String element ... |
ccd5d1ef-0bed-4ddd-b002-d75a99de75d5 | private static Collection<String> getResources(
final String element,
final Pattern pattern){
final ArrayList<String> retval = new ArrayList<String>();
final File file = new File(element);
if(file.isDirectory()){
retval.addAll(getResourcesFromDirectory(file, pattern))... |
cb4fb5f2-c499-473b-a549-2c350ae851d2 | private static Collection<String> getResourcesFromJarFile(
final File file,
final Pattern pattern){
final ArrayList<String> retval = new ArrayList<String>();
ZipFile zf;
try{
zf = new ZipFile(file);
} catch(final ZipException e){
throw new Error(e)... |
041c567e-38bc-405f-b858-1bc941b3c6e0 | private static Collection<String> getResourcesFromDirectory(
final File directory,
final Pattern pattern){
final ArrayList<String> retval = new ArrayList<String>();
final File[] fileList = directory.listFiles();
for(final File file : fileList){
if(file.isDirectory()){... |
7a1a8fbd-d38c-489c-9479-7d0521038b95 | void executeCloverageInvoker(List<String> params); |
9150ea5e-063e-47f7-9a36-ee018650e34d | Object executeFindNamespacesInDir(File sourceDirectory); |
c9691d5f-2333-4377-aa9f-4d53231ab096 | private ClassLoaderUtil() {
// empty
} |
d6c68e67-f2f8-40b4-bfe0-f670f2dabe76 | @SuppressWarnings("unchecked")
public static final void setContextClassLoader(MavenProject project, Log log) {
Set<URL> urls = Sets.newHashSet();
try {
addClasspathElements(urls, project.getTestClasspathElements(), log);
addClasspathElements(urls, project.getRuntimeClasspathE... |
9e40b6da-fd97-40d1-94d5-a3eb67e0004d | private static void addClasspathElements(Set<URL> urls, List<String> classpathElements, Log log)
throws MalformedURLException {
log.debug("######################################## adding deps to classpath");
for (String element : classpathElements) {
log.debug("adding classpath e... |
414e3620-2feb-4523-ac96-5137a58fe37b | public void getClasspath(Log log) {
log.debug("GET CLASSPATH");
ClassLoader classLoader = this.getClass().getClassLoader();
Enumeration<URL> roots = null;
try {
roots = classLoader.getResources("");
} catch (IOException e) {
e.printStackTrace();
... |
6f688c1d-5f6a-4247-98fb-26d5c0e5d981 | private void printChildren(File root, Log log) {
log.debug("ROOT: " + root);
for (File file : root.listFiles()) {
if (file.isDirectory()) {
for (File childFile : file.listFiles()) {
printChildren(childFile, log);
}
} else {
... |
ca5d04b4-b0f6-484a-b226-79ab6ee84409 | private CommonUtil() {
// empty
} |
b6dc15f9-e3c9-480b-a9ef-b5b3ba4d1414 | public static String getRelativePathToProject() {
return System.getProperty(USER_DIR);
} |
904ba5b4-a184-4a6f-9ba1-c6bdbda56bf9 | public static void printOutFileContent(File testFile) {
try {
BufferedReader reader = Files.newBufferedReader(testFile.toPath(), Charset.defaultCharset());
String line;
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
... |
9e59a54f-5eba-4e2c-970d-1d9c11211f23 | private NamespaceUtil() {
// empty
} |
bea08ba0-a468-422c-b105-c45e43ae5f9f | public static List<String> getClojureNamespaces(File testSourceDirectory, File sourceDirectory) {
List<String> result = Lists.newArrayList();
List<String> testNss = getTestNamespaces(testSourceDirectory);
List<String> modifiedTestNssList = addXElementToTestNamespacesList(testNss);
resu... |
0b5bb7b4-175f-465b-b4bd-18a17263fdf4 | private static List<String> getSourcesNamespaces(File sourceDirectory) {
if (sourceDirectory == null) {
throw new IllegalArgumentException("Source directory is null!");
}
List<String> result = Lists.newArrayList();
result.addAll(getNamespacesInDir(sourceDirectory));
r... |
3ea37a35-4a2d-46ab-84b0-df5645c7cb73 | private static List<String> getTestNamespaces(File testSourceDirectory) {
if (testSourceDirectory == null) {
throw new IllegalArgumentException("Test source directory is null!");
}
List<String> result = Lists.newArrayList();
result.addAll(getNamespacesInDir(testSourceDirector... |
297e4c40-3ff4-4936-aa14-6d7854742ed1 | @SuppressWarnings("unchecked")
private static List<String> getNamespacesInDir(File sourceDirectory) {
ClojureExecutorImpl clojureExecutor = new ClojureExecutorImpl();
Object sourceNamespaces = clojureExecutor.executeFindNamespacesInDir(sourceDirectory);
if (sourceNamespaces instanceof Collec... |
a0bb4923-2b1b-44a8-a755-93f14640ade8 | private static List<String> addXElementToTestNamespacesList(List<String> testNss) {
if (testNss == null) {
throw new IllegalArgumentException("Test namespaces list cannot be null!");
}
List<String> result = Lists.newArrayList();
for (String string : testNss) {
res... |
bc416e4d-b6af-4fa4-b1a3-acc14a2d01ae | public EmmaXmlMojo() {
// empty
} |
6a950fc2-d4b4-4a05-addb-c367e4c73185 | @Override
protected void executeReport(Locale arg0) throws MavenReportException {
super.executeReport(arg0);
cloverageArgs.add("--emma-xml");
executeCloverage(cloverageArgs);
} |
5bc1fb7f-a035-4f78-a3f5-0439d55cd536 | public TextMojo() {
// empty
} |
482f4b00-60fa-4ea5-a8cf-cf2a6bc3bab5 | @Override
protected void executeReport(Locale arg0) throws MavenReportException {
super.executeReport(arg0);
cloverageArgs.add("--text");
executeCloverage(cloverageArgs);
} |
953709e6-2bd6-4cc6-928e-83e35cb4db6d | public HtmlMojo() {
// empty
} |
98a8965b-affb-49b7-a74b-b2ef69bc08b7 | @Override
protected void executeReport(Locale arg0) throws MavenReportException {
super.executeReport(arg0);
cloverageArgs.add("--html");
executeCloverage(cloverageArgs);
} |
4aca08ac-2bad-47ab-99be-957616322349 | @Override
public String getDescription(Locale arg0) {
return CLOVERAGE_REPORT_DESCRIPTION;
} |
d71e4744-43b5-436d-9564-25742c091240 | @Override
public String getName(Locale arg0) {
return CLOVERAGE_REPORT_NAME;
} |
cd5a747a-3efb-4a94-bbff-7b3b4c5be44d | @Override
public String getOutputName() {
return OUTPUT_NAME;
} |
2d17491e-d741-40ca-bf1e-434bfe74f64d | @Override
protected void executeReport(Locale arg0) throws MavenReportException {
ClassLoaderUtil.setContextClassLoader(project, getLog());
if (StringUtils.isNotBlank(getOutputDirectory())) {
cloverageArgs.add("-o");
cloverageArgs.add(getOutputDirectory());
}
} |
948fd561-0427-4375-a5b8-0332e96fa56e | @Override
public void execute() throws MojoExecutionException {
// generate report in default location
setOutputDirectory("");
super.execute();
} |
e5b509e4-6182-496b-8a1c-5c4088d0fecd | @Override
protected String getOutputDirectory() {
return outputDirectory;
} |
ad55ccb1-9c7f-4408-97b0-47ba42a8c6b2 | protected void setOutputDirectory(String outputDirectory) {
this.outputDirectory = outputDirectory;
} |
b6468e8c-0728-486b-b637-5f92162fa2c7 | @Override
protected MavenProject getProject() {
return project;
} |
e5d20942-71c4-4f09-84e1-0632495ad9f2 | @Override
protected Renderer getSiteRenderer() {
return siteRenderer;
} |
c9fc46af-0f0a-4593-a86d-78d1d97db858 | @Override
public boolean isExternalReport() {
return true;
} |
70a3f036-29e2-462e-9863-385daec4bbe0 | protected void executeCloverage(List<String> params) {
List<String> clojureProjectNamespaces = NamespaceUtil.getClojureNamespaces(clojureTestSourceDirectory,
clojureSourceDirectory);
if (!clojureProjectNamespaces.isEmpty()) {
// add parameters
clojureProjectNamesp... |
d04978b1-4896-440e-9876-c711c49d1523 | @Test
public void testExample() {
Assert.assertTrue(CommonUtil.getRelativePathToProject().endsWith("cloverage-maven-plugin"));
} |
3a5c5ee8-345f-4c4c-b798-6fd57ca7b833 | public static void main(String[] args) {
try {
GrammerAnalysis.productions = FileAccessUtil
.readProductionFromFile("H://current/grammer.txt");
OutputUtil.printProductions();
AlgorithmUtil.setCharacters();
OutputUtil.printCharacters();
for (String s : tCharacters.keySet()) {
AlgorithmUtil.se... |
c83b0c1f-0ba1-4367-9b95-d0559ac48fef | public static void printProductions() {
System.out.println("产生式:");
for (Production p : GrammerAnalysis.productions) {
System.out.println("左部:" + p.getLeft() + " 右部:" + p.getRight());
}
System.out.println();
} |
8188b1b3-ad8b-432a-971a-c929f4327290 | public static void printCharacters() {
System.out.println("非终结符:");
System.out.println(GrammerAnalysis.nCharacters.keySet());
System.out.println("终结符:");
System.out.println(GrammerAnalysis.tCharacters.keySet());
System.out.println('\n');
} |
a800d498-9ac4-4a09-8bef-1a6e5b1c2d00 | public static void printFirst() {
for (String s : GrammerAnalysis.tCharacters.keySet()) {
System.out.print("FIRST(" + s + ")" + " = ");
System.out.println(GrammerAnalysis.tCharacters.get(s).First);
}
System.out.println();
for (String s : GrammerAnalysis.nCharacters.keySet()) {
System.out.print("FIRST("... |
0ef62675-dc75-44b0-a6c1-77e1dd1950d5 | public static void printFollow() {
for (String s : GrammerAnalysis.nCharacters.keySet()) {
System.out.print("FOLLOW(" + s + ")" + " = ");
System.out.println(((NonterminalCharacter) GrammerAnalysis.nCharacters
.get(s)).Follow);
}
System.out.println();
} |
4e2120ef-aa50-4d99-a437-a73a50b6bacc | public static void printSelect() {
for (Production production : GrammerAnalysis.productions) {
System.out.print("SELECT( " + production.getLeft() + "->"
+ production.getRight() + " ) = ");
System.out.println(production.Select);
}
System.out.println();
} |
c0ea6b74-7f16-491c-aedc-7da7969a9848 | public static void printForecastTable() {
System.out.println("预测分析表:");
for (String s : GrammerAnalysis.ForecastTable.keySet()) {
System.out.println(s + ":");
System.out.print("| ");
for (String s1 : GrammerAnalysis.ForecastTable.get(s).keySet()) {
System.out.print(s1 + " => "
+ GrammerAnalysis.F... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.