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 |
|---|---|---|---|---|---|---|
Someone52/CS2-Decompiler | src/mgi/tools/jagdecs2/ast/BreakNode.java | // Path: src/mgi/tools/jagdecs2/CodePrinter.java
// public class CodePrinter {
//
// protected StringWriter writer;
// private int tabs;
//
//
// public CodePrinter() {
// writer = new StringWriter();
// tabs = 0;
// }
//
// /**
// * Method , unused by default that notifies that specific node is
// * about to be printed.
// */
// public void beginPrinting(AbstractCodeNode node) { }
//
// /**
// * Method, unused by default that notifies that specific node was
// * printed.
// */
// public void endPrinting(AbstractCodeNode node) { }
//
//
// public void print(CharSequence str) {
// for (int i = 0; i < str.length(); i++)
// print(str.charAt(i));
// }
//
// public void print(char c) {
// writer.append(c);
// if (c == '\n')
// writer.append(getTabs());
// }
//
// protected String getTabs() {
// StringBuilder tabs = new StringBuilder();
// for (int i = 0; i < this.tabs; i++)
// tabs.append('\t');
// return tabs.toString();
// }
//
// public void tab() {
// tabs++;
// }
//
// public void untab() {
// if (tabs <= 0)
// throw new RuntimeException("Not tabbed!");
// tabs--;
// }
//
// @Override
// public String toString() {
// writer.flush();
// return writer.toString();
// }
//
// public static String print(AbstractCodeNode node) {
// CodePrinter printer = new CodePrinter();
// node.print(printer);
// return printer.toString();
// }
//
// }
| import mgi.tools.jagdecs2.CodePrinter;
| /*
This program 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 3 of the License, or
(at your option) any later version.
This program 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package mgi.tools.jagdecs2.ast;
public class BreakNode extends AbstractCodeNode implements IFlowControlNode {
private IBreakableNode node;
private ScopeNode selfScope;
public BreakNode(ScopeNode selfScope, IBreakableNode node) {
this.node = node;
this.selfScope = selfScope;
// don't need to write self scope because it's just for label checks. (Not expressed).
if (this.getSelfScope().getParent() != node && node.getLabelName() == null)
node.enableLabelName();
}
@Override
public IBreakableNode getNode() {
return node;
}
public ScopeNode getSelfScope() {
return selfScope;
}
@Override
| // Path: src/mgi/tools/jagdecs2/CodePrinter.java
// public class CodePrinter {
//
// protected StringWriter writer;
// private int tabs;
//
//
// public CodePrinter() {
// writer = new StringWriter();
// tabs = 0;
// }
//
// /**
// * Method , unused by default that notifies that specific node is
// * about to be printed.
// */
// public void beginPrinting(AbstractCodeNode node) { }
//
// /**
// * Method, unused by default that notifies that specific node was
// * printed.
// */
// public void endPrinting(AbstractCodeNode node) { }
//
//
// public void print(CharSequence str) {
// for (int i = 0; i < str.length(); i++)
// print(str.charAt(i));
// }
//
// public void print(char c) {
// writer.append(c);
// if (c == '\n')
// writer.append(getTabs());
// }
//
// protected String getTabs() {
// StringBuilder tabs = new StringBuilder();
// for (int i = 0; i < this.tabs; i++)
// tabs.append('\t');
// return tabs.toString();
// }
//
// public void tab() {
// tabs++;
// }
//
// public void untab() {
// if (tabs <= 0)
// throw new RuntimeException("Not tabbed!");
// tabs--;
// }
//
// @Override
// public String toString() {
// writer.flush();
// return writer.toString();
// }
//
// public static String print(AbstractCodeNode node) {
// CodePrinter printer = new CodePrinter();
// node.print(printer);
// return printer.toString();
// }
//
// }
// Path: src/mgi/tools/jagdecs2/ast/BreakNode.java
import mgi.tools.jagdecs2.CodePrinter;
/*
This program 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 3 of the License, or
(at your option) any later version.
This program 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package mgi.tools.jagdecs2.ast;
public class BreakNode extends AbstractCodeNode implements IFlowControlNode {
private IBreakableNode node;
private ScopeNode selfScope;
public BreakNode(ScopeNode selfScope, IBreakableNode node) {
this.node = node;
this.selfScope = selfScope;
// don't need to write self scope because it's just for label checks. (Not expressed).
if (this.getSelfScope().getParent() != node && node.getLabelName() == null)
node.enableLabelName();
}
@Override
public IBreakableNode getNode() {
return node;
}
public ScopeNode getSelfScope() {
return selfScope;
}
@Override
| public void print(CodePrinter printer) {
|
Someone52/CS2-Decompiler | src/mgi/tools/jagdecs2/FlowBlocksSolver.java | // Path: src/mgi/tools/jagdecs2/util/DecompilerUtils.java
// public class DecompilerUtils {
//
// public static class SwitchCase {
// private CaseAnnotation[] annotations;
// private FlowBlock block;
//
// public SwitchCase(CaseAnnotation[] annotations,FlowBlock block) {
// this.annotations = annotations;
// this.block = block;
// }
//
// public CaseAnnotation[] getAnnotations() {
// return annotations;
// }
//
// public FlowBlock getBlock() {
// return block;
// }
//
// public void setBlock(FlowBlock block) {
// this.block = block;
// }
//
// public String toString() {
// StringBuilder bld = new StringBuilder();
// for (int i = 0; i < annotations.length; i++) {
// bld.append(annotations[i]);
// if ((i + 1) < annotations.length)
// bld.append(" AND ");
// }
// bld.append("\t GOTO flow_" + block.getBlockID());
// return bld.toString();
// }
//
// }
//
// public static SwitchCase[] makeSwitchCases(SwitchFlowBlockJump sbj) {
// SwitchCase[] buff = new SwitchCase[sbj.getCases().length];
// FlowBlock lastBlock = null;
// List<CaseAnnotation> annotations = new ArrayList<CaseAnnotation>();
// int count = 0;
// for (int i = 0; i < sbj.getCases().length; i++) {
// if (sbj.getTargets()[i] == lastBlock)
// annotations.add(sbj.getDefaultIndex() == i ? new CaseAnnotation() : new CaseAnnotation(sbj.getCases()[i]));
// else {
// if (lastBlock != null) {
// CaseAnnotation[] ann = new CaseAnnotation[annotations.size()];
// int aWrite = 0;
// for (CaseAnnotation a : annotations)
// ann[aWrite++] = a;
// buff[count++] = new SwitchCase(ann,lastBlock);
// }
// lastBlock = sbj.getTargets()[i];
// annotations.clear();
// annotations.add(sbj.getDefaultIndex() == i ? new CaseAnnotation() : new CaseAnnotation(sbj.getCases()[i]));
// }
// }
// if (lastBlock != null) {
// CaseAnnotation[] ann = new CaseAnnotation[annotations.size()];
// int aWrite = 0;
// for (CaseAnnotation a : annotations)
// ann[aWrite++] = a;
// buff[count++] = new SwitchCase(ann,lastBlock);
// }
//
// if (count == buff.length)
// return buff;
//
// SwitchCase[] full = new SwitchCase[count];
// System.arraycopy(buff, 0, full, 0, count);
// return full;
// }
//
// }
| import java.util.ArrayList;
import java.util.List;
import mgi.tools.jagdecs2.ast.*;
import mgi.tools.jagdecs2.util.DecompilerUtils;
| if (!(v0 instanceof SwitchFlowBlockJump))
return false;
SwitchFlowBlockJump sw = (SwitchFlowBlockJump)v0;
if (sw.getCases().length <= 0)
return false;
if (sw.getTargets()[0].getBlockID() <= block.getBlockID())
return false;
FlowBlock start = sw.getTargets()[0];
FlowBlock end = sw.getTargets()[sw.getTargets().length - 1];
if (start.getPrev() == null)
attachSynthethicBlockBefore(start);
if (end.getNext() == null)
attachSynthethicBlockAfter(end);
start = start.getPrev();
end = end.getNext();
main: while (true) {
List<FlowBlock> outJumps = this.getAllOutjumps(start, end);
for (FlowBlock out : outJumps) {
if (out.getBlockID() < end.getBlockID())
return false;
if (end != out) {
end = out;
continue main;
}
}
break;
}
| // Path: src/mgi/tools/jagdecs2/util/DecompilerUtils.java
// public class DecompilerUtils {
//
// public static class SwitchCase {
// private CaseAnnotation[] annotations;
// private FlowBlock block;
//
// public SwitchCase(CaseAnnotation[] annotations,FlowBlock block) {
// this.annotations = annotations;
// this.block = block;
// }
//
// public CaseAnnotation[] getAnnotations() {
// return annotations;
// }
//
// public FlowBlock getBlock() {
// return block;
// }
//
// public void setBlock(FlowBlock block) {
// this.block = block;
// }
//
// public String toString() {
// StringBuilder bld = new StringBuilder();
// for (int i = 0; i < annotations.length; i++) {
// bld.append(annotations[i]);
// if ((i + 1) < annotations.length)
// bld.append(" AND ");
// }
// bld.append("\t GOTO flow_" + block.getBlockID());
// return bld.toString();
// }
//
// }
//
// public static SwitchCase[] makeSwitchCases(SwitchFlowBlockJump sbj) {
// SwitchCase[] buff = new SwitchCase[sbj.getCases().length];
// FlowBlock lastBlock = null;
// List<CaseAnnotation> annotations = new ArrayList<CaseAnnotation>();
// int count = 0;
// for (int i = 0; i < sbj.getCases().length; i++) {
// if (sbj.getTargets()[i] == lastBlock)
// annotations.add(sbj.getDefaultIndex() == i ? new CaseAnnotation() : new CaseAnnotation(sbj.getCases()[i]));
// else {
// if (lastBlock != null) {
// CaseAnnotation[] ann = new CaseAnnotation[annotations.size()];
// int aWrite = 0;
// for (CaseAnnotation a : annotations)
// ann[aWrite++] = a;
// buff[count++] = new SwitchCase(ann,lastBlock);
// }
// lastBlock = sbj.getTargets()[i];
// annotations.clear();
// annotations.add(sbj.getDefaultIndex() == i ? new CaseAnnotation() : new CaseAnnotation(sbj.getCases()[i]));
// }
// }
// if (lastBlock != null) {
// CaseAnnotation[] ann = new CaseAnnotation[annotations.size()];
// int aWrite = 0;
// for (CaseAnnotation a : annotations)
// ann[aWrite++] = a;
// buff[count++] = new SwitchCase(ann,lastBlock);
// }
//
// if (count == buff.length)
// return buff;
//
// SwitchCase[] full = new SwitchCase[count];
// System.arraycopy(buff, 0, full, 0, count);
// return full;
// }
//
// }
// Path: src/mgi/tools/jagdecs2/FlowBlocksSolver.java
import java.util.ArrayList;
import java.util.List;
import mgi.tools.jagdecs2.ast.*;
import mgi.tools.jagdecs2.util.DecompilerUtils;
if (!(v0 instanceof SwitchFlowBlockJump))
return false;
SwitchFlowBlockJump sw = (SwitchFlowBlockJump)v0;
if (sw.getCases().length <= 0)
return false;
if (sw.getTargets()[0].getBlockID() <= block.getBlockID())
return false;
FlowBlock start = sw.getTargets()[0];
FlowBlock end = sw.getTargets()[sw.getTargets().length - 1];
if (start.getPrev() == null)
attachSynthethicBlockBefore(start);
if (end.getNext() == null)
attachSynthethicBlockAfter(end);
start = start.getPrev();
end = end.getNext();
main: while (true) {
List<FlowBlock> outJumps = this.getAllOutjumps(start, end);
for (FlowBlock out : outJumps) {
if (out.getBlockID() < end.getBlockID())
return false;
if (end != out) {
end = out;
continue main;
}
}
break;
}
| DecompilerUtils.SwitchCase[] cases = DecompilerUtils.makeSwitchCases(sw);
|
Someone52/CS2-Decompiler | src/mgi/tools/jagdecs2/ast/ArrayStoreNode.java | // Path: src/mgi/tools/jagdecs2/CodePrinter.java
// public class CodePrinter {
//
// protected StringWriter writer;
// private int tabs;
//
//
// public CodePrinter() {
// writer = new StringWriter();
// tabs = 0;
// }
//
// /**
// * Method , unused by default that notifies that specific node is
// * about to be printed.
// */
// public void beginPrinting(AbstractCodeNode node) { }
//
// /**
// * Method, unused by default that notifies that specific node was
// * printed.
// */
// public void endPrinting(AbstractCodeNode node) { }
//
//
// public void print(CharSequence str) {
// for (int i = 0; i < str.length(); i++)
// print(str.charAt(i));
// }
//
// public void print(char c) {
// writer.append(c);
// if (c == '\n')
// writer.append(getTabs());
// }
//
// protected String getTabs() {
// StringBuilder tabs = new StringBuilder();
// for (int i = 0; i < this.tabs; i++)
// tabs.append('\t');
// return tabs.toString();
// }
//
// public void tab() {
// tabs++;
// }
//
// public void untab() {
// if (tabs <= 0)
// throw new RuntimeException("Not tabbed!");
// tabs--;
// }
//
// @Override
// public String toString() {
// writer.flush();
// return writer.toString();
// }
//
// public static String print(AbstractCodeNode node) {
// CodePrinter printer = new CodePrinter();
// node.print(printer);
// return printer.toString();
// }
//
// }
| import mgi.tools.jagdecs2.CS2Type;
import mgi.tools.jagdecs2.CodePrinter;
| /*
This program 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 3 of the License, or
(at your option) any later version.
This program 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package mgi.tools.jagdecs2.ast;
public class ArrayStoreNode extends ExpressionNode {
private ExpressionNode array;
private ExpressionNode index;
private ExpressionNode value;
public ArrayStoreNode(ExpressionNode array,ExpressionNode index,ExpressionNode value) {
this.array = array;
this.index = index;
this.value = value;
this.write(array);
this.write(index);
this.write(value);
array.setParent(this);
index.setParent(this);
value.setParent(this);
}
@Override
public int getPriority() {
return ExpressionNode.PRIORITY_ASSIGNMENT;
}
@Override
public CS2Type getType() {
return value.getType();
}
@Override
public ExpressionNode copy() {
return new ArrayStoreNode(this.array.copy(), this.index.copy(), this.value.copy());
}
@Override
| // Path: src/mgi/tools/jagdecs2/CodePrinter.java
// public class CodePrinter {
//
// protected StringWriter writer;
// private int tabs;
//
//
// public CodePrinter() {
// writer = new StringWriter();
// tabs = 0;
// }
//
// /**
// * Method , unused by default that notifies that specific node is
// * about to be printed.
// */
// public void beginPrinting(AbstractCodeNode node) { }
//
// /**
// * Method, unused by default that notifies that specific node was
// * printed.
// */
// public void endPrinting(AbstractCodeNode node) { }
//
//
// public void print(CharSequence str) {
// for (int i = 0; i < str.length(); i++)
// print(str.charAt(i));
// }
//
// public void print(char c) {
// writer.append(c);
// if (c == '\n')
// writer.append(getTabs());
// }
//
// protected String getTabs() {
// StringBuilder tabs = new StringBuilder();
// for (int i = 0; i < this.tabs; i++)
// tabs.append('\t');
// return tabs.toString();
// }
//
// public void tab() {
// tabs++;
// }
//
// public void untab() {
// if (tabs <= 0)
// throw new RuntimeException("Not tabbed!");
// tabs--;
// }
//
// @Override
// public String toString() {
// writer.flush();
// return writer.toString();
// }
//
// public static String print(AbstractCodeNode node) {
// CodePrinter printer = new CodePrinter();
// node.print(printer);
// return printer.toString();
// }
//
// }
// Path: src/mgi/tools/jagdecs2/ast/ArrayStoreNode.java
import mgi.tools.jagdecs2.CS2Type;
import mgi.tools.jagdecs2.CodePrinter;
/*
This program 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 3 of the License, or
(at your option) any later version.
This program 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package mgi.tools.jagdecs2.ast;
public class ArrayStoreNode extends ExpressionNode {
private ExpressionNode array;
private ExpressionNode index;
private ExpressionNode value;
public ArrayStoreNode(ExpressionNode array,ExpressionNode index,ExpressionNode value) {
this.array = array;
this.index = index;
this.value = value;
this.write(array);
this.write(index);
this.write(value);
array.setParent(this);
index.setParent(this);
value.setParent(this);
}
@Override
public int getPriority() {
return ExpressionNode.PRIORITY_ASSIGNMENT;
}
@Override
public CS2Type getType() {
return value.getType();
}
@Override
public ExpressionNode copy() {
return new ArrayStoreNode(this.array.copy(), this.index.copy(), this.value.copy());
}
@Override
| public void print(CodePrinter printer) {
|
Someone52/CS2-Decompiler | src/mgi/tools/jagdecs2/instructions/IntInstruction.java | // Path: src/mgi/tools/jagdecs2/util/InstructionInfo.java
// public class InstructionInfo {
//
// private String name;
// private int scrampledOpcode;
// private int originalOpcode;
// private boolean hasIntConstant;
//
// public InstructionInfo(String name, int scrampledop, int originalop, boolean hasIntConstant) {
// this.name = name;
// this.scrampledOpcode = scrampledop;
// this.originalOpcode = originalop;
// this.hasIntConstant = hasIntConstant;
// }
//
// public String getName() {
// return name;
// }
//
// public int getScrampledOpcode() {
// return scrampledOpcode;
// }
//
// public int getOpcode() {
// return originalOpcode;
// }
//
// public boolean hasIntConstant() {
// return hasIntConstant;
// }
//
// @Override
// public String toString() {
// return name + "[" + originalOpcode + "," + scrampledOpcode + ":" + hasIntConstant + "]";
// }
//
// }
| import mgi.tools.jagdecs2.util.InstructionInfo;
| /*
This program 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 3 of the License, or
(at your option) any later version.
This program 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package mgi.tools.jagdecs2.instructions;
public class IntInstruction extends AbstractInstruction {
private int constant;
| // Path: src/mgi/tools/jagdecs2/util/InstructionInfo.java
// public class InstructionInfo {
//
// private String name;
// private int scrampledOpcode;
// private int originalOpcode;
// private boolean hasIntConstant;
//
// public InstructionInfo(String name, int scrampledop, int originalop, boolean hasIntConstant) {
// this.name = name;
// this.scrampledOpcode = scrampledop;
// this.originalOpcode = originalop;
// this.hasIntConstant = hasIntConstant;
// }
//
// public String getName() {
// return name;
// }
//
// public int getScrampledOpcode() {
// return scrampledOpcode;
// }
//
// public int getOpcode() {
// return originalOpcode;
// }
//
// public boolean hasIntConstant() {
// return hasIntConstant;
// }
//
// @Override
// public String toString() {
// return name + "[" + originalOpcode + "," + scrampledOpcode + ":" + hasIntConstant + "]";
// }
//
// }
// Path: src/mgi/tools/jagdecs2/instructions/IntInstruction.java
import mgi.tools.jagdecs2.util.InstructionInfo;
/*
This program 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 3 of the License, or
(at your option) any later version.
This program 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package mgi.tools.jagdecs2.instructions;
public class IntInstruction extends AbstractInstruction {
private int constant;
| public IntInstruction(InstructionInfo info, int constant) {
|
Someone52/CS2-Decompiler | src/mgi/tools/jagdecs2/ast/SwitchFlowBlockJump.java | // Path: src/mgi/tools/jagdecs2/CodePrinter.java
// public class CodePrinter {
//
// protected StringWriter writer;
// private int tabs;
//
//
// public CodePrinter() {
// writer = new StringWriter();
// tabs = 0;
// }
//
// /**
// * Method , unused by default that notifies that specific node is
// * about to be printed.
// */
// public void beginPrinting(AbstractCodeNode node) { }
//
// /**
// * Method, unused by default that notifies that specific node was
// * printed.
// */
// public void endPrinting(AbstractCodeNode node) { }
//
//
// public void print(CharSequence str) {
// for (int i = 0; i < str.length(); i++)
// print(str.charAt(i));
// }
//
// public void print(char c) {
// writer.append(c);
// if (c == '\n')
// writer.append(getTabs());
// }
//
// protected String getTabs() {
// StringBuilder tabs = new StringBuilder();
// for (int i = 0; i < this.tabs; i++)
// tabs.append('\t');
// return tabs.toString();
// }
//
// public void tab() {
// tabs++;
// }
//
// public void untab() {
// if (tabs <= 0)
// throw new RuntimeException("Not tabbed!");
// tabs--;
// }
//
// @Override
// public String toString() {
// writer.flush();
// return writer.toString();
// }
//
// public static String print(AbstractCodeNode node) {
// CodePrinter printer = new CodePrinter();
// node.print(printer);
// return printer.toString();
// }
//
// }
| import mgi.tools.jagdecs2.CodePrinter;
| /*
This program 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 3 of the License, or
(at your option) any later version.
This program 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package mgi.tools.jagdecs2.ast;
public class SwitchFlowBlockJump extends AbstractCodeNode {
private ExpressionNode expression;
private int[] cases;
private FlowBlock[] targets;
private int defaultIndex;
public SwitchFlowBlockJump(ExpressionNode expr,int[] cases, FlowBlock[] targets, int defaultIndex) {
this.expression = expr;
this.cases = cases;
this.targets = targets;
this.defaultIndex = defaultIndex;
this.write(expr);
expr.setParent(this);
}
public ExpressionNode getExpression() {
return expression;
}
public int[] getCases() {
return cases;
}
public FlowBlock[] getTargets() {
return targets;
}
public int getDefaultIndex() {
return defaultIndex;
}
@Override
| // Path: src/mgi/tools/jagdecs2/CodePrinter.java
// public class CodePrinter {
//
// protected StringWriter writer;
// private int tabs;
//
//
// public CodePrinter() {
// writer = new StringWriter();
// tabs = 0;
// }
//
// /**
// * Method , unused by default that notifies that specific node is
// * about to be printed.
// */
// public void beginPrinting(AbstractCodeNode node) { }
//
// /**
// * Method, unused by default that notifies that specific node was
// * printed.
// */
// public void endPrinting(AbstractCodeNode node) { }
//
//
// public void print(CharSequence str) {
// for (int i = 0; i < str.length(); i++)
// print(str.charAt(i));
// }
//
// public void print(char c) {
// writer.append(c);
// if (c == '\n')
// writer.append(getTabs());
// }
//
// protected String getTabs() {
// StringBuilder tabs = new StringBuilder();
// for (int i = 0; i < this.tabs; i++)
// tabs.append('\t');
// return tabs.toString();
// }
//
// public void tab() {
// tabs++;
// }
//
// public void untab() {
// if (tabs <= 0)
// throw new RuntimeException("Not tabbed!");
// tabs--;
// }
//
// @Override
// public String toString() {
// writer.flush();
// return writer.toString();
// }
//
// public static String print(AbstractCodeNode node) {
// CodePrinter printer = new CodePrinter();
// node.print(printer);
// return printer.toString();
// }
//
// }
// Path: src/mgi/tools/jagdecs2/ast/SwitchFlowBlockJump.java
import mgi.tools.jagdecs2.CodePrinter;
/*
This program 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 3 of the License, or
(at your option) any later version.
This program 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package mgi.tools.jagdecs2.ast;
public class SwitchFlowBlockJump extends AbstractCodeNode {
private ExpressionNode expression;
private int[] cases;
private FlowBlock[] targets;
private int defaultIndex;
public SwitchFlowBlockJump(ExpressionNode expr,int[] cases, FlowBlock[] targets, int defaultIndex) {
this.expression = expr;
this.cases = cases;
this.targets = targets;
this.defaultIndex = defaultIndex;
this.write(expr);
expr.setParent(this);
}
public ExpressionNode getExpression() {
return expression;
}
public int[] getCases() {
return cases;
}
public FlowBlock[] getTargets() {
return targets;
}
public int getDefaultIndex() {
return defaultIndex;
}
@Override
| public void print(CodePrinter printer) {
|
Someone52/CS2-Decompiler | src/mgi/tools/jagdecs2/ast/ConditionalFlowBlockJump.java | // Path: src/mgi/tools/jagdecs2/CodePrinter.java
// public class CodePrinter {
//
// protected StringWriter writer;
// private int tabs;
//
//
// public CodePrinter() {
// writer = new StringWriter();
// tabs = 0;
// }
//
// /**
// * Method , unused by default that notifies that specific node is
// * about to be printed.
// */
// public void beginPrinting(AbstractCodeNode node) { }
//
// /**
// * Method, unused by default that notifies that specific node was
// * printed.
// */
// public void endPrinting(AbstractCodeNode node) { }
//
//
// public void print(CharSequence str) {
// for (int i = 0; i < str.length(); i++)
// print(str.charAt(i));
// }
//
// public void print(char c) {
// writer.append(c);
// if (c == '\n')
// writer.append(getTabs());
// }
//
// protected String getTabs() {
// StringBuilder tabs = new StringBuilder();
// for (int i = 0; i < this.tabs; i++)
// tabs.append('\t');
// return tabs.toString();
// }
//
// public void tab() {
// tabs++;
// }
//
// public void untab() {
// if (tabs <= 0)
// throw new RuntimeException("Not tabbed!");
// tabs--;
// }
//
// @Override
// public String toString() {
// writer.flush();
// return writer.toString();
// }
//
// public static String print(AbstractCodeNode node) {
// CodePrinter printer = new CodePrinter();
// node.print(printer);
// return printer.toString();
// }
//
// }
| import mgi.tools.jagdecs2.CodePrinter;
| /*
This program 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 3 of the License, or
(at your option) any later version.
This program 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package mgi.tools.jagdecs2.ast;
public class ConditionalFlowBlockJump extends AbstractCodeNode {
/**
* Contains expression which type is boolean.
*/
private ExpressionNode expression;
/**
* Contains target flow block.
*/
private FlowBlock target;
public ConditionalFlowBlockJump(ExpressionNode expr,FlowBlock target) {
this.expression = expr;
this.target = target;
this.write(expr);
expr.setParent(this);
}
public ExpressionNode getExpression() {
return expression;
}
public FlowBlock getTarget() {
return target;
}
@Override
| // Path: src/mgi/tools/jagdecs2/CodePrinter.java
// public class CodePrinter {
//
// protected StringWriter writer;
// private int tabs;
//
//
// public CodePrinter() {
// writer = new StringWriter();
// tabs = 0;
// }
//
// /**
// * Method , unused by default that notifies that specific node is
// * about to be printed.
// */
// public void beginPrinting(AbstractCodeNode node) { }
//
// /**
// * Method, unused by default that notifies that specific node was
// * printed.
// */
// public void endPrinting(AbstractCodeNode node) { }
//
//
// public void print(CharSequence str) {
// for (int i = 0; i < str.length(); i++)
// print(str.charAt(i));
// }
//
// public void print(char c) {
// writer.append(c);
// if (c == '\n')
// writer.append(getTabs());
// }
//
// protected String getTabs() {
// StringBuilder tabs = new StringBuilder();
// for (int i = 0; i < this.tabs; i++)
// tabs.append('\t');
// return tabs.toString();
// }
//
// public void tab() {
// tabs++;
// }
//
// public void untab() {
// if (tabs <= 0)
// throw new RuntimeException("Not tabbed!");
// tabs--;
// }
//
// @Override
// public String toString() {
// writer.flush();
// return writer.toString();
// }
//
// public static String print(AbstractCodeNode node) {
// CodePrinter printer = new CodePrinter();
// node.print(printer);
// return printer.toString();
// }
//
// }
// Path: src/mgi/tools/jagdecs2/ast/ConditionalFlowBlockJump.java
import mgi.tools.jagdecs2.CodePrinter;
/*
This program 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 3 of the License, or
(at your option) any later version.
This program 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package mgi.tools.jagdecs2.ast;
public class ConditionalFlowBlockJump extends AbstractCodeNode {
/**
* Contains expression which type is boolean.
*/
private ExpressionNode expression;
/**
* Contains target flow block.
*/
private FlowBlock target;
public ConditionalFlowBlockJump(ExpressionNode expr,FlowBlock target) {
this.expression = expr;
this.target = target;
this.write(expr);
expr.setParent(this);
}
public ExpressionNode getExpression() {
return expression;
}
public FlowBlock getTarget() {
return target;
}
@Override
| public void print(CodePrinter printer) {
|
Someone52/CS2-Decompiler | src/mgi/tools/jagdecs2/instructions/StringInstruction.java | // Path: src/mgi/tools/jagdecs2/util/InstructionInfo.java
// public class InstructionInfo {
//
// private String name;
// private int scrampledOpcode;
// private int originalOpcode;
// private boolean hasIntConstant;
//
// public InstructionInfo(String name, int scrampledop, int originalop, boolean hasIntConstant) {
// this.name = name;
// this.scrampledOpcode = scrampledop;
// this.originalOpcode = originalop;
// this.hasIntConstant = hasIntConstant;
// }
//
// public String getName() {
// return name;
// }
//
// public int getScrampledOpcode() {
// return scrampledOpcode;
// }
//
// public int getOpcode() {
// return originalOpcode;
// }
//
// public boolean hasIntConstant() {
// return hasIntConstant;
// }
//
// @Override
// public String toString() {
// return name + "[" + originalOpcode + "," + scrampledOpcode + ":" + hasIntConstant + "]";
// }
//
// }
| import mgi.tools.jagdecs2.util.InstructionInfo;
| /*
This program 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 3 of the License, or
(at your option) any later version.
This program 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package mgi.tools.jagdecs2.instructions;
public class StringInstruction extends AbstractInstruction {
private String constant;
| // Path: src/mgi/tools/jagdecs2/util/InstructionInfo.java
// public class InstructionInfo {
//
// private String name;
// private int scrampledOpcode;
// private int originalOpcode;
// private boolean hasIntConstant;
//
// public InstructionInfo(String name, int scrampledop, int originalop, boolean hasIntConstant) {
// this.name = name;
// this.scrampledOpcode = scrampledop;
// this.originalOpcode = originalop;
// this.hasIntConstant = hasIntConstant;
// }
//
// public String getName() {
// return name;
// }
//
// public int getScrampledOpcode() {
// return scrampledOpcode;
// }
//
// public int getOpcode() {
// return originalOpcode;
// }
//
// public boolean hasIntConstant() {
// return hasIntConstant;
// }
//
// @Override
// public String toString() {
// return name + "[" + originalOpcode + "," + scrampledOpcode + ":" + hasIntConstant + "]";
// }
//
// }
// Path: src/mgi/tools/jagdecs2/instructions/StringInstruction.java
import mgi.tools.jagdecs2.util.InstructionInfo;
/*
This program 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 3 of the License, or
(at your option) any later version.
This program 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package mgi.tools.jagdecs2.instructions;
public class StringInstruction extends AbstractInstruction {
private String constant;
| public StringInstruction(InstructionInfo info, String constant) {
|
Someone52/CS2-Decompiler | src/mgi/tools/jagdecs2/ast/ScopeNode.java | // Path: src/mgi/tools/jagdecs2/CodePrinter.java
// public class CodePrinter {
//
// protected StringWriter writer;
// private int tabs;
//
//
// public CodePrinter() {
// writer = new StringWriter();
// tabs = 0;
// }
//
// /**
// * Method , unused by default that notifies that specific node is
// * about to be printed.
// */
// public void beginPrinting(AbstractCodeNode node) { }
//
// /**
// * Method, unused by default that notifies that specific node was
// * printed.
// */
// public void endPrinting(AbstractCodeNode node) { }
//
//
// public void print(CharSequence str) {
// for (int i = 0; i < str.length(); i++)
// print(str.charAt(i));
// }
//
// public void print(char c) {
// writer.append(c);
// if (c == '\n')
// writer.append(getTabs());
// }
//
// protected String getTabs() {
// StringBuilder tabs = new StringBuilder();
// for (int i = 0; i < this.tabs; i++)
// tabs.append('\t');
// return tabs.toString();
// }
//
// public void tab() {
// tabs++;
// }
//
// public void untab() {
// if (tabs <= 0)
// throw new RuntimeException("Not tabbed!");
// tabs--;
// }
//
// @Override
// public String toString() {
// writer.flush();
// return writer.toString();
// }
//
// public static String print(AbstractCodeNode node) {
// CodePrinter printer = new CodePrinter();
// node.print(printer);
// return printer.toString();
// }
//
// }
//
// Path: src/mgi/tools/jagdecs2/DecompilerException.java
// public class DecompilerException extends RuntimeException {
// private static final long serialVersionUID = 7195887685185051968L;
//
// public DecompilerException(String string) {
// super(string);
// }
//
// }
| import java.util.ArrayList;
import java.util.List;
import mgi.tools.jagdecs2.CodePrinter;
import mgi.tools.jagdecs2.DecompilerException;
| /*
This program 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 3 of the License, or
(at your option) any later version.
This program 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package mgi.tools.jagdecs2.ast;
public class ScopeNode extends AbstractCodeNode {
/**
* Contains scope in which this scope is
* declared or null if this scope is first.
*/
private ScopeNode parentScope;
/**
* Contains parent node or null if this scope doesn't have
* parent node.
*/
private AbstractCodeNode parent;
/**
* Contains list of declared local variables.
*/
private List<LocalVariable> declaredLocalVariables;
public ScopeNode() {
this(null);
}
public ScopeNode(ScopeNode parent) {
this.parentScope = parent;
this.declaredLocalVariables = new ArrayList<LocalVariable>();
}
/**
* Removes local variable from declared variables list.
* @param variable
* @throws DecompilerException
* If variable does not belong to this scope.
*/
| // Path: src/mgi/tools/jagdecs2/CodePrinter.java
// public class CodePrinter {
//
// protected StringWriter writer;
// private int tabs;
//
//
// public CodePrinter() {
// writer = new StringWriter();
// tabs = 0;
// }
//
// /**
// * Method , unused by default that notifies that specific node is
// * about to be printed.
// */
// public void beginPrinting(AbstractCodeNode node) { }
//
// /**
// * Method, unused by default that notifies that specific node was
// * printed.
// */
// public void endPrinting(AbstractCodeNode node) { }
//
//
// public void print(CharSequence str) {
// for (int i = 0; i < str.length(); i++)
// print(str.charAt(i));
// }
//
// public void print(char c) {
// writer.append(c);
// if (c == '\n')
// writer.append(getTabs());
// }
//
// protected String getTabs() {
// StringBuilder tabs = new StringBuilder();
// for (int i = 0; i < this.tabs; i++)
// tabs.append('\t');
// return tabs.toString();
// }
//
// public void tab() {
// tabs++;
// }
//
// public void untab() {
// if (tabs <= 0)
// throw new RuntimeException("Not tabbed!");
// tabs--;
// }
//
// @Override
// public String toString() {
// writer.flush();
// return writer.toString();
// }
//
// public static String print(AbstractCodeNode node) {
// CodePrinter printer = new CodePrinter();
// node.print(printer);
// return printer.toString();
// }
//
// }
//
// Path: src/mgi/tools/jagdecs2/DecompilerException.java
// public class DecompilerException extends RuntimeException {
// private static final long serialVersionUID = 7195887685185051968L;
//
// public DecompilerException(String string) {
// super(string);
// }
//
// }
// Path: src/mgi/tools/jagdecs2/ast/ScopeNode.java
import java.util.ArrayList;
import java.util.List;
import mgi.tools.jagdecs2.CodePrinter;
import mgi.tools.jagdecs2.DecompilerException;
/*
This program 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 3 of the License, or
(at your option) any later version.
This program 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package mgi.tools.jagdecs2.ast;
public class ScopeNode extends AbstractCodeNode {
/**
* Contains scope in which this scope is
* declared or null if this scope is first.
*/
private ScopeNode parentScope;
/**
* Contains parent node or null if this scope doesn't have
* parent node.
*/
private AbstractCodeNode parent;
/**
* Contains list of declared local variables.
*/
private List<LocalVariable> declaredLocalVariables;
public ScopeNode() {
this(null);
}
public ScopeNode(ScopeNode parent) {
this.parentScope = parent;
this.declaredLocalVariables = new ArrayList<LocalVariable>();
}
/**
* Removes local variable from declared variables list.
* @param variable
* @throws DecompilerException
* If variable does not belong to this scope.
*/
| public void undeclare(LocalVariable variable) throws DecompilerException {
|
Someone52/CS2-Decompiler | src/mgi/tools/jagdecs2/ast/ScopeNode.java | // Path: src/mgi/tools/jagdecs2/CodePrinter.java
// public class CodePrinter {
//
// protected StringWriter writer;
// private int tabs;
//
//
// public CodePrinter() {
// writer = new StringWriter();
// tabs = 0;
// }
//
// /**
// * Method , unused by default that notifies that specific node is
// * about to be printed.
// */
// public void beginPrinting(AbstractCodeNode node) { }
//
// /**
// * Method, unused by default that notifies that specific node was
// * printed.
// */
// public void endPrinting(AbstractCodeNode node) { }
//
//
// public void print(CharSequence str) {
// for (int i = 0; i < str.length(); i++)
// print(str.charAt(i));
// }
//
// public void print(char c) {
// writer.append(c);
// if (c == '\n')
// writer.append(getTabs());
// }
//
// protected String getTabs() {
// StringBuilder tabs = new StringBuilder();
// for (int i = 0; i < this.tabs; i++)
// tabs.append('\t');
// return tabs.toString();
// }
//
// public void tab() {
// tabs++;
// }
//
// public void untab() {
// if (tabs <= 0)
// throw new RuntimeException("Not tabbed!");
// tabs--;
// }
//
// @Override
// public String toString() {
// writer.flush();
// return writer.toString();
// }
//
// public static String print(AbstractCodeNode node) {
// CodePrinter printer = new CodePrinter();
// node.print(printer);
// return printer.toString();
// }
//
// }
//
// Path: src/mgi/tools/jagdecs2/DecompilerException.java
// public class DecompilerException extends RuntimeException {
// private static final long serialVersionUID = 7195887685185051968L;
//
// public DecompilerException(String string) {
// super(string);
// }
//
// }
| import java.util.ArrayList;
import java.util.List;
import mgi.tools.jagdecs2.CodePrinter;
import mgi.tools.jagdecs2.DecompilerException;
|
public void setParent(AbstractCodeNode parentInstruction) {
this.parent = parentInstruction;
}
public AbstractCodeNode getParent() {
return parent;
}
private boolean needsBraces() {
if (!(getParent() instanceof LoopNode) && !(getParent() instanceof IfElseNode))
return true;
int cElements = size();
for (int i = 0; i < cElements; i++) {
if (read(i) instanceof LoopNode || read(i) instanceof IfElseNode || read(i) instanceof SwitchNode)
return true;
}
for (LocalVariable var : this.declaredLocalVariables)
if (var.needsScopeDeclaration())
cElements++;
return cElements > 1;
}
@Override
| // Path: src/mgi/tools/jagdecs2/CodePrinter.java
// public class CodePrinter {
//
// protected StringWriter writer;
// private int tabs;
//
//
// public CodePrinter() {
// writer = new StringWriter();
// tabs = 0;
// }
//
// /**
// * Method , unused by default that notifies that specific node is
// * about to be printed.
// */
// public void beginPrinting(AbstractCodeNode node) { }
//
// /**
// * Method, unused by default that notifies that specific node was
// * printed.
// */
// public void endPrinting(AbstractCodeNode node) { }
//
//
// public void print(CharSequence str) {
// for (int i = 0; i < str.length(); i++)
// print(str.charAt(i));
// }
//
// public void print(char c) {
// writer.append(c);
// if (c == '\n')
// writer.append(getTabs());
// }
//
// protected String getTabs() {
// StringBuilder tabs = new StringBuilder();
// for (int i = 0; i < this.tabs; i++)
// tabs.append('\t');
// return tabs.toString();
// }
//
// public void tab() {
// tabs++;
// }
//
// public void untab() {
// if (tabs <= 0)
// throw new RuntimeException("Not tabbed!");
// tabs--;
// }
//
// @Override
// public String toString() {
// writer.flush();
// return writer.toString();
// }
//
// public static String print(AbstractCodeNode node) {
// CodePrinter printer = new CodePrinter();
// node.print(printer);
// return printer.toString();
// }
//
// }
//
// Path: src/mgi/tools/jagdecs2/DecompilerException.java
// public class DecompilerException extends RuntimeException {
// private static final long serialVersionUID = 7195887685185051968L;
//
// public DecompilerException(String string) {
// super(string);
// }
//
// }
// Path: src/mgi/tools/jagdecs2/ast/ScopeNode.java
import java.util.ArrayList;
import java.util.List;
import mgi.tools.jagdecs2.CodePrinter;
import mgi.tools.jagdecs2.DecompilerException;
public void setParent(AbstractCodeNode parentInstruction) {
this.parent = parentInstruction;
}
public AbstractCodeNode getParent() {
return parent;
}
private boolean needsBraces() {
if (!(getParent() instanceof LoopNode) && !(getParent() instanceof IfElseNode))
return true;
int cElements = size();
for (int i = 0; i < cElements; i++) {
if (read(i) instanceof LoopNode || read(i) instanceof IfElseNode || read(i) instanceof SwitchNode)
return true;
}
for (LocalVariable var : this.declaredLocalVariables)
if (var.needsScopeDeclaration())
cElements++;
return cElements > 1;
}
@Override
| public void print(CodePrinter printer) {
|
Someone52/CS2-Decompiler | src/mgi/tools/jagdecs2/ast/ReturnNode.java | // Path: src/mgi/tools/jagdecs2/CodePrinter.java
// public class CodePrinter {
//
// protected StringWriter writer;
// private int tabs;
//
//
// public CodePrinter() {
// writer = new StringWriter();
// tabs = 0;
// }
//
// /**
// * Method , unused by default that notifies that specific node is
// * about to be printed.
// */
// public void beginPrinting(AbstractCodeNode node) { }
//
// /**
// * Method, unused by default that notifies that specific node was
// * printed.
// */
// public void endPrinting(AbstractCodeNode node) { }
//
//
// public void print(CharSequence str) {
// for (int i = 0; i < str.length(); i++)
// print(str.charAt(i));
// }
//
// public void print(char c) {
// writer.append(c);
// if (c == '\n')
// writer.append(getTabs());
// }
//
// protected String getTabs() {
// StringBuilder tabs = new StringBuilder();
// for (int i = 0; i < this.tabs; i++)
// tabs.append('\t');
// return tabs.toString();
// }
//
// public void tab() {
// tabs++;
// }
//
// public void untab() {
// if (tabs <= 0)
// throw new RuntimeException("Not tabbed!");
// tabs--;
// }
//
// @Override
// public String toString() {
// writer.flush();
// return writer.toString();
// }
//
// public static String print(AbstractCodeNode node) {
// CodePrinter printer = new CodePrinter();
// node.print(printer);
// return printer.toString();
// }
//
// }
| import mgi.tools.jagdecs2.CodePrinter;
| /*
This program 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 3 of the License, or
(at your option) any later version.
This program 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package mgi.tools.jagdecs2.ast;
public class ReturnNode extends AbstractCodeNode {
/**
* Contains return expression.
*/
private ExpressionNode expression;
public ReturnNode() {
this(null);
}
public ReturnNode(ExpressionNode expr) {
this.expression = expr;
if (expr != null) {
this.write(expr);
expr.setParent(this);
}
}
public ExpressionNode getExpression() {
return expression;
}
@Override
| // Path: src/mgi/tools/jagdecs2/CodePrinter.java
// public class CodePrinter {
//
// protected StringWriter writer;
// private int tabs;
//
//
// public CodePrinter() {
// writer = new StringWriter();
// tabs = 0;
// }
//
// /**
// * Method , unused by default that notifies that specific node is
// * about to be printed.
// */
// public void beginPrinting(AbstractCodeNode node) { }
//
// /**
// * Method, unused by default that notifies that specific node was
// * printed.
// */
// public void endPrinting(AbstractCodeNode node) { }
//
//
// public void print(CharSequence str) {
// for (int i = 0; i < str.length(); i++)
// print(str.charAt(i));
// }
//
// public void print(char c) {
// writer.append(c);
// if (c == '\n')
// writer.append(getTabs());
// }
//
// protected String getTabs() {
// StringBuilder tabs = new StringBuilder();
// for (int i = 0; i < this.tabs; i++)
// tabs.append('\t');
// return tabs.toString();
// }
//
// public void tab() {
// tabs++;
// }
//
// public void untab() {
// if (tabs <= 0)
// throw new RuntimeException("Not tabbed!");
// tabs--;
// }
//
// @Override
// public String toString() {
// writer.flush();
// return writer.toString();
// }
//
// public static String print(AbstractCodeNode node) {
// CodePrinter printer = new CodePrinter();
// node.print(printer);
// return printer.toString();
// }
//
// }
// Path: src/mgi/tools/jagdecs2/ast/ReturnNode.java
import mgi.tools.jagdecs2.CodePrinter;
/*
This program 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 3 of the License, or
(at your option) any later version.
This program 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package mgi.tools.jagdecs2.ast;
public class ReturnNode extends AbstractCodeNode {
/**
* Contains return expression.
*/
private ExpressionNode expression;
public ReturnNode() {
this(null);
}
public ReturnNode(ExpressionNode expr) {
this.expression = expr;
if (expr != null) {
this.write(expr);
expr.setParent(this);
}
}
public ExpressionNode getExpression() {
return expression;
}
@Override
| public void print(CodePrinter printer) {
|
Someone52/CS2-Decompiler | src/mgi/tools/jagdecs2/ast/NewArrayNode.java | // Path: src/mgi/tools/jagdecs2/CodePrinter.java
// public class CodePrinter {
//
// protected StringWriter writer;
// private int tabs;
//
//
// public CodePrinter() {
// writer = new StringWriter();
// tabs = 0;
// }
//
// /**
// * Method , unused by default that notifies that specific node is
// * about to be printed.
// */
// public void beginPrinting(AbstractCodeNode node) { }
//
// /**
// * Method, unused by default that notifies that specific node was
// * printed.
// */
// public void endPrinting(AbstractCodeNode node) { }
//
//
// public void print(CharSequence str) {
// for (int i = 0; i < str.length(); i++)
// print(str.charAt(i));
// }
//
// public void print(char c) {
// writer.append(c);
// if (c == '\n')
// writer.append(getTabs());
// }
//
// protected String getTabs() {
// StringBuilder tabs = new StringBuilder();
// for (int i = 0; i < this.tabs; i++)
// tabs.append('\t');
// return tabs.toString();
// }
//
// public void tab() {
// tabs++;
// }
//
// public void untab() {
// if (tabs <= 0)
// throw new RuntimeException("Not tabbed!");
// tabs--;
// }
//
// @Override
// public String toString() {
// writer.flush();
// return writer.toString();
// }
//
// public static String print(AbstractCodeNode node) {
// CodePrinter printer = new CodePrinter();
// node.print(printer);
// return printer.toString();
// }
//
// }
| import mgi.tools.jagdecs2.CS2Type;
import mgi.tools.jagdecs2.CodePrinter;
| /*
This program 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 3 of the License, or
(at your option) any later version.
This program 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package mgi.tools.jagdecs2.ast;
public class NewArrayNode extends ExpressionNode {
private ExpressionNode expression;
private CS2Type type;
public NewArrayNode(ExpressionNode expr,CS2Type type) {
this.expression = expr;
this.type = type;
this.write(expr);
expr.setParent(this);
}
@Override
public int getPriority() {
return ExpressionNode.PRIORITY_ARRAY_INDEX;
}
@Override
public CS2Type getType() {
return this.type;
}
@Override
public ExpressionNode copy() {
return new NewArrayNode(this.expression.copy(),this.type);
}
public ExpressionNode getExpression() {
return expression;
}
@Override
| // Path: src/mgi/tools/jagdecs2/CodePrinter.java
// public class CodePrinter {
//
// protected StringWriter writer;
// private int tabs;
//
//
// public CodePrinter() {
// writer = new StringWriter();
// tabs = 0;
// }
//
// /**
// * Method , unused by default that notifies that specific node is
// * about to be printed.
// */
// public void beginPrinting(AbstractCodeNode node) { }
//
// /**
// * Method, unused by default that notifies that specific node was
// * printed.
// */
// public void endPrinting(AbstractCodeNode node) { }
//
//
// public void print(CharSequence str) {
// for (int i = 0; i < str.length(); i++)
// print(str.charAt(i));
// }
//
// public void print(char c) {
// writer.append(c);
// if (c == '\n')
// writer.append(getTabs());
// }
//
// protected String getTabs() {
// StringBuilder tabs = new StringBuilder();
// for (int i = 0; i < this.tabs; i++)
// tabs.append('\t');
// return tabs.toString();
// }
//
// public void tab() {
// tabs++;
// }
//
// public void untab() {
// if (tabs <= 0)
// throw new RuntimeException("Not tabbed!");
// tabs--;
// }
//
// @Override
// public String toString() {
// writer.flush();
// return writer.toString();
// }
//
// public static String print(AbstractCodeNode node) {
// CodePrinter printer = new CodePrinter();
// node.print(printer);
// return printer.toString();
// }
//
// }
// Path: src/mgi/tools/jagdecs2/ast/NewArrayNode.java
import mgi.tools.jagdecs2.CS2Type;
import mgi.tools.jagdecs2.CodePrinter;
/*
This program 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 3 of the License, or
(at your option) any later version.
This program 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package mgi.tools.jagdecs2.ast;
public class NewArrayNode extends ExpressionNode {
private ExpressionNode expression;
private CS2Type type;
public NewArrayNode(ExpressionNode expr,CS2Type type) {
this.expression = expr;
this.type = type;
this.write(expr);
expr.setParent(this);
}
@Override
public int getPriority() {
return ExpressionNode.PRIORITY_ARRAY_INDEX;
}
@Override
public CS2Type getType() {
return this.type;
}
@Override
public ExpressionNode copy() {
return new NewArrayNode(this.expression.copy(),this.type);
}
public ExpressionNode getExpression() {
return expression;
}
@Override
| public void print(CodePrinter printer) {
|
Someone52/CS2-Decompiler | src/mgi/tools/jagdecs2/ast/LoadNamedDataNode.java | // Path: src/mgi/tools/jagdecs2/CodePrinter.java
// public class CodePrinter {
//
// protected StringWriter writer;
// private int tabs;
//
//
// public CodePrinter() {
// writer = new StringWriter();
// tabs = 0;
// }
//
// /**
// * Method , unused by default that notifies that specific node is
// * about to be printed.
// */
// public void beginPrinting(AbstractCodeNode node) { }
//
// /**
// * Method, unused by default that notifies that specific node was
// * printed.
// */
// public void endPrinting(AbstractCodeNode node) { }
//
//
// public void print(CharSequence str) {
// for (int i = 0; i < str.length(); i++)
// print(str.charAt(i));
// }
//
// public void print(char c) {
// writer.append(c);
// if (c == '\n')
// writer.append(getTabs());
// }
//
// protected String getTabs() {
// StringBuilder tabs = new StringBuilder();
// for (int i = 0; i < this.tabs; i++)
// tabs.append('\t');
// return tabs.toString();
// }
//
// public void tab() {
// tabs++;
// }
//
// public void untab() {
// if (tabs <= 0)
// throw new RuntimeException("Not tabbed!");
// tabs--;
// }
//
// @Override
// public String toString() {
// writer.flush();
// return writer.toString();
// }
//
// public static String print(AbstractCodeNode node) {
// CodePrinter printer = new CodePrinter();
// node.print(printer);
// return printer.toString();
// }
//
// }
| import mgi.tools.jagdecs2.CS2Type;
import mgi.tools.jagdecs2.CodePrinter;
| /*
This program 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 3 of the License, or
(at your option) any later version.
This program 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package mgi.tools.jagdecs2.ast;
public class LoadNamedDataNode extends ExpressionNode {
private String name;
private CS2Type type;
public LoadNamedDataNode(String name, CS2Type type) {
this.name = name;
this.type = type;
}
@Override
public int getPriority() {
return ExpressionNode.PRIORITY_STANDART;
}
@Override
public CS2Type getType() {
return type;
}
@Override
public ExpressionNode copy() {
return new LoadNamedDataNode(this.name,this.type);
}
public String getName() {
return name;
}
@Override
| // Path: src/mgi/tools/jagdecs2/CodePrinter.java
// public class CodePrinter {
//
// protected StringWriter writer;
// private int tabs;
//
//
// public CodePrinter() {
// writer = new StringWriter();
// tabs = 0;
// }
//
// /**
// * Method , unused by default that notifies that specific node is
// * about to be printed.
// */
// public void beginPrinting(AbstractCodeNode node) { }
//
// /**
// * Method, unused by default that notifies that specific node was
// * printed.
// */
// public void endPrinting(AbstractCodeNode node) { }
//
//
// public void print(CharSequence str) {
// for (int i = 0; i < str.length(); i++)
// print(str.charAt(i));
// }
//
// public void print(char c) {
// writer.append(c);
// if (c == '\n')
// writer.append(getTabs());
// }
//
// protected String getTabs() {
// StringBuilder tabs = new StringBuilder();
// for (int i = 0; i < this.tabs; i++)
// tabs.append('\t');
// return tabs.toString();
// }
//
// public void tab() {
// tabs++;
// }
//
// public void untab() {
// if (tabs <= 0)
// throw new RuntimeException("Not tabbed!");
// tabs--;
// }
//
// @Override
// public String toString() {
// writer.flush();
// return writer.toString();
// }
//
// public static String print(AbstractCodeNode node) {
// CodePrinter printer = new CodePrinter();
// node.print(printer);
// return printer.toString();
// }
//
// }
// Path: src/mgi/tools/jagdecs2/ast/LoadNamedDataNode.java
import mgi.tools.jagdecs2.CS2Type;
import mgi.tools.jagdecs2.CodePrinter;
/*
This program 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 3 of the License, or
(at your option) any later version.
This program 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package mgi.tools.jagdecs2.ast;
public class LoadNamedDataNode extends ExpressionNode {
private String name;
private CS2Type type;
public LoadNamedDataNode(String name, CS2Type type) {
this.name = name;
this.type = type;
}
@Override
public int getPriority() {
return ExpressionNode.PRIORITY_STANDART;
}
@Override
public CS2Type getType() {
return type;
}
@Override
public ExpressionNode copy() {
return new LoadNamedDataNode(this.name,this.type);
}
public String getName() {
return name;
}
@Override
| public void print(CodePrinter printer) {
|
Someone52/CS2-Decompiler | src/mgi/tools/jagdecs2/ast/CaseAnnotation.java | // Path: src/mgi/tools/jagdecs2/CodePrinter.java
// public class CodePrinter {
//
// protected StringWriter writer;
// private int tabs;
//
//
// public CodePrinter() {
// writer = new StringWriter();
// tabs = 0;
// }
//
// /**
// * Method , unused by default that notifies that specific node is
// * about to be printed.
// */
// public void beginPrinting(AbstractCodeNode node) { }
//
// /**
// * Method, unused by default that notifies that specific node was
// * printed.
// */
// public void endPrinting(AbstractCodeNode node) { }
//
//
// public void print(CharSequence str) {
// for (int i = 0; i < str.length(); i++)
// print(str.charAt(i));
// }
//
// public void print(char c) {
// writer.append(c);
// if (c == '\n')
// writer.append(getTabs());
// }
//
// protected String getTabs() {
// StringBuilder tabs = new StringBuilder();
// for (int i = 0; i < this.tabs; i++)
// tabs.append('\t');
// return tabs.toString();
// }
//
// public void tab() {
// tabs++;
// }
//
// public void untab() {
// if (tabs <= 0)
// throw new RuntimeException("Not tabbed!");
// tabs--;
// }
//
// @Override
// public String toString() {
// writer.flush();
// return writer.toString();
// }
//
// public static String print(AbstractCodeNode node) {
// CodePrinter printer = new CodePrinter();
// node.print(printer);
// return printer.toString();
// }
//
// }
| import mgi.tools.jagdecs2.CodePrinter;
| /*
This program 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 3 of the License, or
(at your option) any later version.
This program 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package mgi.tools.jagdecs2.ast;
public class CaseAnnotation extends AbstractCodeNode {
private int caseNumber;
private boolean isDefault;
public CaseAnnotation(int caseNumber) {
this.caseNumber = caseNumber;
this.isDefault = false;
}
public CaseAnnotation() {
this.caseNumber = 0;
this.isDefault = true;
}
public int getCaseNumber() {
return caseNumber;
}
public boolean isDefault() {
return isDefault;
}
@Override
| // Path: src/mgi/tools/jagdecs2/CodePrinter.java
// public class CodePrinter {
//
// protected StringWriter writer;
// private int tabs;
//
//
// public CodePrinter() {
// writer = new StringWriter();
// tabs = 0;
// }
//
// /**
// * Method , unused by default that notifies that specific node is
// * about to be printed.
// */
// public void beginPrinting(AbstractCodeNode node) { }
//
// /**
// * Method, unused by default that notifies that specific node was
// * printed.
// */
// public void endPrinting(AbstractCodeNode node) { }
//
//
// public void print(CharSequence str) {
// for (int i = 0; i < str.length(); i++)
// print(str.charAt(i));
// }
//
// public void print(char c) {
// writer.append(c);
// if (c == '\n')
// writer.append(getTabs());
// }
//
// protected String getTabs() {
// StringBuilder tabs = new StringBuilder();
// for (int i = 0; i < this.tabs; i++)
// tabs.append('\t');
// return tabs.toString();
// }
//
// public void tab() {
// tabs++;
// }
//
// public void untab() {
// if (tabs <= 0)
// throw new RuntimeException("Not tabbed!");
// tabs--;
// }
//
// @Override
// public String toString() {
// writer.flush();
// return writer.toString();
// }
//
// public static String print(AbstractCodeNode node) {
// CodePrinter printer = new CodePrinter();
// node.print(printer);
// return printer.toString();
// }
//
// }
// Path: src/mgi/tools/jagdecs2/ast/CaseAnnotation.java
import mgi.tools.jagdecs2.CodePrinter;
/*
This program 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 3 of the License, or
(at your option) any later version.
This program 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package mgi.tools.jagdecs2.ast;
public class CaseAnnotation extends AbstractCodeNode {
private int caseNumber;
private boolean isDefault;
public CaseAnnotation(int caseNumber) {
this.caseNumber = caseNumber;
this.isDefault = false;
}
public CaseAnnotation() {
this.caseNumber = 0;
this.isDefault = true;
}
public int getCaseNumber() {
return caseNumber;
}
public boolean isDefault() {
return isDefault;
}
@Override
| public void print(CodePrinter printer) {
|
Someone52/CS2-Decompiler | src/mgi/tools/jagdecs2/instructions/JumpInstruction.java | // Path: src/mgi/tools/jagdecs2/util/InstructionInfo.java
// public class InstructionInfo {
//
// private String name;
// private int scrampledOpcode;
// private int originalOpcode;
// private boolean hasIntConstant;
//
// public InstructionInfo(String name, int scrampledop, int originalop, boolean hasIntConstant) {
// this.name = name;
// this.scrampledOpcode = scrampledop;
// this.originalOpcode = originalop;
// this.hasIntConstant = hasIntConstant;
// }
//
// public String getName() {
// return name;
// }
//
// public int getScrampledOpcode() {
// return scrampledOpcode;
// }
//
// public int getOpcode() {
// return originalOpcode;
// }
//
// public boolean hasIntConstant() {
// return hasIntConstant;
// }
//
// @Override
// public String toString() {
// return name + "[" + originalOpcode + "," + scrampledOpcode + ":" + hasIntConstant + "]";
// }
//
// }
| import mgi.tools.jagdecs2.util.InstructionInfo;
| /*
This program 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 3 of the License, or
(at your option) any later version.
This program 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package mgi.tools.jagdecs2.instructions;
public class JumpInstruction extends AbstractInstruction {
private Label target;
| // Path: src/mgi/tools/jagdecs2/util/InstructionInfo.java
// public class InstructionInfo {
//
// private String name;
// private int scrampledOpcode;
// private int originalOpcode;
// private boolean hasIntConstant;
//
// public InstructionInfo(String name, int scrampledop, int originalop, boolean hasIntConstant) {
// this.name = name;
// this.scrampledOpcode = scrampledop;
// this.originalOpcode = originalop;
// this.hasIntConstant = hasIntConstant;
// }
//
// public String getName() {
// return name;
// }
//
// public int getScrampledOpcode() {
// return scrampledOpcode;
// }
//
// public int getOpcode() {
// return originalOpcode;
// }
//
// public boolean hasIntConstant() {
// return hasIntConstant;
// }
//
// @Override
// public String toString() {
// return name + "[" + originalOpcode + "," + scrampledOpcode + ":" + hasIntConstant + "]";
// }
//
// }
// Path: src/mgi/tools/jagdecs2/instructions/JumpInstruction.java
import mgi.tools.jagdecs2.util.InstructionInfo;
/*
This program 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 3 of the License, or
(at your option) any later version.
This program 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package mgi.tools.jagdecs2.instructions;
public class JumpInstruction extends AbstractInstruction {
private Label target;
| public JumpInstruction(InstructionInfo info, Label target) {
|
Someone52/CS2-Decompiler | src/mgi/tools/jagdecs2/ast/IntExpressionNode.java | // Path: src/mgi/tools/jagdecs2/CodePrinter.java
// public class CodePrinter {
//
// protected StringWriter writer;
// private int tabs;
//
//
// public CodePrinter() {
// writer = new StringWriter();
// tabs = 0;
// }
//
// /**
// * Method , unused by default that notifies that specific node is
// * about to be printed.
// */
// public void beginPrinting(AbstractCodeNode node) { }
//
// /**
// * Method, unused by default that notifies that specific node was
// * printed.
// */
// public void endPrinting(AbstractCodeNode node) { }
//
//
// public void print(CharSequence str) {
// for (int i = 0; i < str.length(); i++)
// print(str.charAt(i));
// }
//
// public void print(char c) {
// writer.append(c);
// if (c == '\n')
// writer.append(getTabs());
// }
//
// protected String getTabs() {
// StringBuilder tabs = new StringBuilder();
// for (int i = 0; i < this.tabs; i++)
// tabs.append('\t');
// return tabs.toString();
// }
//
// public void tab() {
// tabs++;
// }
//
// public void untab() {
// if (tabs <= 0)
// throw new RuntimeException("Not tabbed!");
// tabs--;
// }
//
// @Override
// public String toString() {
// writer.flush();
// return writer.toString();
// }
//
// public static String print(AbstractCodeNode node) {
// CodePrinter printer = new CodePrinter();
// node.print(printer);
// return printer.toString();
// }
//
// }
| import mgi.tools.jagdecs2.CS2Type;
import mgi.tools.jagdecs2.CodePrinter;
| /*
This program 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 3 of the License, or
(at your option) any later version.
This program 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package mgi.tools.jagdecs2.ast;
public class IntExpressionNode extends ExpressionNode implements IConstantNode {
/**
* Contains int which this expression holds.
*/
private int data;
public IntExpressionNode(int data) {
this.data = data;
}
public int getData() {
return data;
}
@Override
public CS2Type getType() {
return CS2Type.INT;
}
@Override
public Object getConst() {
return this.data;
}
@Override
public ExpressionNode copy() {
return new IntExpressionNode(this.data);
}
@Override
| // Path: src/mgi/tools/jagdecs2/CodePrinter.java
// public class CodePrinter {
//
// protected StringWriter writer;
// private int tabs;
//
//
// public CodePrinter() {
// writer = new StringWriter();
// tabs = 0;
// }
//
// /**
// * Method , unused by default that notifies that specific node is
// * about to be printed.
// */
// public void beginPrinting(AbstractCodeNode node) { }
//
// /**
// * Method, unused by default that notifies that specific node was
// * printed.
// */
// public void endPrinting(AbstractCodeNode node) { }
//
//
// public void print(CharSequence str) {
// for (int i = 0; i < str.length(); i++)
// print(str.charAt(i));
// }
//
// public void print(char c) {
// writer.append(c);
// if (c == '\n')
// writer.append(getTabs());
// }
//
// protected String getTabs() {
// StringBuilder tabs = new StringBuilder();
// for (int i = 0; i < this.tabs; i++)
// tabs.append('\t');
// return tabs.toString();
// }
//
// public void tab() {
// tabs++;
// }
//
// public void untab() {
// if (tabs <= 0)
// throw new RuntimeException("Not tabbed!");
// tabs--;
// }
//
// @Override
// public String toString() {
// writer.flush();
// return writer.toString();
// }
//
// public static String print(AbstractCodeNode node) {
// CodePrinter printer = new CodePrinter();
// node.print(printer);
// return printer.toString();
// }
//
// }
// Path: src/mgi/tools/jagdecs2/ast/IntExpressionNode.java
import mgi.tools.jagdecs2.CS2Type;
import mgi.tools.jagdecs2.CodePrinter;
/*
This program 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 3 of the License, or
(at your option) any later version.
This program 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package mgi.tools.jagdecs2.ast;
public class IntExpressionNode extends ExpressionNode implements IConstantNode {
/**
* Contains int which this expression holds.
*/
private int data;
public IntExpressionNode(int data) {
this.data = data;
}
public int getData() {
return data;
}
@Override
public CS2Type getType() {
return CS2Type.INT;
}
@Override
public Object getConst() {
return this.data;
}
@Override
public ExpressionNode copy() {
return new IntExpressionNode(this.data);
}
@Override
| public void print(CodePrinter printer) {
|
Someone52/CS2-Decompiler | src/mgi/tools/jagdecs2/ast/FunctionNode.java | // Path: src/mgi/tools/jagdecs2/CodePrinter.java
// public class CodePrinter {
//
// protected StringWriter writer;
// private int tabs;
//
//
// public CodePrinter() {
// writer = new StringWriter();
// tabs = 0;
// }
//
// /**
// * Method , unused by default that notifies that specific node is
// * about to be printed.
// */
// public void beginPrinting(AbstractCodeNode node) { }
//
// /**
// * Method, unused by default that notifies that specific node was
// * printed.
// */
// public void endPrinting(AbstractCodeNode node) { }
//
//
// public void print(CharSequence str) {
// for (int i = 0; i < str.length(); i++)
// print(str.charAt(i));
// }
//
// public void print(char c) {
// writer.append(c);
// if (c == '\n')
// writer.append(getTabs());
// }
//
// protected String getTabs() {
// StringBuilder tabs = new StringBuilder();
// for (int i = 0; i < this.tabs; i++)
// tabs.append('\t');
// return tabs.toString();
// }
//
// public void tab() {
// tabs++;
// }
//
// public void untab() {
// if (tabs <= 0)
// throw new RuntimeException("Not tabbed!");
// tabs--;
// }
//
// @Override
// public String toString() {
// writer.flush();
// return writer.toString();
// }
//
// public static String print(AbstractCodeNode node) {
// CodePrinter printer = new CodePrinter();
// node.print(printer);
// return printer.toString();
// }
//
// }
| import mgi.tools.jagdecs2.CS2Type;
import mgi.tools.jagdecs2.CodePrinter;
| return name;
}
public CS2Type[] getArgumentTypes() {
return argumentTypes;
}
public String[] getArgumentNames() {
return argumentNames;
}
public LocalVariable[] getArgumentLocals() {
return argumentLocals;
}
public void setReturnType(CS2Type returnType) {
this.returnType = returnType;
}
public CS2Type getReturnType() {
return returnType;
}
public ScopeNode getScope() {
return scope;
}
@Override
| // Path: src/mgi/tools/jagdecs2/CodePrinter.java
// public class CodePrinter {
//
// protected StringWriter writer;
// private int tabs;
//
//
// public CodePrinter() {
// writer = new StringWriter();
// tabs = 0;
// }
//
// /**
// * Method , unused by default that notifies that specific node is
// * about to be printed.
// */
// public void beginPrinting(AbstractCodeNode node) { }
//
// /**
// * Method, unused by default that notifies that specific node was
// * printed.
// */
// public void endPrinting(AbstractCodeNode node) { }
//
//
// public void print(CharSequence str) {
// for (int i = 0; i < str.length(); i++)
// print(str.charAt(i));
// }
//
// public void print(char c) {
// writer.append(c);
// if (c == '\n')
// writer.append(getTabs());
// }
//
// protected String getTabs() {
// StringBuilder tabs = new StringBuilder();
// for (int i = 0; i < this.tabs; i++)
// tabs.append('\t');
// return tabs.toString();
// }
//
// public void tab() {
// tabs++;
// }
//
// public void untab() {
// if (tabs <= 0)
// throw new RuntimeException("Not tabbed!");
// tabs--;
// }
//
// @Override
// public String toString() {
// writer.flush();
// return writer.toString();
// }
//
// public static String print(AbstractCodeNode node) {
// CodePrinter printer = new CodePrinter();
// node.print(printer);
// return printer.toString();
// }
//
// }
// Path: src/mgi/tools/jagdecs2/ast/FunctionNode.java
import mgi.tools.jagdecs2.CS2Type;
import mgi.tools.jagdecs2.CodePrinter;
return name;
}
public CS2Type[] getArgumentTypes() {
return argumentTypes;
}
public String[] getArgumentNames() {
return argumentNames;
}
public LocalVariable[] getArgumentLocals() {
return argumentLocals;
}
public void setReturnType(CS2Type returnType) {
this.returnType = returnType;
}
public CS2Type getReturnType() {
return returnType;
}
public ScopeNode getScope() {
return scope;
}
@Override
| public void print(CodePrinter printer) {
|
Someone52/CS2-Decompiler | src/mgi/tools/jagdecs2/ast/StructConstructExpr.java | // Path: src/mgi/tools/jagdecs2/CodePrinter.java
// public class CodePrinter {
//
// protected StringWriter writer;
// private int tabs;
//
//
// public CodePrinter() {
// writer = new StringWriter();
// tabs = 0;
// }
//
// /**
// * Method , unused by default that notifies that specific node is
// * about to be printed.
// */
// public void beginPrinting(AbstractCodeNode node) { }
//
// /**
// * Method, unused by default that notifies that specific node was
// * printed.
// */
// public void endPrinting(AbstractCodeNode node) { }
//
//
// public void print(CharSequence str) {
// for (int i = 0; i < str.length(); i++)
// print(str.charAt(i));
// }
//
// public void print(char c) {
// writer.append(c);
// if (c == '\n')
// writer.append(getTabs());
// }
//
// protected String getTabs() {
// StringBuilder tabs = new StringBuilder();
// for (int i = 0; i < this.tabs; i++)
// tabs.append('\t');
// return tabs.toString();
// }
//
// public void tab() {
// tabs++;
// }
//
// public void untab() {
// if (tabs <= 0)
// throw new RuntimeException("Not tabbed!");
// tabs--;
// }
//
// @Override
// public String toString() {
// writer.flush();
// return writer.toString();
// }
//
// public static String print(AbstractCodeNode node) {
// CodePrinter printer = new CodePrinter();
// node.print(printer);
// return printer.toString();
// }
//
// }
| import mgi.tools.jagdecs2.CS2Type;
import mgi.tools.jagdecs2.CodePrinter;
| /*
This program 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 3 of the License, or
(at your option) any later version.
This program 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package mgi.tools.jagdecs2.ast;
public class StructConstructExpr extends ExpressionNode {
private CS2Type type;
private ExpressionNode[] arguments;
public StructConstructExpr(CS2Type type,ExpressionNode[] arguments) {
this.type = type;
this.arguments = arguments;
for (int i = 0; i < arguments.length; i++) {
this.write(arguments[i]);
arguments[i].setParent(this);
}
}
@Override
public int getPriority() {
return ExpressionNode.PRIORITY_CALL;
}
@Override
public CS2Type getType() {
return type;
}
@Override
public ExpressionNode copy() {
ExpressionNode[] argsCopy = new ExpressionNode[arguments.length];
for (int i = 0; i < arguments.length; i++)
argsCopy[i] = arguments[i].copy();
return new StructConstructExpr(this.type,argsCopy);
}
@Override
| // Path: src/mgi/tools/jagdecs2/CodePrinter.java
// public class CodePrinter {
//
// protected StringWriter writer;
// private int tabs;
//
//
// public CodePrinter() {
// writer = new StringWriter();
// tabs = 0;
// }
//
// /**
// * Method , unused by default that notifies that specific node is
// * about to be printed.
// */
// public void beginPrinting(AbstractCodeNode node) { }
//
// /**
// * Method, unused by default that notifies that specific node was
// * printed.
// */
// public void endPrinting(AbstractCodeNode node) { }
//
//
// public void print(CharSequence str) {
// for (int i = 0; i < str.length(); i++)
// print(str.charAt(i));
// }
//
// public void print(char c) {
// writer.append(c);
// if (c == '\n')
// writer.append(getTabs());
// }
//
// protected String getTabs() {
// StringBuilder tabs = new StringBuilder();
// for (int i = 0; i < this.tabs; i++)
// tabs.append('\t');
// return tabs.toString();
// }
//
// public void tab() {
// tabs++;
// }
//
// public void untab() {
// if (tabs <= 0)
// throw new RuntimeException("Not tabbed!");
// tabs--;
// }
//
// @Override
// public String toString() {
// writer.flush();
// return writer.toString();
// }
//
// public static String print(AbstractCodeNode node) {
// CodePrinter printer = new CodePrinter();
// node.print(printer);
// return printer.toString();
// }
//
// }
// Path: src/mgi/tools/jagdecs2/ast/StructConstructExpr.java
import mgi.tools.jagdecs2.CS2Type;
import mgi.tools.jagdecs2.CodePrinter;
/*
This program 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 3 of the License, or
(at your option) any later version.
This program 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package mgi.tools.jagdecs2.ast;
public class StructConstructExpr extends ExpressionNode {
private CS2Type type;
private ExpressionNode[] arguments;
public StructConstructExpr(CS2Type type,ExpressionNode[] arguments) {
this.type = type;
this.arguments = arguments;
for (int i = 0; i < arguments.length; i++) {
this.write(arguments[i]);
arguments[i].setParent(this);
}
}
@Override
public int getPriority() {
return ExpressionNode.PRIORITY_CALL;
}
@Override
public CS2Type getType() {
return type;
}
@Override
public ExpressionNode copy() {
ExpressionNode[] argsCopy = new ExpressionNode[arguments.length];
for (int i = 0; i < arguments.length; i++)
argsCopy[i] = arguments[i].copy();
return new StructConstructExpr(this.type,argsCopy);
}
@Override
| public void print(CodePrinter printer) {
|
Someone52/CS2-Decompiler | src/mgi/tools/jagdecs2/ast/VariableAssignationNode.java | // Path: src/mgi/tools/jagdecs2/CodePrinter.java
// public class CodePrinter {
//
// protected StringWriter writer;
// private int tabs;
//
//
// public CodePrinter() {
// writer = new StringWriter();
// tabs = 0;
// }
//
// /**
// * Method , unused by default that notifies that specific node is
// * about to be printed.
// */
// public void beginPrinting(AbstractCodeNode node) { }
//
// /**
// * Method, unused by default that notifies that specific node was
// * printed.
// */
// public void endPrinting(AbstractCodeNode node) { }
//
//
// public void print(CharSequence str) {
// for (int i = 0; i < str.length(); i++)
// print(str.charAt(i));
// }
//
// public void print(char c) {
// writer.append(c);
// if (c == '\n')
// writer.append(getTabs());
// }
//
// protected String getTabs() {
// StringBuilder tabs = new StringBuilder();
// for (int i = 0; i < this.tabs; i++)
// tabs.append('\t');
// return tabs.toString();
// }
//
// public void tab() {
// tabs++;
// }
//
// public void untab() {
// if (tabs <= 0)
// throw new RuntimeException("Not tabbed!");
// tabs--;
// }
//
// @Override
// public String toString() {
// writer.flush();
// return writer.toString();
// }
//
// public static String print(AbstractCodeNode node) {
// CodePrinter printer = new CodePrinter();
// node.print(printer);
// return printer.toString();
// }
//
// }
| import mgi.tools.jagdecs2.CS2Type;
import mgi.tools.jagdecs2.CodePrinter;
| public CS2Type getType() {
return this.expression.getType();
}
@Override
public ExpressionNode copy() {
return new VariableAssignationNode(this.variable,this.expression.copy());
}
public LocalVariable getVariable() {
return variable;
}
public void setVariable(LocalVariable v) {
this.variable = v;
}
public ExpressionNode getExpression() {
return expression;
}
public boolean isDeclaration() {
return isDeclaration;
}
public void setIsDeclaration(boolean is) {
isDeclaration = is;
}
@Override
| // Path: src/mgi/tools/jagdecs2/CodePrinter.java
// public class CodePrinter {
//
// protected StringWriter writer;
// private int tabs;
//
//
// public CodePrinter() {
// writer = new StringWriter();
// tabs = 0;
// }
//
// /**
// * Method , unused by default that notifies that specific node is
// * about to be printed.
// */
// public void beginPrinting(AbstractCodeNode node) { }
//
// /**
// * Method, unused by default that notifies that specific node was
// * printed.
// */
// public void endPrinting(AbstractCodeNode node) { }
//
//
// public void print(CharSequence str) {
// for (int i = 0; i < str.length(); i++)
// print(str.charAt(i));
// }
//
// public void print(char c) {
// writer.append(c);
// if (c == '\n')
// writer.append(getTabs());
// }
//
// protected String getTabs() {
// StringBuilder tabs = new StringBuilder();
// for (int i = 0; i < this.tabs; i++)
// tabs.append('\t');
// return tabs.toString();
// }
//
// public void tab() {
// tabs++;
// }
//
// public void untab() {
// if (tabs <= 0)
// throw new RuntimeException("Not tabbed!");
// tabs--;
// }
//
// @Override
// public String toString() {
// writer.flush();
// return writer.toString();
// }
//
// public static String print(AbstractCodeNode node) {
// CodePrinter printer = new CodePrinter();
// node.print(printer);
// return printer.toString();
// }
//
// }
// Path: src/mgi/tools/jagdecs2/ast/VariableAssignationNode.java
import mgi.tools.jagdecs2.CS2Type;
import mgi.tools.jagdecs2.CodePrinter;
public CS2Type getType() {
return this.expression.getType();
}
@Override
public ExpressionNode copy() {
return new VariableAssignationNode(this.variable,this.expression.copy());
}
public LocalVariable getVariable() {
return variable;
}
public void setVariable(LocalVariable v) {
this.variable = v;
}
public ExpressionNode getExpression() {
return expression;
}
public boolean isDeclaration() {
return isDeclaration;
}
public void setIsDeclaration(boolean is) {
isDeclaration = is;
}
@Override
| public void print(CodePrinter printer) {
|
Someone52/CS2-Decompiler | src/mgi/tools/jagdecs2/ast/StructPartLoadNode.java | // Path: src/mgi/tools/jagdecs2/CodePrinter.java
// public class CodePrinter {
//
// protected StringWriter writer;
// private int tabs;
//
//
// public CodePrinter() {
// writer = new StringWriter();
// tabs = 0;
// }
//
// /**
// * Method , unused by default that notifies that specific node is
// * about to be printed.
// */
// public void beginPrinting(AbstractCodeNode node) { }
//
// /**
// * Method, unused by default that notifies that specific node was
// * printed.
// */
// public void endPrinting(AbstractCodeNode node) { }
//
//
// public void print(CharSequence str) {
// for (int i = 0; i < str.length(); i++)
// print(str.charAt(i));
// }
//
// public void print(char c) {
// writer.append(c);
// if (c == '\n')
// writer.append(getTabs());
// }
//
// protected String getTabs() {
// StringBuilder tabs = new StringBuilder();
// for (int i = 0; i < this.tabs; i++)
// tabs.append('\t');
// return tabs.toString();
// }
//
// public void tab() {
// tabs++;
// }
//
// public void untab() {
// if (tabs <= 0)
// throw new RuntimeException("Not tabbed!");
// tabs--;
// }
//
// @Override
// public String toString() {
// writer.flush();
// return writer.toString();
// }
//
// public static String print(AbstractCodeNode node) {
// CodePrinter printer = new CodePrinter();
// node.print(printer);
// return printer.toString();
// }
//
// }
| import mgi.tools.jagdecs2.CS2Type;
import mgi.tools.jagdecs2.CodePrinter;
| /*
This program 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 3 of the License, or
(at your option) any later version.
This program 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package mgi.tools.jagdecs2.ast;
public class StructPartLoadNode extends ExpressionNode {
private String name;
private CS2Type type;
private ExpressionNode expression;
public StructPartLoadNode(String name,CS2Type type,ExpressionNode expr) {
this.name = name;
this.type = type;
this.expression = expr;
this.write(expr);
expr.setParent(this);
}
@Override
public CS2Type getType() {
return this.type;
}
public String getName() {
return name;
}
public ExpressionNode getExpression() {
return expression;
}
@Override
public ExpressionNode copy() {
return new StructPartLoadNode(this.name,this.type,this.expression.copy());
}
@Override
| // Path: src/mgi/tools/jagdecs2/CodePrinter.java
// public class CodePrinter {
//
// protected StringWriter writer;
// private int tabs;
//
//
// public CodePrinter() {
// writer = new StringWriter();
// tabs = 0;
// }
//
// /**
// * Method , unused by default that notifies that specific node is
// * about to be printed.
// */
// public void beginPrinting(AbstractCodeNode node) { }
//
// /**
// * Method, unused by default that notifies that specific node was
// * printed.
// */
// public void endPrinting(AbstractCodeNode node) { }
//
//
// public void print(CharSequence str) {
// for (int i = 0; i < str.length(); i++)
// print(str.charAt(i));
// }
//
// public void print(char c) {
// writer.append(c);
// if (c == '\n')
// writer.append(getTabs());
// }
//
// protected String getTabs() {
// StringBuilder tabs = new StringBuilder();
// for (int i = 0; i < this.tabs; i++)
// tabs.append('\t');
// return tabs.toString();
// }
//
// public void tab() {
// tabs++;
// }
//
// public void untab() {
// if (tabs <= 0)
// throw new RuntimeException("Not tabbed!");
// tabs--;
// }
//
// @Override
// public String toString() {
// writer.flush();
// return writer.toString();
// }
//
// public static String print(AbstractCodeNode node) {
// CodePrinter printer = new CodePrinter();
// node.print(printer);
// return printer.toString();
// }
//
// }
// Path: src/mgi/tools/jagdecs2/ast/StructPartLoadNode.java
import mgi.tools.jagdecs2.CS2Type;
import mgi.tools.jagdecs2.CodePrinter;
/*
This program 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 3 of the License, or
(at your option) any later version.
This program 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package mgi.tools.jagdecs2.ast;
public class StructPartLoadNode extends ExpressionNode {
private String name;
private CS2Type type;
private ExpressionNode expression;
public StructPartLoadNode(String name,CS2Type type,ExpressionNode expr) {
this.name = name;
this.type = type;
this.expression = expr;
this.write(expr);
expr.setParent(this);
}
@Override
public CS2Type getType() {
return this.type;
}
public String getName() {
return name;
}
public ExpressionNode getExpression() {
return expression;
}
@Override
public ExpressionNode copy() {
return new StructPartLoadNode(this.name,this.type,this.expression.copy());
}
@Override
| public void print(CodePrinter printer) {
|
Someone52/CS2-Decompiler | src/mgi/tools/jagdecs2/ast/LongExpressionNode.java | // Path: src/mgi/tools/jagdecs2/CodePrinter.java
// public class CodePrinter {
//
// protected StringWriter writer;
// private int tabs;
//
//
// public CodePrinter() {
// writer = new StringWriter();
// tabs = 0;
// }
//
// /**
// * Method , unused by default that notifies that specific node is
// * about to be printed.
// */
// public void beginPrinting(AbstractCodeNode node) { }
//
// /**
// * Method, unused by default that notifies that specific node was
// * printed.
// */
// public void endPrinting(AbstractCodeNode node) { }
//
//
// public void print(CharSequence str) {
// for (int i = 0; i < str.length(); i++)
// print(str.charAt(i));
// }
//
// public void print(char c) {
// writer.append(c);
// if (c == '\n')
// writer.append(getTabs());
// }
//
// protected String getTabs() {
// StringBuilder tabs = new StringBuilder();
// for (int i = 0; i < this.tabs; i++)
// tabs.append('\t');
// return tabs.toString();
// }
//
// public void tab() {
// tabs++;
// }
//
// public void untab() {
// if (tabs <= 0)
// throw new RuntimeException("Not tabbed!");
// tabs--;
// }
//
// @Override
// public String toString() {
// writer.flush();
// return writer.toString();
// }
//
// public static String print(AbstractCodeNode node) {
// CodePrinter printer = new CodePrinter();
// node.print(printer);
// return printer.toString();
// }
//
// }
| import mgi.tools.jagdecs2.CS2Type;
import mgi.tools.jagdecs2.CodePrinter;
| /*
This program 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 3 of the License, or
(at your option) any later version.
This program 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package mgi.tools.jagdecs2.ast;
public class LongExpressionNode extends ExpressionNode implements IConstantNode {
/**
* Contains long which this expression holds.
*/
private long data;
public LongExpressionNode(long data) {
this.data = data;
}
public long getData() {
return data;
}
@Override
public CS2Type getType() {
return CS2Type.LONG;
}
@Override
public Object getConst() {
return this.data;
}
@Override
public ExpressionNode copy() {
return new LongExpressionNode(data);
}
@Override
| // Path: src/mgi/tools/jagdecs2/CodePrinter.java
// public class CodePrinter {
//
// protected StringWriter writer;
// private int tabs;
//
//
// public CodePrinter() {
// writer = new StringWriter();
// tabs = 0;
// }
//
// /**
// * Method , unused by default that notifies that specific node is
// * about to be printed.
// */
// public void beginPrinting(AbstractCodeNode node) { }
//
// /**
// * Method, unused by default that notifies that specific node was
// * printed.
// */
// public void endPrinting(AbstractCodeNode node) { }
//
//
// public void print(CharSequence str) {
// for (int i = 0; i < str.length(); i++)
// print(str.charAt(i));
// }
//
// public void print(char c) {
// writer.append(c);
// if (c == '\n')
// writer.append(getTabs());
// }
//
// protected String getTabs() {
// StringBuilder tabs = new StringBuilder();
// for (int i = 0; i < this.tabs; i++)
// tabs.append('\t');
// return tabs.toString();
// }
//
// public void tab() {
// tabs++;
// }
//
// public void untab() {
// if (tabs <= 0)
// throw new RuntimeException("Not tabbed!");
// tabs--;
// }
//
// @Override
// public String toString() {
// writer.flush();
// return writer.toString();
// }
//
// public static String print(AbstractCodeNode node) {
// CodePrinter printer = new CodePrinter();
// node.print(printer);
// return printer.toString();
// }
//
// }
// Path: src/mgi/tools/jagdecs2/ast/LongExpressionNode.java
import mgi.tools.jagdecs2.CS2Type;
import mgi.tools.jagdecs2.CodePrinter;
/*
This program 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 3 of the License, or
(at your option) any later version.
This program 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package mgi.tools.jagdecs2.ast;
public class LongExpressionNode extends ExpressionNode implements IConstantNode {
/**
* Contains long which this expression holds.
*/
private long data;
public LongExpressionNode(long data) {
this.data = data;
}
public long getData() {
return data;
}
@Override
public CS2Type getType() {
return CS2Type.LONG;
}
@Override
public Object getConst() {
return this.data;
}
@Override
public ExpressionNode copy() {
return new LongExpressionNode(data);
}
@Override
| public void print(CodePrinter printer) {
|
Someone52/CS2-Decompiler | src/mgi/tools/jagdecs2/ast/SwitchNode.java | // Path: src/mgi/tools/jagdecs2/CodePrinter.java
// public class CodePrinter {
//
// protected StringWriter writer;
// private int tabs;
//
//
// public CodePrinter() {
// writer = new StringWriter();
// tabs = 0;
// }
//
// /**
// * Method , unused by default that notifies that specific node is
// * about to be printed.
// */
// public void beginPrinting(AbstractCodeNode node) { }
//
// /**
// * Method, unused by default that notifies that specific node was
// * printed.
// */
// public void endPrinting(AbstractCodeNode node) { }
//
//
// public void print(CharSequence str) {
// for (int i = 0; i < str.length(); i++)
// print(str.charAt(i));
// }
//
// public void print(char c) {
// writer.append(c);
// if (c == '\n')
// writer.append(getTabs());
// }
//
// protected String getTabs() {
// StringBuilder tabs = new StringBuilder();
// for (int i = 0; i < this.tabs; i++)
// tabs.append('\t');
// return tabs.toString();
// }
//
// public void tab() {
// tabs++;
// }
//
// public void untab() {
// if (tabs <= 0)
// throw new RuntimeException("Not tabbed!");
// tabs--;
// }
//
// @Override
// public String toString() {
// writer.flush();
// return writer.toString();
// }
//
// public static String print(AbstractCodeNode node) {
// CodePrinter printer = new CodePrinter();
// node.print(printer);
// return printer.toString();
// }
//
// }
| import mgi.tools.jagdecs2.CodePrinter;
| /*
This program 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 3 of the License, or
(at your option) any later version.
This program 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package mgi.tools.jagdecs2.ast;
public class SwitchNode extends AbstractCodeNode implements IBreakableNode {
/**
* Contains expression which type is boolean.
*/
private ExpressionNode expression;
/**
* Contains scope which should be executed if
* expression finds valid case.
*/
private ScopeNode scope;
/**
* Contains end block of this switch node.
*/
private FlowBlock end;
/**
* Contains label name.
*/
private String labelName;
public SwitchNode(FlowBlock end, ScopeNode scope, ExpressionNode expr) {
this.end = end;
this.expression = expr;
this.scope = scope;
this.write(expr);
this.write(scope);
expr.setParent(this);
scope.setParent(this);
}
@Override
| // Path: src/mgi/tools/jagdecs2/CodePrinter.java
// public class CodePrinter {
//
// protected StringWriter writer;
// private int tabs;
//
//
// public CodePrinter() {
// writer = new StringWriter();
// tabs = 0;
// }
//
// /**
// * Method , unused by default that notifies that specific node is
// * about to be printed.
// */
// public void beginPrinting(AbstractCodeNode node) { }
//
// /**
// * Method, unused by default that notifies that specific node was
// * printed.
// */
// public void endPrinting(AbstractCodeNode node) { }
//
//
// public void print(CharSequence str) {
// for (int i = 0; i < str.length(); i++)
// print(str.charAt(i));
// }
//
// public void print(char c) {
// writer.append(c);
// if (c == '\n')
// writer.append(getTabs());
// }
//
// protected String getTabs() {
// StringBuilder tabs = new StringBuilder();
// for (int i = 0; i < this.tabs; i++)
// tabs.append('\t');
// return tabs.toString();
// }
//
// public void tab() {
// tabs++;
// }
//
// public void untab() {
// if (tabs <= 0)
// throw new RuntimeException("Not tabbed!");
// tabs--;
// }
//
// @Override
// public String toString() {
// writer.flush();
// return writer.toString();
// }
//
// public static String print(AbstractCodeNode node) {
// CodePrinter printer = new CodePrinter();
// node.print(printer);
// return printer.toString();
// }
//
// }
// Path: src/mgi/tools/jagdecs2/ast/SwitchNode.java
import mgi.tools.jagdecs2.CodePrinter;
/*
This program 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 3 of the License, or
(at your option) any later version.
This program 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package mgi.tools.jagdecs2.ast;
public class SwitchNode extends AbstractCodeNode implements IBreakableNode {
/**
* Contains expression which type is boolean.
*/
private ExpressionNode expression;
/**
* Contains scope which should be executed if
* expression finds valid case.
*/
private ScopeNode scope;
/**
* Contains end block of this switch node.
*/
private FlowBlock end;
/**
* Contains label name.
*/
private String labelName;
public SwitchNode(FlowBlock end, ScopeNode scope, ExpressionNode expr) {
this.end = end;
this.expression = expr;
this.scope = scope;
this.write(expr);
this.write(scope);
expr.setParent(this);
scope.setParent(this);
}
@Override
| public void print(CodePrinter printer) {
|
Someone52/CS2-Decompiler | src/mgi/tools/jagdecs2/ast/CastNode.java | // Path: src/mgi/tools/jagdecs2/CodePrinter.java
// public class CodePrinter {
//
// protected StringWriter writer;
// private int tabs;
//
//
// public CodePrinter() {
// writer = new StringWriter();
// tabs = 0;
// }
//
// /**
// * Method , unused by default that notifies that specific node is
// * about to be printed.
// */
// public void beginPrinting(AbstractCodeNode node) { }
//
// /**
// * Method, unused by default that notifies that specific node was
// * printed.
// */
// public void endPrinting(AbstractCodeNode node) { }
//
//
// public void print(CharSequence str) {
// for (int i = 0; i < str.length(); i++)
// print(str.charAt(i));
// }
//
// public void print(char c) {
// writer.append(c);
// if (c == '\n')
// writer.append(getTabs());
// }
//
// protected String getTabs() {
// StringBuilder tabs = new StringBuilder();
// for (int i = 0; i < this.tabs; i++)
// tabs.append('\t');
// return tabs.toString();
// }
//
// public void tab() {
// tabs++;
// }
//
// public void untab() {
// if (tabs <= 0)
// throw new RuntimeException("Not tabbed!");
// tabs--;
// }
//
// @Override
// public String toString() {
// writer.flush();
// return writer.toString();
// }
//
// public static String print(AbstractCodeNode node) {
// CodePrinter printer = new CodePrinter();
// node.print(printer);
// return printer.toString();
// }
//
// }
| import mgi.tools.jagdecs2.CS2Type;
import mgi.tools.jagdecs2.CodePrinter;
| /*
This program 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 3 of the License, or
(at your option) any later version.
This program 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package mgi.tools.jagdecs2.ast;
public class CastNode extends ExpressionNode {
private CS2Type type;
private ExpressionNode expression;
public CastNode(CS2Type type,ExpressionNode expr) {
this.type = type;
this.expression = expr;
this.write(expr);
expr.setParent(this);
}
@Override
public int getPriority() {
return expression.getPriority();
//return ExpressionNode.PRIORITY_CAST;
}
@Override
public CS2Type getType() {
return type;
}
@Override
public ExpressionNode copy() {
return new CastNode(this.type,this.expression.copy());
}
public ExpressionNode getExpression() {
return expression;
}
@Override
| // Path: src/mgi/tools/jagdecs2/CodePrinter.java
// public class CodePrinter {
//
// protected StringWriter writer;
// private int tabs;
//
//
// public CodePrinter() {
// writer = new StringWriter();
// tabs = 0;
// }
//
// /**
// * Method , unused by default that notifies that specific node is
// * about to be printed.
// */
// public void beginPrinting(AbstractCodeNode node) { }
//
// /**
// * Method, unused by default that notifies that specific node was
// * printed.
// */
// public void endPrinting(AbstractCodeNode node) { }
//
//
// public void print(CharSequence str) {
// for (int i = 0; i < str.length(); i++)
// print(str.charAt(i));
// }
//
// public void print(char c) {
// writer.append(c);
// if (c == '\n')
// writer.append(getTabs());
// }
//
// protected String getTabs() {
// StringBuilder tabs = new StringBuilder();
// for (int i = 0; i < this.tabs; i++)
// tabs.append('\t');
// return tabs.toString();
// }
//
// public void tab() {
// tabs++;
// }
//
// public void untab() {
// if (tabs <= 0)
// throw new RuntimeException("Not tabbed!");
// tabs--;
// }
//
// @Override
// public String toString() {
// writer.flush();
// return writer.toString();
// }
//
// public static String print(AbstractCodeNode node) {
// CodePrinter printer = new CodePrinter();
// node.print(printer);
// return printer.toString();
// }
//
// }
// Path: src/mgi/tools/jagdecs2/ast/CastNode.java
import mgi.tools.jagdecs2.CS2Type;
import mgi.tools.jagdecs2.CodePrinter;
/*
This program 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 3 of the License, or
(at your option) any later version.
This program 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package mgi.tools.jagdecs2.ast;
public class CastNode extends ExpressionNode {
private CS2Type type;
private ExpressionNode expression;
public CastNode(CS2Type type,ExpressionNode expr) {
this.type = type;
this.expression = expr;
this.write(expr);
expr.setParent(this);
}
@Override
public int getPriority() {
return expression.getPriority();
//return ExpressionNode.PRIORITY_CAST;
}
@Override
public CS2Type getType() {
return type;
}
@Override
public ExpressionNode copy() {
return new CastNode(this.type,this.expression.copy());
}
public ExpressionNode getExpression() {
return expression;
}
@Override
| public void print(CodePrinter printer) {
|
Someone52/CS2-Decompiler | src/mgi/tools/jagdecs2/ast/FunctionExpressionNode.java | // Path: src/mgi/tools/jagdecs2/CodePrinter.java
// public class CodePrinter {
//
// protected StringWriter writer;
// private int tabs;
//
//
// public CodePrinter() {
// writer = new StringWriter();
// tabs = 0;
// }
//
// /**
// * Method , unused by default that notifies that specific node is
// * about to be printed.
// */
// public void beginPrinting(AbstractCodeNode node) { }
//
// /**
// * Method, unused by default that notifies that specific node was
// * printed.
// */
// public void endPrinting(AbstractCodeNode node) { }
//
//
// public void print(CharSequence str) {
// for (int i = 0; i < str.length(); i++)
// print(str.charAt(i));
// }
//
// public void print(char c) {
// writer.append(c);
// if (c == '\n')
// writer.append(getTabs());
// }
//
// protected String getTabs() {
// StringBuilder tabs = new StringBuilder();
// for (int i = 0; i < this.tabs; i++)
// tabs.append('\t');
// return tabs.toString();
// }
//
// public void tab() {
// tabs++;
// }
//
// public void untab() {
// if (tabs <= 0)
// throw new RuntimeException("Not tabbed!");
// tabs--;
// }
//
// @Override
// public String toString() {
// writer.flush();
// return writer.toString();
// }
//
// public static String print(AbstractCodeNode node) {
// CodePrinter printer = new CodePrinter();
// node.print(printer);
// return printer.toString();
// }
//
// }
| import mgi.tools.jagdecs2.CS2Type;
import mgi.tools.jagdecs2.CodePrinter;
| /*
This program 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 3 of the License, or
(at your option) any later version.
This program 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package mgi.tools.jagdecs2.ast;
public class FunctionExpressionNode extends ExpressionNode {
/**
* Id of the function.
*/
private ExpressionNode id;
/**
* Contains int which this expression holds.
*/
private FunctionNode function;
public FunctionExpressionNode(ExpressionNode id, FunctionNode function) {
this.id = id;
this.function = function;
this.write(id);
id.setParent(this);
}
public ExpressionNode getId() {
return id;
}
public FunctionNode getFunction() {
return function;
}
@Override
public CS2Type getType() {
return CS2Type.FUNCTION;
}
@Override
public ExpressionNode copy() {
return new FunctionExpressionNode(this.id.copy(), this.function);
}
@Override
| // Path: src/mgi/tools/jagdecs2/CodePrinter.java
// public class CodePrinter {
//
// protected StringWriter writer;
// private int tabs;
//
//
// public CodePrinter() {
// writer = new StringWriter();
// tabs = 0;
// }
//
// /**
// * Method , unused by default that notifies that specific node is
// * about to be printed.
// */
// public void beginPrinting(AbstractCodeNode node) { }
//
// /**
// * Method, unused by default that notifies that specific node was
// * printed.
// */
// public void endPrinting(AbstractCodeNode node) { }
//
//
// public void print(CharSequence str) {
// for (int i = 0; i < str.length(); i++)
// print(str.charAt(i));
// }
//
// public void print(char c) {
// writer.append(c);
// if (c == '\n')
// writer.append(getTabs());
// }
//
// protected String getTabs() {
// StringBuilder tabs = new StringBuilder();
// for (int i = 0; i < this.tabs; i++)
// tabs.append('\t');
// return tabs.toString();
// }
//
// public void tab() {
// tabs++;
// }
//
// public void untab() {
// if (tabs <= 0)
// throw new RuntimeException("Not tabbed!");
// tabs--;
// }
//
// @Override
// public String toString() {
// writer.flush();
// return writer.toString();
// }
//
// public static String print(AbstractCodeNode node) {
// CodePrinter printer = new CodePrinter();
// node.print(printer);
// return printer.toString();
// }
//
// }
// Path: src/mgi/tools/jagdecs2/ast/FunctionExpressionNode.java
import mgi.tools.jagdecs2.CS2Type;
import mgi.tools.jagdecs2.CodePrinter;
/*
This program 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 3 of the License, or
(at your option) any later version.
This program 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package mgi.tools.jagdecs2.ast;
public class FunctionExpressionNode extends ExpressionNode {
/**
* Id of the function.
*/
private ExpressionNode id;
/**
* Contains int which this expression holds.
*/
private FunctionNode function;
public FunctionExpressionNode(ExpressionNode id, FunctionNode function) {
this.id = id;
this.function = function;
this.write(id);
id.setParent(this);
}
public ExpressionNode getId() {
return id;
}
public FunctionNode getFunction() {
return function;
}
@Override
public CS2Type getType() {
return CS2Type.FUNCTION;
}
@Override
public ExpressionNode copy() {
return new FunctionExpressionNode(this.id.copy(), this.function);
}
@Override
| public void print(CodePrinter printer) {
|
Someone52/CS2-Decompiler | src/mgi/tools/jagdecs2/instructions/SwitchInstruction.java | // Path: src/mgi/tools/jagdecs2/util/InstructionInfo.java
// public class InstructionInfo {
//
// private String name;
// private int scrampledOpcode;
// private int originalOpcode;
// private boolean hasIntConstant;
//
// public InstructionInfo(String name, int scrampledop, int originalop, boolean hasIntConstant) {
// this.name = name;
// this.scrampledOpcode = scrampledop;
// this.originalOpcode = originalop;
// this.hasIntConstant = hasIntConstant;
// }
//
// public String getName() {
// return name;
// }
//
// public int getScrampledOpcode() {
// return scrampledOpcode;
// }
//
// public int getOpcode() {
// return originalOpcode;
// }
//
// public boolean hasIntConstant() {
// return hasIntConstant;
// }
//
// @Override
// public String toString() {
// return name + "[" + originalOpcode + "," + scrampledOpcode + ":" + hasIntConstant + "]";
// }
//
// }
| import mgi.tools.jagdecs2.util.InstructionInfo;
| /*
This program 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 3 of the License, or
(at your option) any later version.
This program 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package mgi.tools.jagdecs2.instructions;
public class SwitchInstruction extends AbstractInstruction {
private int[] cases;
private Label[] targets;
private int defaultIndex;
| // Path: src/mgi/tools/jagdecs2/util/InstructionInfo.java
// public class InstructionInfo {
//
// private String name;
// private int scrampledOpcode;
// private int originalOpcode;
// private boolean hasIntConstant;
//
// public InstructionInfo(String name, int scrampledop, int originalop, boolean hasIntConstant) {
// this.name = name;
// this.scrampledOpcode = scrampledop;
// this.originalOpcode = originalop;
// this.hasIntConstant = hasIntConstant;
// }
//
// public String getName() {
// return name;
// }
//
// public int getScrampledOpcode() {
// return scrampledOpcode;
// }
//
// public int getOpcode() {
// return originalOpcode;
// }
//
// public boolean hasIntConstant() {
// return hasIntConstant;
// }
//
// @Override
// public String toString() {
// return name + "[" + originalOpcode + "," + scrampledOpcode + ":" + hasIntConstant + "]";
// }
//
// }
// Path: src/mgi/tools/jagdecs2/instructions/SwitchInstruction.java
import mgi.tools.jagdecs2.util.InstructionInfo;
/*
This program 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 3 of the License, or
(at your option) any later version.
This program 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package mgi.tools.jagdecs2.instructions;
public class SwitchInstruction extends AbstractInstruction {
private int[] cases;
private Label[] targets;
private int defaultIndex;
| public SwitchInstruction(InstructionInfo info, int[] cases, Label[] targets) {
|
Someone52/CS2-Decompiler | src/mgi/tools/jagdecs2/CodePrinter.java | // Path: src/mgi/tools/jagdecs2/ast/AbstractCodeNode.java
// public abstract class AbstractCodeNode {
//
// private static final int INITIAL_BUFFER_SIZE = 4;
// private AbstractCodeNode[] childs;
// private int codeAddress;
//
//
// public abstract void print(CodePrinter printer);
//
// public AbstractCodeNode() {
// childs = new AbstractCodeNode[INITIAL_BUFFER_SIZE];
// codeAddress = 0;
// }
//
// public AbstractCodeNode read() {
// if (childs[codeAddress] == null)
// return null;
// return childs[codeAddress++];
// }
//
// public AbstractCodeNode read(int addr) {
// if (addr < 0 || addr >= childs.length || (addr > 0 && childs[addr - 1] == null))
// throw new IllegalArgumentException("Invalid address.");
// return childs[addr];
// }
//
// public void write(AbstractCodeNode node) {
// if (needsExpand())
// expand();
// if (childs[codeAddress] == null)
// childs[codeAddress++] = node;
// else {
// List<AbstractCodeNode> taken = new ArrayList<AbstractCodeNode>();
// for (int i = codeAddress; i < childs.length; i++) {
// if (childs[i] != null) {
// taken.add(childs[i]);
// childs[i] = null;
// }
// }
// childs[codeAddress] = node;
// int write = ++codeAddress;
// for (AbstractCodeNode n : taken)
// childs[write++] = n;
// }
// }
//
// public void delete() {
// delete(codeAddress);
// }
//
// public void delete(int address) {
// if (address < 0 || address >= childs.length || (address > 0 && childs[address - 1] == null))
// throw new IllegalArgumentException("Invalid address.");
// if (childs[address] == null)
// throw new RuntimeException("No element to delete.");
// if ((address + 1) < childs.length && childs[address + 1] == null)
// childs[address] = null;
// else {
// childs[address] = null;
// for (int i = address + 1; i < childs.length; i++) {
// childs[i - 1] = childs[i];
// childs[i] = null;
// }
// }
// }
//
// public int addressOf(AbstractCodeNode child) {
// for (int i = 0; i < childs.length; i++)
// if (childs[i] == child)
// return i;
// return -1;
// }
//
// public List<AbstractCodeNode> listChilds() {
// List<AbstractCodeNode> list = new ArrayList<AbstractCodeNode>();
// for (int i = 0; i < childs.length; i++)
// if (childs[i] != null)
// list.add(childs[i]);
// return list;
// }
//
// public int size() {
// int total = 0;
// for (int i = 0; i < childs.length; i++)
// if (childs[i] != null)
// total++;
// return total;
// }
//
//
// private boolean needsExpand() {
// double max = childs.length * 0.50;
// return (double)size() > max;
// }
//
//
// private void expand() {
// if (childs.length >= Integer.MAX_VALUE)
// throw new RuntimeException("Can't expand anymore.");
// long newSize = childs.length * 2;
// if (newSize > Integer.MAX_VALUE)
// newSize = Integer.MAX_VALUE;
// AbstractCodeNode[] newBuffer = new AbstractCodeNode[(int)newSize];
// System.arraycopy(childs, 0, newBuffer, 0, childs.length);
// childs = newBuffer;
// }
//
//
// @Override
// public String toString() {
// return CodePrinter.print(this);
// }
//
// public void setCodeAddress(int codeAddress) {
// if (codeAddress < 0 || codeAddress >= childs.length || (codeAddress > 0 && childs[codeAddress - 1] == null))
// throw new IllegalArgumentException("Invalid address.");
// this.codeAddress = codeAddress;
// }
//
// public int getCodeAddress() {
// return codeAddress;
// }
// }
| import java.io.StringWriter;
import mgi.tools.jagdecs2.ast.AbstractCodeNode;
| /*
This program 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 3 of the License, or
(at your option) any later version.
This program 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package mgi.tools.jagdecs2;
public class CodePrinter {
protected StringWriter writer;
private int tabs;
public CodePrinter() {
writer = new StringWriter();
tabs = 0;
}
/**
* Method , unused by default that notifies that specific node is
* about to be printed.
*/
| // Path: src/mgi/tools/jagdecs2/ast/AbstractCodeNode.java
// public abstract class AbstractCodeNode {
//
// private static final int INITIAL_BUFFER_SIZE = 4;
// private AbstractCodeNode[] childs;
// private int codeAddress;
//
//
// public abstract void print(CodePrinter printer);
//
// public AbstractCodeNode() {
// childs = new AbstractCodeNode[INITIAL_BUFFER_SIZE];
// codeAddress = 0;
// }
//
// public AbstractCodeNode read() {
// if (childs[codeAddress] == null)
// return null;
// return childs[codeAddress++];
// }
//
// public AbstractCodeNode read(int addr) {
// if (addr < 0 || addr >= childs.length || (addr > 0 && childs[addr - 1] == null))
// throw new IllegalArgumentException("Invalid address.");
// return childs[addr];
// }
//
// public void write(AbstractCodeNode node) {
// if (needsExpand())
// expand();
// if (childs[codeAddress] == null)
// childs[codeAddress++] = node;
// else {
// List<AbstractCodeNode> taken = new ArrayList<AbstractCodeNode>();
// for (int i = codeAddress; i < childs.length; i++) {
// if (childs[i] != null) {
// taken.add(childs[i]);
// childs[i] = null;
// }
// }
// childs[codeAddress] = node;
// int write = ++codeAddress;
// for (AbstractCodeNode n : taken)
// childs[write++] = n;
// }
// }
//
// public void delete() {
// delete(codeAddress);
// }
//
// public void delete(int address) {
// if (address < 0 || address >= childs.length || (address > 0 && childs[address - 1] == null))
// throw new IllegalArgumentException("Invalid address.");
// if (childs[address] == null)
// throw new RuntimeException("No element to delete.");
// if ((address + 1) < childs.length && childs[address + 1] == null)
// childs[address] = null;
// else {
// childs[address] = null;
// for (int i = address + 1; i < childs.length; i++) {
// childs[i - 1] = childs[i];
// childs[i] = null;
// }
// }
// }
//
// public int addressOf(AbstractCodeNode child) {
// for (int i = 0; i < childs.length; i++)
// if (childs[i] == child)
// return i;
// return -1;
// }
//
// public List<AbstractCodeNode> listChilds() {
// List<AbstractCodeNode> list = new ArrayList<AbstractCodeNode>();
// for (int i = 0; i < childs.length; i++)
// if (childs[i] != null)
// list.add(childs[i]);
// return list;
// }
//
// public int size() {
// int total = 0;
// for (int i = 0; i < childs.length; i++)
// if (childs[i] != null)
// total++;
// return total;
// }
//
//
// private boolean needsExpand() {
// double max = childs.length * 0.50;
// return (double)size() > max;
// }
//
//
// private void expand() {
// if (childs.length >= Integer.MAX_VALUE)
// throw new RuntimeException("Can't expand anymore.");
// long newSize = childs.length * 2;
// if (newSize > Integer.MAX_VALUE)
// newSize = Integer.MAX_VALUE;
// AbstractCodeNode[] newBuffer = new AbstractCodeNode[(int)newSize];
// System.arraycopy(childs, 0, newBuffer, 0, childs.length);
// childs = newBuffer;
// }
//
//
// @Override
// public String toString() {
// return CodePrinter.print(this);
// }
//
// public void setCodeAddress(int codeAddress) {
// if (codeAddress < 0 || codeAddress >= childs.length || (codeAddress > 0 && childs[codeAddress - 1] == null))
// throw new IllegalArgumentException("Invalid address.");
// this.codeAddress = codeAddress;
// }
//
// public int getCodeAddress() {
// return codeAddress;
// }
// }
// Path: src/mgi/tools/jagdecs2/CodePrinter.java
import java.io.StringWriter;
import mgi.tools.jagdecs2.ast.AbstractCodeNode;
/*
This program 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 3 of the License, or
(at your option) any later version.
This program 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
package mgi.tools.jagdecs2;
public class CodePrinter {
protected StringWriter writer;
private int tabs;
public CodePrinter() {
writer = new StringWriter();
tabs = 0;
}
/**
* Method , unused by default that notifies that specific node is
* about to be printed.
*/
| public void beginPrinting(AbstractCodeNode node) { }
|
Someone52/CS2-Decompiler | src/mgi/tools/jagdecs2/ast/IfElseNode.java | // Path: src/mgi/tools/jagdecs2/CodePrinter.java
// public class CodePrinter {
//
// protected StringWriter writer;
// private int tabs;
//
//
// public CodePrinter() {
// writer = new StringWriter();
// tabs = 0;
// }
//
// /**
// * Method , unused by default that notifies that specific node is
// * about to be printed.
// */
// public void beginPrinting(AbstractCodeNode node) { }
//
// /**
// * Method, unused by default that notifies that specific node was
// * printed.
// */
// public void endPrinting(AbstractCodeNode node) { }
//
//
// public void print(CharSequence str) {
// for (int i = 0; i < str.length(); i++)
// print(str.charAt(i));
// }
//
// public void print(char c) {
// writer.append(c);
// if (c == '\n')
// writer.append(getTabs());
// }
//
// protected String getTabs() {
// StringBuilder tabs = new StringBuilder();
// for (int i = 0; i < this.tabs; i++)
// tabs.append('\t');
// return tabs.toString();
// }
//
// public void tab() {
// tabs++;
// }
//
// public void untab() {
// if (tabs <= 0)
// throw new RuntimeException("Not tabbed!");
// tabs--;
// }
//
// @Override
// public String toString() {
// writer.flush();
// return writer.toString();
// }
//
// public static String print(AbstractCodeNode node) {
// CodePrinter printer = new CodePrinter();
// node.print(printer);
// return printer.toString();
// }
//
// }
| import mgi.tools.jagdecs2.CodePrinter;
| this.write(expressions[i]);
expressions[i].setParent(this);
}
for (int i = 0; i < scopes.length; i++) {
this.write(scopes[i]);
scopes[i].setParent(this);
}
this.write(elseScope);
elseScope.setParent(this);
}
public boolean hasElseScope() {
return !this.elseScope.isEmpty();
}
public ExpressionNode[] getExpressions() {
return expressions;
}
public ScopeNode[] getScopes() {
return scopes;
}
public ScopeNode getElseScope() {
return elseScope;
}
@Override
| // Path: src/mgi/tools/jagdecs2/CodePrinter.java
// public class CodePrinter {
//
// protected StringWriter writer;
// private int tabs;
//
//
// public CodePrinter() {
// writer = new StringWriter();
// tabs = 0;
// }
//
// /**
// * Method , unused by default that notifies that specific node is
// * about to be printed.
// */
// public void beginPrinting(AbstractCodeNode node) { }
//
// /**
// * Method, unused by default that notifies that specific node was
// * printed.
// */
// public void endPrinting(AbstractCodeNode node) { }
//
//
// public void print(CharSequence str) {
// for (int i = 0; i < str.length(); i++)
// print(str.charAt(i));
// }
//
// public void print(char c) {
// writer.append(c);
// if (c == '\n')
// writer.append(getTabs());
// }
//
// protected String getTabs() {
// StringBuilder tabs = new StringBuilder();
// for (int i = 0; i < this.tabs; i++)
// tabs.append('\t');
// return tabs.toString();
// }
//
// public void tab() {
// tabs++;
// }
//
// public void untab() {
// if (tabs <= 0)
// throw new RuntimeException("Not tabbed!");
// tabs--;
// }
//
// @Override
// public String toString() {
// writer.flush();
// return writer.toString();
// }
//
// public static String print(AbstractCodeNode node) {
// CodePrinter printer = new CodePrinter();
// node.print(printer);
// return printer.toString();
// }
//
// }
// Path: src/mgi/tools/jagdecs2/ast/IfElseNode.java
import mgi.tools.jagdecs2.CodePrinter;
this.write(expressions[i]);
expressions[i].setParent(this);
}
for (int i = 0; i < scopes.length; i++) {
this.write(scopes[i]);
scopes[i].setParent(this);
}
this.write(elseScope);
elseScope.setParent(this);
}
public boolean hasElseScope() {
return !this.elseScope.isEmpty();
}
public ExpressionNode[] getExpressions() {
return expressions;
}
public ScopeNode[] getScopes() {
return scopes;
}
public ScopeNode getElseScope() {
return elseScope;
}
@Override
| public void print(CodePrinter printer) {
|
SignalK/signalk-server-java | src/test/java/nz/co/fortytwo/signalk/processor/SourceRefToSourceProcessorTest.java | // Path: src/main/java/nz/co/fortytwo/signalk/server/RouteManagerFactory.java
// public class RouteManagerFactory {
//
// private static Logger logger = LogManager.getLogger(RouteManagerFactory.class);
// static RouteManager manager = null;
//
// public static RouteManager getInstance() throws FileNotFoundException, IOException{
// Util.getConfig();
// if(manager==null){
//
// manager=new RouteManager();
// //must do this early!
// CamelContextFactory.setContext(manager);
//
// }
// return manager;
// }
//
// /**
// * Returns an env setup with the test config.
// * @return
// * @throws FileNotFoundException
// * @throws IOException
// */
// public static RouteManager getMotuTestInstance() throws FileNotFoundException, IOException{
// SignalKModel model = SignalKModelFactory.getMotuTestInstance();
// Util.setConfig(model);
// if(manager==null){
//
// manager=new RouteManager();
// //must do this early!
// CamelContextFactory.setContext(manager);
//
// }
// return manager;
// }
//
// /**
// * For testing
// */
// public static void clear(){
// manager = null;
// }
// }
| import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger;
import org.junit.Test;
import nz.co.fortytwo.signalk.model.SignalKModel;
import nz.co.fortytwo.signalk.model.impl.SignalKModelFactory;
import nz.co.fortytwo.signalk.server.RouteManagerFactory;
import static org.junit.Assert.assertEquals;
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.impl.DefaultExchange; | /*
*
* Copyright (C) 2012-2014 R T Huitema. All Rights Reserved.
* Web: www.42.co.nz
* Email: robert@42.co.nz
* Author: R T Huitema
*
* This file is part of the signalk-server-java project
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* 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 nz.co.fortytwo.signalk.processor;
public class SourceRefToSourceProcessorTest {
private static Logger logger = LogManager.getLogger(SourceRefToSourceProcessorTest.class);
@Test
public void shouldRemoveSourceRef() throws Exception { | // Path: src/main/java/nz/co/fortytwo/signalk/server/RouteManagerFactory.java
// public class RouteManagerFactory {
//
// private static Logger logger = LogManager.getLogger(RouteManagerFactory.class);
// static RouteManager manager = null;
//
// public static RouteManager getInstance() throws FileNotFoundException, IOException{
// Util.getConfig();
// if(manager==null){
//
// manager=new RouteManager();
// //must do this early!
// CamelContextFactory.setContext(manager);
//
// }
// return manager;
// }
//
// /**
// * Returns an env setup with the test config.
// * @return
// * @throws FileNotFoundException
// * @throws IOException
// */
// public static RouteManager getMotuTestInstance() throws FileNotFoundException, IOException{
// SignalKModel model = SignalKModelFactory.getMotuTestInstance();
// Util.setConfig(model);
// if(manager==null){
//
// manager=new RouteManager();
// //must do this early!
// CamelContextFactory.setContext(manager);
//
// }
// return manager;
// }
//
// /**
// * For testing
// */
// public static void clear(){
// manager = null;
// }
// }
// Path: src/test/java/nz/co/fortytwo/signalk/processor/SourceRefToSourceProcessorTest.java
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger;
import org.junit.Test;
import nz.co.fortytwo.signalk.model.SignalKModel;
import nz.co.fortytwo.signalk.model.impl.SignalKModelFactory;
import nz.co.fortytwo.signalk.server.RouteManagerFactory;
import static org.junit.Assert.assertEquals;
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.impl.DefaultExchange;
/*
*
* Copyright (C) 2012-2014 R T Huitema. All Rights Reserved.
* Web: www.42.co.nz
* Email: robert@42.co.nz
* Author: R T Huitema
*
* This file is part of the signalk-server-java project
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* 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 nz.co.fortytwo.signalk.processor;
public class SourceRefToSourceProcessorTest {
private static Logger logger = LogManager.getLogger(SourceRefToSourceProcessorTest.class);
@Test
public void shouldRemoveSourceRef() throws Exception { | CamelContext ctx = RouteManagerFactory.getMotuTestInstance().getContext(); |
SignalK/signalk-server-java | src/test/java/nz/co/fortytwo/signalk/processor/ValidationProcessorTest.java | // Path: src/main/java/nz/co/fortytwo/signalk/server/RouteManagerFactory.java
// public class RouteManagerFactory {
//
// private static Logger logger = LogManager.getLogger(RouteManagerFactory.class);
// static RouteManager manager = null;
//
// public static RouteManager getInstance() throws FileNotFoundException, IOException{
// Util.getConfig();
// if(manager==null){
//
// manager=new RouteManager();
// //must do this early!
// CamelContextFactory.setContext(manager);
//
// }
// return manager;
// }
//
// /**
// * Returns an env setup with the test config.
// * @return
// * @throws FileNotFoundException
// * @throws IOException
// */
// public static RouteManager getMotuTestInstance() throws FileNotFoundException, IOException{
// SignalKModel model = SignalKModelFactory.getMotuTestInstance();
// Util.setConfig(model);
// if(manager==null){
//
// manager=new RouteManager();
// //must do this early!
// CamelContextFactory.setContext(manager);
//
// }
// return manager;
// }
//
// /**
// * For testing
// */
// public static void clear(){
// manager = null;
// }
// }
| import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.*;
import java.io.IOException;
import nz.co.fortytwo.signalk.model.SignalKModel;
import nz.co.fortytwo.signalk.model.impl.SignalKModelFactory;
import nz.co.fortytwo.signalk.server.RouteManagerFactory;
import nz.co.fortytwo.signalk.util.JsonSerializer;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static nz.co.fortytwo.signalk.util.SignalKConstants.dot;
import static nz.co.fortytwo.signalk.util.SignalKConstants.env_wind_directionChangeAlarm;
import static nz.co.fortytwo.signalk.util.SignalKConstants.env_wind_speedTrue;
import static nz.co.fortytwo.signalk.util.SignalKConstants.sourceRef;
import static nz.co.fortytwo.signalk.util.SignalKConstants.timestamp;
import static nz.co.fortytwo.signalk.util.SignalKConstants.value;
import static nz.co.fortytwo.signalk.util.SignalKConstants.vessels_dot_self_dot; | /*
*
* Copyright (C) 2012-2014 R T Huitema. All Rights Reserved.
* Web: www.42.co.nz
* Email: robert@42.co.nz
* Author: R T Huitema
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* 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 nz.co.fortytwo.signalk.processor;
public class ValidationProcessorTest {
private static Logger logger = LogManager.getLogger(ValidationProcessorTest.class);
private JsonSerializer ser = new JsonSerializer();
@Before
public void setUp() throws Exception { | // Path: src/main/java/nz/co/fortytwo/signalk/server/RouteManagerFactory.java
// public class RouteManagerFactory {
//
// private static Logger logger = LogManager.getLogger(RouteManagerFactory.class);
// static RouteManager manager = null;
//
// public static RouteManager getInstance() throws FileNotFoundException, IOException{
// Util.getConfig();
// if(manager==null){
//
// manager=new RouteManager();
// //must do this early!
// CamelContextFactory.setContext(manager);
//
// }
// return manager;
// }
//
// /**
// * Returns an env setup with the test config.
// * @return
// * @throws FileNotFoundException
// * @throws IOException
// */
// public static RouteManager getMotuTestInstance() throws FileNotFoundException, IOException{
// SignalKModel model = SignalKModelFactory.getMotuTestInstance();
// Util.setConfig(model);
// if(manager==null){
//
// manager=new RouteManager();
// //must do this early!
// CamelContextFactory.setContext(manager);
//
// }
// return manager;
// }
//
// /**
// * For testing
// */
// public static void clear(){
// manager = null;
// }
// }
// Path: src/test/java/nz/co/fortytwo/signalk/processor/ValidationProcessorTest.java
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.*;
import java.io.IOException;
import nz.co.fortytwo.signalk.model.SignalKModel;
import nz.co.fortytwo.signalk.model.impl.SignalKModelFactory;
import nz.co.fortytwo.signalk.server.RouteManagerFactory;
import nz.co.fortytwo.signalk.util.JsonSerializer;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static nz.co.fortytwo.signalk.util.SignalKConstants.dot;
import static nz.co.fortytwo.signalk.util.SignalKConstants.env_wind_directionChangeAlarm;
import static nz.co.fortytwo.signalk.util.SignalKConstants.env_wind_speedTrue;
import static nz.co.fortytwo.signalk.util.SignalKConstants.sourceRef;
import static nz.co.fortytwo.signalk.util.SignalKConstants.timestamp;
import static nz.co.fortytwo.signalk.util.SignalKConstants.value;
import static nz.co.fortytwo.signalk.util.SignalKConstants.vessels_dot_self_dot;
/*
*
* Copyright (C) 2012-2014 R T Huitema. All Rights Reserved.
* Web: www.42.co.nz
* Email: robert@42.co.nz
* Author: R T Huitema
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* 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 nz.co.fortytwo.signalk.processor;
public class ValidationProcessorTest {
private static Logger logger = LogManager.getLogger(ValidationProcessorTest.class);
private JsonSerializer ser = new JsonSerializer();
@Before
public void setUp() throws Exception { | RouteManagerFactory.getMotuTestInstance(); |
SignalK/signalk-server-java | src/test/java/nz/co/fortytwo/signalk/processor/SourceToSourceRefProcessorTest.java | // Path: src/main/java/nz/co/fortytwo/signalk/server/RouteManagerFactory.java
// public class RouteManagerFactory {
//
// private static Logger logger = LogManager.getLogger(RouteManagerFactory.class);
// static RouteManager manager = null;
//
// public static RouteManager getInstance() throws FileNotFoundException, IOException{
// Util.getConfig();
// if(manager==null){
//
// manager=new RouteManager();
// //must do this early!
// CamelContextFactory.setContext(manager);
//
// }
// return manager;
// }
//
// /**
// * Returns an env setup with the test config.
// * @return
// * @throws FileNotFoundException
// * @throws IOException
// */
// public static RouteManager getMotuTestInstance() throws FileNotFoundException, IOException{
// SignalKModel model = SignalKModelFactory.getMotuTestInstance();
// Util.setConfig(model);
// if(manager==null){
//
// manager=new RouteManager();
// //must do this early!
// CamelContextFactory.setContext(manager);
//
// }
// return manager;
// }
//
// /**
// * For testing
// */
// public static void clear(){
// manager = null;
// }
// }
| import static nz.co.fortytwo.signalk.util.SignalKConstants.MSG_TYPE;
import static nz.co.fortytwo.signalk.util.SignalKConstants.dot;
import static nz.co.fortytwo.signalk.util.SignalKConstants.env_outside_pressure;
import static nz.co.fortytwo.signalk.util.SignalKConstants.nav_courseOverGroundMagnetic;
import static nz.co.fortytwo.signalk.util.SignalKConstants.nav_courseOverGroundTrue;
import static nz.co.fortytwo.signalk.util.SignalKConstants.source;
import static nz.co.fortytwo.signalk.util.SignalKConstants.sourceRef;
import static nz.co.fortytwo.signalk.util.SignalKConstants.sources;
import static nz.co.fortytwo.signalk.util.SignalKConstants.vessels_dot_self_dot;
import static org.junit.Assert.*;
import java.io.FileNotFoundException;
import java.io.IOException;
import nz.co.fortytwo.signalk.model.SignalKModel;
import nz.co.fortytwo.signalk.model.impl.SignalKModelFactory;
import nz.co.fortytwo.signalk.model.impl.SignalKModelImpl;
import nz.co.fortytwo.signalk.server.RouteManagerFactory;
import nz.co.fortytwo.signalk.util.TestHelper;
import nz.co.fortytwo.signalk.util.Util;
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.impl.DefaultExchange;
import org.apache.camel.util.ExchangeHelper;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger;
import org.junit.Test; | /*
*
* Copyright (C) 2012-2014 R T Huitema. All Rights Reserved.
* Web: www.42.co.nz
* Email: robert@42.co.nz
* Author: R T Huitema
*
* This file is part of the signalk-server-java project
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* 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 nz.co.fortytwo.signalk.processor;
public class SourceToSourceRefProcessorTest{
private static Logger logger = LogManager.getLogger(SourceToSourceRefProcessorTest.class);
@Test
public void shouldMoveSource() throws Exception { | // Path: src/main/java/nz/co/fortytwo/signalk/server/RouteManagerFactory.java
// public class RouteManagerFactory {
//
// private static Logger logger = LogManager.getLogger(RouteManagerFactory.class);
// static RouteManager manager = null;
//
// public static RouteManager getInstance() throws FileNotFoundException, IOException{
// Util.getConfig();
// if(manager==null){
//
// manager=new RouteManager();
// //must do this early!
// CamelContextFactory.setContext(manager);
//
// }
// return manager;
// }
//
// /**
// * Returns an env setup with the test config.
// * @return
// * @throws FileNotFoundException
// * @throws IOException
// */
// public static RouteManager getMotuTestInstance() throws FileNotFoundException, IOException{
// SignalKModel model = SignalKModelFactory.getMotuTestInstance();
// Util.setConfig(model);
// if(manager==null){
//
// manager=new RouteManager();
// //must do this early!
// CamelContextFactory.setContext(manager);
//
// }
// return manager;
// }
//
// /**
// * For testing
// */
// public static void clear(){
// manager = null;
// }
// }
// Path: src/test/java/nz/co/fortytwo/signalk/processor/SourceToSourceRefProcessorTest.java
import static nz.co.fortytwo.signalk.util.SignalKConstants.MSG_TYPE;
import static nz.co.fortytwo.signalk.util.SignalKConstants.dot;
import static nz.co.fortytwo.signalk.util.SignalKConstants.env_outside_pressure;
import static nz.co.fortytwo.signalk.util.SignalKConstants.nav_courseOverGroundMagnetic;
import static nz.co.fortytwo.signalk.util.SignalKConstants.nav_courseOverGroundTrue;
import static nz.co.fortytwo.signalk.util.SignalKConstants.source;
import static nz.co.fortytwo.signalk.util.SignalKConstants.sourceRef;
import static nz.co.fortytwo.signalk.util.SignalKConstants.sources;
import static nz.co.fortytwo.signalk.util.SignalKConstants.vessels_dot_self_dot;
import static org.junit.Assert.*;
import java.io.FileNotFoundException;
import java.io.IOException;
import nz.co.fortytwo.signalk.model.SignalKModel;
import nz.co.fortytwo.signalk.model.impl.SignalKModelFactory;
import nz.co.fortytwo.signalk.model.impl.SignalKModelImpl;
import nz.co.fortytwo.signalk.server.RouteManagerFactory;
import nz.co.fortytwo.signalk.util.TestHelper;
import nz.co.fortytwo.signalk.util.Util;
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.impl.DefaultExchange;
import org.apache.camel.util.ExchangeHelper;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger;
import org.junit.Test;
/*
*
* Copyright (C) 2012-2014 R T Huitema. All Rights Reserved.
* Web: www.42.co.nz
* Email: robert@42.co.nz
* Author: R T Huitema
*
* This file is part of the signalk-server-java project
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* 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 nz.co.fortytwo.signalk.processor;
public class SourceToSourceRefProcessorTest{
private static Logger logger = LogManager.getLogger(SourceToSourceRefProcessorTest.class);
@Test
public void shouldMoveSource() throws Exception { | CamelContext ctx = RouteManagerFactory.getMotuTestInstance().getContext(); |
SignalK/signalk-server-java | src/test/java/nz/co/fortytwo/signalk/processor/SignalkModelProcessorTest.java | // Path: src/main/java/nz/co/fortytwo/signalk/server/RouteManagerFactory.java
// public class RouteManagerFactory {
//
// private static Logger logger = LogManager.getLogger(RouteManagerFactory.class);
// static RouteManager manager = null;
//
// public static RouteManager getInstance() throws FileNotFoundException, IOException{
// Util.getConfig();
// if(manager==null){
//
// manager=new RouteManager();
// //must do this early!
// CamelContextFactory.setContext(manager);
//
// }
// return manager;
// }
//
// /**
// * Returns an env setup with the test config.
// * @return
// * @throws FileNotFoundException
// * @throws IOException
// */
// public static RouteManager getMotuTestInstance() throws FileNotFoundException, IOException{
// SignalKModel model = SignalKModelFactory.getMotuTestInstance();
// Util.setConfig(model);
// if(manager==null){
//
// manager=new RouteManager();
// //must do this early!
// CamelContextFactory.setContext(manager);
//
// }
// return manager;
// }
//
// /**
// * For testing
// */
// public static void clear(){
// manager = null;
// }
// }
| import static nz.co.fortytwo.signalk.util.SignalKConstants.dot;
import static nz.co.fortytwo.signalk.util.SignalKConstants.nav_courseOverGroundTrue;
import static nz.co.fortytwo.signalk.util.SignalKConstants.sourceRef;
import static nz.co.fortytwo.signalk.util.SignalKConstants.timestamp;
import static nz.co.fortytwo.signalk.util.SignalKConstants.value;
import static nz.co.fortytwo.signalk.util.SignalKConstants.vessels;
import static nz.co.fortytwo.signalk.util.SignalKConstants.vessels_dot_self_dot;
import java.io.IOException;
import java.util.NavigableMap;
import nz.co.fortytwo.signalk.model.SignalKModel;
import nz.co.fortytwo.signalk.model.impl.SignalKModelFactory;
import nz.co.fortytwo.signalk.server.RouteManagerFactory;
import nz.co.fortytwo.signalk.util.JsonSerializer;
import nz.co.fortytwo.signalk.util.SignalKConstants;
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.impl.DefaultExchange;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test; | /*
*
* Copyright (C) 2012-2014 R T Huitema. All Rights Reserved.
* Web: www.42.co.nz
* Email: robert@42.co.nz
* Author: R T Huitema
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* 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 nz.co.fortytwo.signalk.processor;
public class SignalkModelProcessorTest extends CamelTestSupport {
@BeforeClass
public static void init() throws Exception {
SignalKModelFactory.getMotuTestInstance();
}
@Before
public void setUp() throws Exception { | // Path: src/main/java/nz/co/fortytwo/signalk/server/RouteManagerFactory.java
// public class RouteManagerFactory {
//
// private static Logger logger = LogManager.getLogger(RouteManagerFactory.class);
// static RouteManager manager = null;
//
// public static RouteManager getInstance() throws FileNotFoundException, IOException{
// Util.getConfig();
// if(manager==null){
//
// manager=new RouteManager();
// //must do this early!
// CamelContextFactory.setContext(manager);
//
// }
// return manager;
// }
//
// /**
// * Returns an env setup with the test config.
// * @return
// * @throws FileNotFoundException
// * @throws IOException
// */
// public static RouteManager getMotuTestInstance() throws FileNotFoundException, IOException{
// SignalKModel model = SignalKModelFactory.getMotuTestInstance();
// Util.setConfig(model);
// if(manager==null){
//
// manager=new RouteManager();
// //must do this early!
// CamelContextFactory.setContext(manager);
//
// }
// return manager;
// }
//
// /**
// * For testing
// */
// public static void clear(){
// manager = null;
// }
// }
// Path: src/test/java/nz/co/fortytwo/signalk/processor/SignalkModelProcessorTest.java
import static nz.co.fortytwo.signalk.util.SignalKConstants.dot;
import static nz.co.fortytwo.signalk.util.SignalKConstants.nav_courseOverGroundTrue;
import static nz.co.fortytwo.signalk.util.SignalKConstants.sourceRef;
import static nz.co.fortytwo.signalk.util.SignalKConstants.timestamp;
import static nz.co.fortytwo.signalk.util.SignalKConstants.value;
import static nz.co.fortytwo.signalk.util.SignalKConstants.vessels;
import static nz.co.fortytwo.signalk.util.SignalKConstants.vessels_dot_self_dot;
import java.io.IOException;
import java.util.NavigableMap;
import nz.co.fortytwo.signalk.model.SignalKModel;
import nz.co.fortytwo.signalk.model.impl.SignalKModelFactory;
import nz.co.fortytwo.signalk.server.RouteManagerFactory;
import nz.co.fortytwo.signalk.util.JsonSerializer;
import nz.co.fortytwo.signalk.util.SignalKConstants;
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.impl.DefaultExchange;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
/*
*
* Copyright (C) 2012-2014 R T Huitema. All Rights Reserved.
* Web: www.42.co.nz
* Email: robert@42.co.nz
* Author: R T Huitema
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* 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 nz.co.fortytwo.signalk.processor;
public class SignalkModelProcessorTest extends CamelTestSupport {
@BeforeClass
public static void init() throws Exception {
SignalKModelFactory.getMotuTestInstance();
}
@Before
public void setUp() throws Exception { | RouteManagerFactory.getMotuTestInstance(); |
SignalK/signalk-server-java | src/test/java/nz/co/fortytwo/signalk/server/SignalKCamelTestSupport.java | // Path: src/main/java/org/apache/camel/component/websocket/SignalkWebsocketComponent.java
// public class SignalkWebsocketComponent extends WebsocketComponent {
//
// protected WebsocketComponentServlet createServlet(NodeSynchronization sync, String pathSpec, Map<String, WebsocketComponentServlet> servlets,
// ServletContextHandler handler) {
// SignalkWebSocketServlet servlet = new SignalkWebSocketServlet(sync);
// servlets.put(pathSpec, servlet);
// handler.addServlet(new ServletHolder(servlet), pathSpec);
// return servlet;
// }
//
// }
| import mjson.Json;
import nz.co.fortytwo.signalk.model.SignalKModel;
import nz.co.fortytwo.signalk.model.impl.SignalKModelFactory;
import nz.co.fortytwo.signalk.util.ConfigConstants;
import nz.co.fortytwo.signalk.util.JsonSerializer;
import nz.co.fortytwo.signalk.util.Util;
import org.apache.activemq.broker.BrokerService;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.websocket.SignalkWebsocketComponent;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger;
import org.junit.After;
import org.junit.BeforeClass;
import static nz.co.fortytwo.signalk.util.SignalKConstants.FORMAT;
import static nz.co.fortytwo.signalk.util.SignalKConstants.GET;
import static nz.co.fortytwo.signalk.util.SignalKConstants.PATH;
import java.util.concurrent.CountDownLatch; | public Json getList(String context, String path) {
Json json = Json.read("{\"context\":\""+context+"\", \"list\": []}");
Json sub = Json.object();
sub.set("path",path);
json.at("list").add(sub);
logger.debug("Created json list: "+json);
return json;
}
public Json getGet(String context, String path, String format) {
Json json = Json.read("{\"context\":\"" + context + "\", \"get\": []}");
Json sub = Json.object();
sub.set(PATH, path);
sub.set(FORMAT, format);
json.at(GET).add(sub);
logger.debug("Created json get: " + json);
return json;
}
@Override
protected RouteBuilder createRouteBuilder() {
try {
try {
//Util.getConfig();
broker.start();
logger.debug("Started broker");
routeManager=new RouteManager(){
@Override
public void configure() throws Exception {
if(CamelContextFactory.getInstance().getComponent("skWebsocket")==null){ | // Path: src/main/java/org/apache/camel/component/websocket/SignalkWebsocketComponent.java
// public class SignalkWebsocketComponent extends WebsocketComponent {
//
// protected WebsocketComponentServlet createServlet(NodeSynchronization sync, String pathSpec, Map<String, WebsocketComponentServlet> servlets,
// ServletContextHandler handler) {
// SignalkWebSocketServlet servlet = new SignalkWebSocketServlet(sync);
// servlets.put(pathSpec, servlet);
// handler.addServlet(new ServletHolder(servlet), pathSpec);
// return servlet;
// }
//
// }
// Path: src/test/java/nz/co/fortytwo/signalk/server/SignalKCamelTestSupport.java
import mjson.Json;
import nz.co.fortytwo.signalk.model.SignalKModel;
import nz.co.fortytwo.signalk.model.impl.SignalKModelFactory;
import nz.co.fortytwo.signalk.util.ConfigConstants;
import nz.co.fortytwo.signalk.util.JsonSerializer;
import nz.co.fortytwo.signalk.util.Util;
import org.apache.activemq.broker.BrokerService;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.websocket.SignalkWebsocketComponent;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger;
import org.junit.After;
import org.junit.BeforeClass;
import static nz.co.fortytwo.signalk.util.SignalKConstants.FORMAT;
import static nz.co.fortytwo.signalk.util.SignalKConstants.GET;
import static nz.co.fortytwo.signalk.util.SignalKConstants.PATH;
import java.util.concurrent.CountDownLatch;
public Json getList(String context, String path) {
Json json = Json.read("{\"context\":\""+context+"\", \"list\": []}");
Json sub = Json.object();
sub.set("path",path);
json.at("list").add(sub);
logger.debug("Created json list: "+json);
return json;
}
public Json getGet(String context, String path, String format) {
Json json = Json.read("{\"context\":\"" + context + "\", \"get\": []}");
Json sub = Json.object();
sub.set(PATH, path);
sub.set(FORMAT, format);
json.at(GET).add(sub);
logger.debug("Created json get: " + json);
return json;
}
@Override
protected RouteBuilder createRouteBuilder() {
try {
try {
//Util.getConfig();
broker.start();
logger.debug("Started broker");
routeManager=new RouteManager(){
@Override
public void configure() throws Exception {
if(CamelContextFactory.getInstance().getComponent("skWebsocket")==null){ | CamelContextFactory.getInstance().addComponent("skWebsocket", new SignalkWebsocketComponent()); |
NikitaKozlov/MVP-Navigation | app/src/main/java/org/kaerdan/mvp_navigation/example1_activities/FavoriteListActivity.java | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/favorite_list/FavoriteListContract.java
// public interface FavoriteListContract {
// interface Presenter extends org.kaerdan.mvp_navigation.core.Presenter<View> {
// void setNavigator(@NonNull Navigator navigator);
// }
//
// interface View extends org.kaerdan.mvp_navigation.core.Presenter.View {
// void displayArticles(@NonNull List<Article> articles, @NonNull OnArticleClickListener onArticleClickListener);
// }
//
// interface Navigator {
// void openArticle(int id);
// }
//
// interface NavigatorProvider {
//
// @NonNull
// Navigator getNavigator(FavoriteListContract.Presenter presenter);
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/favorite_list/FavoriteListFragment.java
// public class FavoriteListFragment extends Fragment implements FavoriteListContract.View {
//
// private FavoriteListContract.Presenter mPresenter;
//
// private RecyclerView mRecyclerView;
//
// public FavoriteListFragment() {
// // Required empty public constructor
// }
//
// @Override
// public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
// final Bundle savedInstanceState) {
// mPresenter = createPresenter();
//
// // Inflate the layout for this fragment
// mRecyclerView = (RecyclerView) inflater.inflate(R.layout.fragment_favorite_article_list, container, false);
// mRecyclerView.setLayoutManager(new LinearLayoutManager(container.getContext(), LinearLayoutManager.VERTICAL,
// false));
// return mRecyclerView;
// }
//
// @NonNull
// protected FavoriteListContract.Presenter createPresenter() {
// FavoriteListContract.Presenter presenter = new FavoriteListPresenter();
// presenter.setNavigator(getNavigator(presenter));
// return presenter;
// }
//
// @NonNull
// protected FavoriteListContract.Navigator getNavigator(final FavoriteListContract.Presenter presenter) {
// Fragment parentFragment = getParentFragment();
// if (parentFragment != null && parentFragment instanceof FavoriteListContract.NavigatorProvider) {
// return ((FavoriteListContract.NavigatorProvider) parentFragment).getNavigator(presenter);
// } else {
// Activity activity = getActivity();
// if (activity instanceof FavoriteListContract.NavigatorProvider) {
// return ((FavoriteListContract.NavigatorProvider) activity).getNavigator(presenter);
// }
// }
//
// throw new IllegalStateException("Activity or parent Fragment must implement "
// + "FavoriteListContract.NavigatorProvider");
// }
//
// @Override
// public void onStart() {
// super.onStart();
// mPresenter.onAttachView(this);
// }
//
// @Override
// public void onStop() {
// super.onStop();
// mPresenter.onDetachView();
// }
//
// @Override
// public void displayArticles(@NonNull final List<Article> articles,
// @NonNull final OnArticleClickListener onArticleClickListener) {
// mRecyclerView.setAdapter(new ArticleListAdapter(articles, onArticleClickListener));
// }
// }
| import org.kaerdan.mvp_navigation.R;
import org.kaerdan.mvp_navigation.core.ui.favorite_list.FavoriteListContract;
import org.kaerdan.mvp_navigation.core.ui.favorite_list.FavoriteListFragment;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.view.MenuItem; | package org.kaerdan.mvp_navigation.example1_activities;
public class FavoriteListActivity extends AppCompatActivity implements FavoriteListContract.NavigatorProvider {
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_single_fragment);
if (savedInstanceState == null) { | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/favorite_list/FavoriteListContract.java
// public interface FavoriteListContract {
// interface Presenter extends org.kaerdan.mvp_navigation.core.Presenter<View> {
// void setNavigator(@NonNull Navigator navigator);
// }
//
// interface View extends org.kaerdan.mvp_navigation.core.Presenter.View {
// void displayArticles(@NonNull List<Article> articles, @NonNull OnArticleClickListener onArticleClickListener);
// }
//
// interface Navigator {
// void openArticle(int id);
// }
//
// interface NavigatorProvider {
//
// @NonNull
// Navigator getNavigator(FavoriteListContract.Presenter presenter);
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/favorite_list/FavoriteListFragment.java
// public class FavoriteListFragment extends Fragment implements FavoriteListContract.View {
//
// private FavoriteListContract.Presenter mPresenter;
//
// private RecyclerView mRecyclerView;
//
// public FavoriteListFragment() {
// // Required empty public constructor
// }
//
// @Override
// public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
// final Bundle savedInstanceState) {
// mPresenter = createPresenter();
//
// // Inflate the layout for this fragment
// mRecyclerView = (RecyclerView) inflater.inflate(R.layout.fragment_favorite_article_list, container, false);
// mRecyclerView.setLayoutManager(new LinearLayoutManager(container.getContext(), LinearLayoutManager.VERTICAL,
// false));
// return mRecyclerView;
// }
//
// @NonNull
// protected FavoriteListContract.Presenter createPresenter() {
// FavoriteListContract.Presenter presenter = new FavoriteListPresenter();
// presenter.setNavigator(getNavigator(presenter));
// return presenter;
// }
//
// @NonNull
// protected FavoriteListContract.Navigator getNavigator(final FavoriteListContract.Presenter presenter) {
// Fragment parentFragment = getParentFragment();
// if (parentFragment != null && parentFragment instanceof FavoriteListContract.NavigatorProvider) {
// return ((FavoriteListContract.NavigatorProvider) parentFragment).getNavigator(presenter);
// } else {
// Activity activity = getActivity();
// if (activity instanceof FavoriteListContract.NavigatorProvider) {
// return ((FavoriteListContract.NavigatorProvider) activity).getNavigator(presenter);
// }
// }
//
// throw new IllegalStateException("Activity or parent Fragment must implement "
// + "FavoriteListContract.NavigatorProvider");
// }
//
// @Override
// public void onStart() {
// super.onStart();
// mPresenter.onAttachView(this);
// }
//
// @Override
// public void onStop() {
// super.onStop();
// mPresenter.onDetachView();
// }
//
// @Override
// public void displayArticles(@NonNull final List<Article> articles,
// @NonNull final OnArticleClickListener onArticleClickListener) {
// mRecyclerView.setAdapter(new ArticleListAdapter(articles, onArticleClickListener));
// }
// }
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example1_activities/FavoriteListActivity.java
import org.kaerdan.mvp_navigation.R;
import org.kaerdan.mvp_navigation.core.ui.favorite_list.FavoriteListContract;
import org.kaerdan.mvp_navigation.core.ui.favorite_list.FavoriteListFragment;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.view.MenuItem;
package org.kaerdan.mvp_navigation.example1_activities;
public class FavoriteListActivity extends AppCompatActivity implements FavoriteListContract.NavigatorProvider {
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_single_fragment);
if (savedInstanceState == null) { | getSupportFragmentManager().beginTransaction().add(R.id.content_frame, new FavoriteListFragment(), null) |
NikitaKozlov/MVP-Navigation | app/src/main/java/org/kaerdan/mvp_navigation/example4_injection/InjectActivityNavigator.java | // Path: app/src/main/java/org/kaerdan/mvp_navigation/example1_activities/ArticleActivity.java
// public class ArticleActivity extends AppCompatActivity {
//
// private static final String ARTICLE_ID_TAG = "Article id";
//
// public static Intent createIntent(final Context context, final int id) {
// Intent intent = new Intent(context, ArticleActivity.class);
// intent.putExtra(ARTICLE_ID_TAG, id);
// return intent;
// }
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_single_fragment);
// if (savedInstanceState == null) {
// getSupportFragmentManager().beginTransaction()
// .add(R.id.content_frame,
// ArticleFragment.newInstance(getIntent().getIntExtra(ARTICLE_ID_TAG, 0)), null).commit();
// }
//
// getSupportActionBar().setHomeButtonEnabled(true);
// getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// }
//
// @Override
// public boolean onOptionsItemSelected(final MenuItem item) {
// if (item.getItemId() == android.R.id.home) {
// onBackPressed();
// return true;
// }
//
// return super.onOptionsItemSelected(item);
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example1_activities/FavoriteListActivity.java
// public class FavoriteListActivity extends AppCompatActivity implements FavoriteListContract.NavigatorProvider {
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_single_fragment);
// if (savedInstanceState == null) {
// getSupportFragmentManager().beginTransaction().add(R.id.content_frame, new FavoriteListFragment(), null)
// .commit();
// }
//
// getSupportActionBar().setHomeButtonEnabled(true);
// getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// }
//
// @Override
// public boolean onOptionsItemSelected(final MenuItem item) {
// if (item.getItemId() == android.R.id.home) {
// onBackPressed();
// return true;
// }
//
// return super.onOptionsItemSelected(item);
// }
//
// @NonNull
// @Override
// public FavoriteListContract.Navigator getNavigator(final FavoriteListContract.Presenter presenter) {
// return new ActivitiesFavoriteListNavigator(this);
// }
// }
| import org.kaerdan.mvp_navigation.example1_activities.ArticleActivity;
import org.kaerdan.mvp_navigation.example1_activities.FavoriteListActivity;
import android.content.Context;
import android.content.Intent; | package org.kaerdan.mvp_navigation.example4_injection;
public class InjectActivityNavigator implements InjectArticleListContract.Navigator {
private final Context mActivityContext;
public InjectActivityNavigator(final Context activityContext) {
this.mActivityContext = activityContext;
}
@Override
public void openArticle(final int id) { | // Path: app/src/main/java/org/kaerdan/mvp_navigation/example1_activities/ArticleActivity.java
// public class ArticleActivity extends AppCompatActivity {
//
// private static final String ARTICLE_ID_TAG = "Article id";
//
// public static Intent createIntent(final Context context, final int id) {
// Intent intent = new Intent(context, ArticleActivity.class);
// intent.putExtra(ARTICLE_ID_TAG, id);
// return intent;
// }
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_single_fragment);
// if (savedInstanceState == null) {
// getSupportFragmentManager().beginTransaction()
// .add(R.id.content_frame,
// ArticleFragment.newInstance(getIntent().getIntExtra(ARTICLE_ID_TAG, 0)), null).commit();
// }
//
// getSupportActionBar().setHomeButtonEnabled(true);
// getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// }
//
// @Override
// public boolean onOptionsItemSelected(final MenuItem item) {
// if (item.getItemId() == android.R.id.home) {
// onBackPressed();
// return true;
// }
//
// return super.onOptionsItemSelected(item);
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example1_activities/FavoriteListActivity.java
// public class FavoriteListActivity extends AppCompatActivity implements FavoriteListContract.NavigatorProvider {
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_single_fragment);
// if (savedInstanceState == null) {
// getSupportFragmentManager().beginTransaction().add(R.id.content_frame, new FavoriteListFragment(), null)
// .commit();
// }
//
// getSupportActionBar().setHomeButtonEnabled(true);
// getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// }
//
// @Override
// public boolean onOptionsItemSelected(final MenuItem item) {
// if (item.getItemId() == android.R.id.home) {
// onBackPressed();
// return true;
// }
//
// return super.onOptionsItemSelected(item);
// }
//
// @NonNull
// @Override
// public FavoriteListContract.Navigator getNavigator(final FavoriteListContract.Presenter presenter) {
// return new ActivitiesFavoriteListNavigator(this);
// }
// }
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example4_injection/InjectActivityNavigator.java
import org.kaerdan.mvp_navigation.example1_activities.ArticleActivity;
import org.kaerdan.mvp_navigation.example1_activities.FavoriteListActivity;
import android.content.Context;
import android.content.Intent;
package org.kaerdan.mvp_navigation.example4_injection;
public class InjectActivityNavigator implements InjectArticleListContract.Navigator {
private final Context mActivityContext;
public InjectActivityNavigator(final Context activityContext) {
this.mActivityContext = activityContext;
}
@Override
public void openArticle(final int id) { | mActivityContext.startActivity(ArticleActivity.createIntent(mActivityContext, id)); |
NikitaKozlov/MVP-Navigation | app/src/main/java/org/kaerdan/mvp_navigation/example4_injection/InjectActivityNavigator.java | // Path: app/src/main/java/org/kaerdan/mvp_navigation/example1_activities/ArticleActivity.java
// public class ArticleActivity extends AppCompatActivity {
//
// private static final String ARTICLE_ID_TAG = "Article id";
//
// public static Intent createIntent(final Context context, final int id) {
// Intent intent = new Intent(context, ArticleActivity.class);
// intent.putExtra(ARTICLE_ID_TAG, id);
// return intent;
// }
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_single_fragment);
// if (savedInstanceState == null) {
// getSupportFragmentManager().beginTransaction()
// .add(R.id.content_frame,
// ArticleFragment.newInstance(getIntent().getIntExtra(ARTICLE_ID_TAG, 0)), null).commit();
// }
//
// getSupportActionBar().setHomeButtonEnabled(true);
// getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// }
//
// @Override
// public boolean onOptionsItemSelected(final MenuItem item) {
// if (item.getItemId() == android.R.id.home) {
// onBackPressed();
// return true;
// }
//
// return super.onOptionsItemSelected(item);
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example1_activities/FavoriteListActivity.java
// public class FavoriteListActivity extends AppCompatActivity implements FavoriteListContract.NavigatorProvider {
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_single_fragment);
// if (savedInstanceState == null) {
// getSupportFragmentManager().beginTransaction().add(R.id.content_frame, new FavoriteListFragment(), null)
// .commit();
// }
//
// getSupportActionBar().setHomeButtonEnabled(true);
// getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// }
//
// @Override
// public boolean onOptionsItemSelected(final MenuItem item) {
// if (item.getItemId() == android.R.id.home) {
// onBackPressed();
// return true;
// }
//
// return super.onOptionsItemSelected(item);
// }
//
// @NonNull
// @Override
// public FavoriteListContract.Navigator getNavigator(final FavoriteListContract.Presenter presenter) {
// return new ActivitiesFavoriteListNavigator(this);
// }
// }
| import org.kaerdan.mvp_navigation.example1_activities.ArticleActivity;
import org.kaerdan.mvp_navigation.example1_activities.FavoriteListActivity;
import android.content.Context;
import android.content.Intent; | package org.kaerdan.mvp_navigation.example4_injection;
public class InjectActivityNavigator implements InjectArticleListContract.Navigator {
private final Context mActivityContext;
public InjectActivityNavigator(final Context activityContext) {
this.mActivityContext = activityContext;
}
@Override
public void openArticle(final int id) {
mActivityContext.startActivity(ArticleActivity.createIntent(mActivityContext, id));
}
@Override
public void openFavoriteArticles() { | // Path: app/src/main/java/org/kaerdan/mvp_navigation/example1_activities/ArticleActivity.java
// public class ArticleActivity extends AppCompatActivity {
//
// private static final String ARTICLE_ID_TAG = "Article id";
//
// public static Intent createIntent(final Context context, final int id) {
// Intent intent = new Intent(context, ArticleActivity.class);
// intent.putExtra(ARTICLE_ID_TAG, id);
// return intent;
// }
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_single_fragment);
// if (savedInstanceState == null) {
// getSupportFragmentManager().beginTransaction()
// .add(R.id.content_frame,
// ArticleFragment.newInstance(getIntent().getIntExtra(ARTICLE_ID_TAG, 0)), null).commit();
// }
//
// getSupportActionBar().setHomeButtonEnabled(true);
// getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// }
//
// @Override
// public boolean onOptionsItemSelected(final MenuItem item) {
// if (item.getItemId() == android.R.id.home) {
// onBackPressed();
// return true;
// }
//
// return super.onOptionsItemSelected(item);
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example1_activities/FavoriteListActivity.java
// public class FavoriteListActivity extends AppCompatActivity implements FavoriteListContract.NavigatorProvider {
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_single_fragment);
// if (savedInstanceState == null) {
// getSupportFragmentManager().beginTransaction().add(R.id.content_frame, new FavoriteListFragment(), null)
// .commit();
// }
//
// getSupportActionBar().setHomeButtonEnabled(true);
// getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// }
//
// @Override
// public boolean onOptionsItemSelected(final MenuItem item) {
// if (item.getItemId() == android.R.id.home) {
// onBackPressed();
// return true;
// }
//
// return super.onOptionsItemSelected(item);
// }
//
// @NonNull
// @Override
// public FavoriteListContract.Navigator getNavigator(final FavoriteListContract.Presenter presenter) {
// return new ActivitiesFavoriteListNavigator(this);
// }
// }
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example4_injection/InjectActivityNavigator.java
import org.kaerdan.mvp_navigation.example1_activities.ArticleActivity;
import org.kaerdan.mvp_navigation.example1_activities.FavoriteListActivity;
import android.content.Context;
import android.content.Intent;
package org.kaerdan.mvp_navigation.example4_injection;
public class InjectActivityNavigator implements InjectArticleListContract.Navigator {
private final Context mActivityContext;
public InjectActivityNavigator(final Context activityContext) {
this.mActivityContext = activityContext;
}
@Override
public void openArticle(final int id) {
mActivityContext.startActivity(ArticleActivity.createIntent(mActivityContext, id));
}
@Override
public void openFavoriteArticles() { | mActivityContext.startActivity(new Intent(mActivityContext, FavoriteListActivity.class)); |
NikitaKozlov/MVP-Navigation | app/src/main/java/org/kaerdan/mvp_navigation/example1_activities/ArticleListActivity.java | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/article_list/ArticleListContract.java
// public interface ArticleListContract {
// interface Presenter extends org.kaerdan.mvp_navigation.core.Presenter<View> {
// void setNavigator(@NonNull Navigator navigator);
//
// void onFavoriteArticleClick();
// }
//
// interface View extends org.kaerdan.mvp_navigation.core.Presenter.View {
// void displayArticles(@NonNull List<Article> articles, @NonNull OnArticleClickListener onArticleClickListener);
// }
//
// interface Navigator {
// void openArticle(int id);
//
// void openFavoriteArticles();
// }
//
// interface NavigatorProvider {
//
// @NonNull
// Navigator getNavigator(ArticleListContract.Presenter presenter);
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/article_list/ArticleListFragment.java
// public class ArticleListFragment extends Fragment implements ArticleListContract.View {
//
// private ArticleListContract.Presenter mPresenter;
//
// private RecyclerView mRecyclerView;
//
// public ArticleListFragment() {
// // Required empty public constructor
// }
//
// @Override
// public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
// final Bundle savedInstanceState) {
// mPresenter = createPresenter();
//
// // Inflate the layout for this fragment
// View view = inflater.inflate(R.layout.fragment_article_list, container, false);
// mRecyclerView = (RecyclerView) view.findViewById(R.id.article_list);
// mRecyclerView.setLayoutManager(new LinearLayoutManager(container.getContext(), LinearLayoutManager.VERTICAL,
// false));
//
// view.findViewById(R.id.favorite_articles).setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(final View v) {
// mPresenter.onFavoriteArticleClick();
// }
// });
//
// return view;
// }
//
// @NonNull
// protected ArticleListContract.Presenter createPresenter() {
// ArticleListContract.Presenter presenter = new ArticleListPresenter();
// presenter.setNavigator(getNavigator(presenter));
// return presenter;
// }
//
// @NonNull
// protected ArticleListContract.Navigator getNavigator(final ArticleListContract.Presenter presenter) {
// Fragment parentFragment = getParentFragment();
// if (parentFragment != null && parentFragment instanceof ArticleListContract.NavigatorProvider) {
// return ((ArticleListContract.NavigatorProvider) parentFragment).getNavigator(presenter);
// } else {
// Activity activity = getActivity();
// if (activity instanceof ArticleListContract.NavigatorProvider) {
// return ((ArticleListContract.NavigatorProvider) activity).getNavigator(presenter);
// }
// }
//
// throw new IllegalStateException("Activity or parent Fragment must implement "
// + "ArticleListContract.NavigatorProvider");
// }
//
// @Override
// public void onStart() {
// super.onStart();
// mPresenter.onAttachView(this);
// }
//
// @Override
// public void onStop() {
// super.onStop();
// mPresenter.onDetachView();
// }
//
// @Override
// public void displayArticles(@NonNull final List<Article> articles,
// @NonNull final OnArticleClickListener onArticleClickListener) {
// mRecyclerView.setAdapter(new ArticleListAdapter(articles, onArticleClickListener));
// }
// }
| import org.kaerdan.mvp_navigation.R;
import org.kaerdan.mvp_navigation.core.ui.article_list.ArticleListContract;
import org.kaerdan.mvp_navigation.core.ui.article_list.ArticleListFragment;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity; | package org.kaerdan.mvp_navigation.example1_activities;
public class ArticleListActivity extends AppCompatActivity implements ArticleListContract.NavigatorProvider {
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_single_fragment);
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction() | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/article_list/ArticleListContract.java
// public interface ArticleListContract {
// interface Presenter extends org.kaerdan.mvp_navigation.core.Presenter<View> {
// void setNavigator(@NonNull Navigator navigator);
//
// void onFavoriteArticleClick();
// }
//
// interface View extends org.kaerdan.mvp_navigation.core.Presenter.View {
// void displayArticles(@NonNull List<Article> articles, @NonNull OnArticleClickListener onArticleClickListener);
// }
//
// interface Navigator {
// void openArticle(int id);
//
// void openFavoriteArticles();
// }
//
// interface NavigatorProvider {
//
// @NonNull
// Navigator getNavigator(ArticleListContract.Presenter presenter);
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/article_list/ArticleListFragment.java
// public class ArticleListFragment extends Fragment implements ArticleListContract.View {
//
// private ArticleListContract.Presenter mPresenter;
//
// private RecyclerView mRecyclerView;
//
// public ArticleListFragment() {
// // Required empty public constructor
// }
//
// @Override
// public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
// final Bundle savedInstanceState) {
// mPresenter = createPresenter();
//
// // Inflate the layout for this fragment
// View view = inflater.inflate(R.layout.fragment_article_list, container, false);
// mRecyclerView = (RecyclerView) view.findViewById(R.id.article_list);
// mRecyclerView.setLayoutManager(new LinearLayoutManager(container.getContext(), LinearLayoutManager.VERTICAL,
// false));
//
// view.findViewById(R.id.favorite_articles).setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(final View v) {
// mPresenter.onFavoriteArticleClick();
// }
// });
//
// return view;
// }
//
// @NonNull
// protected ArticleListContract.Presenter createPresenter() {
// ArticleListContract.Presenter presenter = new ArticleListPresenter();
// presenter.setNavigator(getNavigator(presenter));
// return presenter;
// }
//
// @NonNull
// protected ArticleListContract.Navigator getNavigator(final ArticleListContract.Presenter presenter) {
// Fragment parentFragment = getParentFragment();
// if (parentFragment != null && parentFragment instanceof ArticleListContract.NavigatorProvider) {
// return ((ArticleListContract.NavigatorProvider) parentFragment).getNavigator(presenter);
// } else {
// Activity activity = getActivity();
// if (activity instanceof ArticleListContract.NavigatorProvider) {
// return ((ArticleListContract.NavigatorProvider) activity).getNavigator(presenter);
// }
// }
//
// throw new IllegalStateException("Activity or parent Fragment must implement "
// + "ArticleListContract.NavigatorProvider");
// }
//
// @Override
// public void onStart() {
// super.onStart();
// mPresenter.onAttachView(this);
// }
//
// @Override
// public void onStop() {
// super.onStop();
// mPresenter.onDetachView();
// }
//
// @Override
// public void displayArticles(@NonNull final List<Article> articles,
// @NonNull final OnArticleClickListener onArticleClickListener) {
// mRecyclerView.setAdapter(new ArticleListAdapter(articles, onArticleClickListener));
// }
// }
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example1_activities/ArticleListActivity.java
import org.kaerdan.mvp_navigation.R;
import org.kaerdan.mvp_navigation.core.ui.article_list.ArticleListContract;
import org.kaerdan.mvp_navigation.core.ui.article_list.ArticleListFragment;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
package org.kaerdan.mvp_navigation.example1_activities;
public class ArticleListActivity extends AppCompatActivity implements ArticleListContract.NavigatorProvider {
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_single_fragment);
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction() | .add(R.id.content_frame, new ArticleListFragment(), null) |
NikitaKozlov/MVP-Navigation | app/src/main/java/org/kaerdan/mvp_navigation/core/ui/article/ArticleContract.java | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/Article.java
// public class Article {
// private final int id;
// private final String title;
// private final String body;
// private final boolean isFavourite;
//
// public Article(int id, String title, String body, boolean isFavourite) {
// this.id = id;
// this.title = title;
// this.body = body;
// this.isFavourite = isFavourite;
// }
//
// public int getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getBody() {
// return body;
// }
//
// public boolean isFavourite() {
// return isFavourite;
// }
// }
| import org.kaerdan.mvp_navigation.core.data.Article;
import android.support.annotation.NonNull; | package org.kaerdan.mvp_navigation.core.ui.article;
public interface ArticleContract {
interface Presenter extends org.kaerdan.mvp_navigation.core.Presenter<View> { }
interface View extends org.kaerdan.mvp_navigation.core.Presenter.View { | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/Article.java
// public class Article {
// private final int id;
// private final String title;
// private final String body;
// private final boolean isFavourite;
//
// public Article(int id, String title, String body, boolean isFavourite) {
// this.id = id;
// this.title = title;
// this.body = body;
// this.isFavourite = isFavourite;
// }
//
// public int getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getBody() {
// return body;
// }
//
// public boolean isFavourite() {
// return isFavourite;
// }
// }
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/article/ArticleContract.java
import org.kaerdan.mvp_navigation.core.data.Article;
import android.support.annotation.NonNull;
package org.kaerdan.mvp_navigation.core.ui.article;
public interface ArticleContract {
interface Presenter extends org.kaerdan.mvp_navigation.core.Presenter<View> { }
interface View extends org.kaerdan.mvp_navigation.core.Presenter.View { | void displayArticle(@NonNull Article article); |
NikitaKozlov/MVP-Navigation | app/src/main/java/org/kaerdan/mvp_navigation/core/ui/favorite_list/FavoriteListFragment.java | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/Article.java
// public class Article {
// private final int id;
// private final String title;
// private final String body;
// private final boolean isFavourite;
//
// public Article(int id, String title, String body, boolean isFavourite) {
// this.id = id;
// this.title = title;
// this.body = body;
// this.isFavourite = isFavourite;
// }
//
// public int getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getBody() {
// return body;
// }
//
// public boolean isFavourite() {
// return isFavourite;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/ArticleListAdapter.java
// public class ArticleListAdapter extends RecyclerView.Adapter<ArticleListAdapter.ArticleViewHolder> {
//
// private final List<Article> mArticles;
// private final OnArticleClickListener mOnArticleClickListener;
//
// public ArticleListAdapter(@NonNull final List<Article> articles,
// @NonNull final OnArticleClickListener onArticleClickListener) {
// this.mArticles = articles;
// this.mOnArticleClickListener = onArticleClickListener;
// }
//
// @Override
// public ArticleViewHolder onCreateViewHolder(final ViewGroup parent, final int viewType) {
// return new ArticleViewHolder(new Button(parent.getContext()));
// }
//
// @Override
// public void onBindViewHolder(final ArticleViewHolder holder, final int position) {
// final Article article = mArticles.get(position);
// ((Button) holder.itemView).setText(article.getTitle());
// holder.itemView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(final View v) {
// mOnArticleClickListener.onArticleClick(article.getId());
// }
// });
// }
//
// @Override
// public int getItemCount() {
// return mArticles.size();
// }
//
// static class ArticleViewHolder extends RecyclerView.ViewHolder {
// public ArticleViewHolder(final View itemView) {
// super(itemView);
// }
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/OnArticleClickListener.java
// public interface OnArticleClickListener {
// void onArticleClick(int id);
// }
| import java.util.List;
import org.kaerdan.mvp_navigation.R;
import org.kaerdan.mvp_navigation.core.data.Article;
import org.kaerdan.mvp_navigation.core.ui.ArticleListAdapter;
import org.kaerdan.mvp_navigation.core.ui.OnArticleClickListener;
import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup; |
@NonNull
protected FavoriteListContract.Navigator getNavigator(final FavoriteListContract.Presenter presenter) {
Fragment parentFragment = getParentFragment();
if (parentFragment != null && parentFragment instanceof FavoriteListContract.NavigatorProvider) {
return ((FavoriteListContract.NavigatorProvider) parentFragment).getNavigator(presenter);
} else {
Activity activity = getActivity();
if (activity instanceof FavoriteListContract.NavigatorProvider) {
return ((FavoriteListContract.NavigatorProvider) activity).getNavigator(presenter);
}
}
throw new IllegalStateException("Activity or parent Fragment must implement "
+ "FavoriteListContract.NavigatorProvider");
}
@Override
public void onStart() {
super.onStart();
mPresenter.onAttachView(this);
}
@Override
public void onStop() {
super.onStop();
mPresenter.onDetachView();
}
@Override | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/Article.java
// public class Article {
// private final int id;
// private final String title;
// private final String body;
// private final boolean isFavourite;
//
// public Article(int id, String title, String body, boolean isFavourite) {
// this.id = id;
// this.title = title;
// this.body = body;
// this.isFavourite = isFavourite;
// }
//
// public int getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getBody() {
// return body;
// }
//
// public boolean isFavourite() {
// return isFavourite;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/ArticleListAdapter.java
// public class ArticleListAdapter extends RecyclerView.Adapter<ArticleListAdapter.ArticleViewHolder> {
//
// private final List<Article> mArticles;
// private final OnArticleClickListener mOnArticleClickListener;
//
// public ArticleListAdapter(@NonNull final List<Article> articles,
// @NonNull final OnArticleClickListener onArticleClickListener) {
// this.mArticles = articles;
// this.mOnArticleClickListener = onArticleClickListener;
// }
//
// @Override
// public ArticleViewHolder onCreateViewHolder(final ViewGroup parent, final int viewType) {
// return new ArticleViewHolder(new Button(parent.getContext()));
// }
//
// @Override
// public void onBindViewHolder(final ArticleViewHolder holder, final int position) {
// final Article article = mArticles.get(position);
// ((Button) holder.itemView).setText(article.getTitle());
// holder.itemView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(final View v) {
// mOnArticleClickListener.onArticleClick(article.getId());
// }
// });
// }
//
// @Override
// public int getItemCount() {
// return mArticles.size();
// }
//
// static class ArticleViewHolder extends RecyclerView.ViewHolder {
// public ArticleViewHolder(final View itemView) {
// super(itemView);
// }
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/OnArticleClickListener.java
// public interface OnArticleClickListener {
// void onArticleClick(int id);
// }
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/favorite_list/FavoriteListFragment.java
import java.util.List;
import org.kaerdan.mvp_navigation.R;
import org.kaerdan.mvp_navigation.core.data.Article;
import org.kaerdan.mvp_navigation.core.ui.ArticleListAdapter;
import org.kaerdan.mvp_navigation.core.ui.OnArticleClickListener;
import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@NonNull
protected FavoriteListContract.Navigator getNavigator(final FavoriteListContract.Presenter presenter) {
Fragment parentFragment = getParentFragment();
if (parentFragment != null && parentFragment instanceof FavoriteListContract.NavigatorProvider) {
return ((FavoriteListContract.NavigatorProvider) parentFragment).getNavigator(presenter);
} else {
Activity activity = getActivity();
if (activity instanceof FavoriteListContract.NavigatorProvider) {
return ((FavoriteListContract.NavigatorProvider) activity).getNavigator(presenter);
}
}
throw new IllegalStateException("Activity or parent Fragment must implement "
+ "FavoriteListContract.NavigatorProvider");
}
@Override
public void onStart() {
super.onStart();
mPresenter.onAttachView(this);
}
@Override
public void onStop() {
super.onStop();
mPresenter.onDetachView();
}
@Override | public void displayArticles(@NonNull final List<Article> articles, |
NikitaKozlov/MVP-Navigation | app/src/main/java/org/kaerdan/mvp_navigation/core/ui/favorite_list/FavoriteListFragment.java | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/Article.java
// public class Article {
// private final int id;
// private final String title;
// private final String body;
// private final boolean isFavourite;
//
// public Article(int id, String title, String body, boolean isFavourite) {
// this.id = id;
// this.title = title;
// this.body = body;
// this.isFavourite = isFavourite;
// }
//
// public int getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getBody() {
// return body;
// }
//
// public boolean isFavourite() {
// return isFavourite;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/ArticleListAdapter.java
// public class ArticleListAdapter extends RecyclerView.Adapter<ArticleListAdapter.ArticleViewHolder> {
//
// private final List<Article> mArticles;
// private final OnArticleClickListener mOnArticleClickListener;
//
// public ArticleListAdapter(@NonNull final List<Article> articles,
// @NonNull final OnArticleClickListener onArticleClickListener) {
// this.mArticles = articles;
// this.mOnArticleClickListener = onArticleClickListener;
// }
//
// @Override
// public ArticleViewHolder onCreateViewHolder(final ViewGroup parent, final int viewType) {
// return new ArticleViewHolder(new Button(parent.getContext()));
// }
//
// @Override
// public void onBindViewHolder(final ArticleViewHolder holder, final int position) {
// final Article article = mArticles.get(position);
// ((Button) holder.itemView).setText(article.getTitle());
// holder.itemView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(final View v) {
// mOnArticleClickListener.onArticleClick(article.getId());
// }
// });
// }
//
// @Override
// public int getItemCount() {
// return mArticles.size();
// }
//
// static class ArticleViewHolder extends RecyclerView.ViewHolder {
// public ArticleViewHolder(final View itemView) {
// super(itemView);
// }
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/OnArticleClickListener.java
// public interface OnArticleClickListener {
// void onArticleClick(int id);
// }
| import java.util.List;
import org.kaerdan.mvp_navigation.R;
import org.kaerdan.mvp_navigation.core.data.Article;
import org.kaerdan.mvp_navigation.core.ui.ArticleListAdapter;
import org.kaerdan.mvp_navigation.core.ui.OnArticleClickListener;
import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup; | @NonNull
protected FavoriteListContract.Navigator getNavigator(final FavoriteListContract.Presenter presenter) {
Fragment parentFragment = getParentFragment();
if (parentFragment != null && parentFragment instanceof FavoriteListContract.NavigatorProvider) {
return ((FavoriteListContract.NavigatorProvider) parentFragment).getNavigator(presenter);
} else {
Activity activity = getActivity();
if (activity instanceof FavoriteListContract.NavigatorProvider) {
return ((FavoriteListContract.NavigatorProvider) activity).getNavigator(presenter);
}
}
throw new IllegalStateException("Activity or parent Fragment must implement "
+ "FavoriteListContract.NavigatorProvider");
}
@Override
public void onStart() {
super.onStart();
mPresenter.onAttachView(this);
}
@Override
public void onStop() {
super.onStop();
mPresenter.onDetachView();
}
@Override
public void displayArticles(@NonNull final List<Article> articles, | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/Article.java
// public class Article {
// private final int id;
// private final String title;
// private final String body;
// private final boolean isFavourite;
//
// public Article(int id, String title, String body, boolean isFavourite) {
// this.id = id;
// this.title = title;
// this.body = body;
// this.isFavourite = isFavourite;
// }
//
// public int getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getBody() {
// return body;
// }
//
// public boolean isFavourite() {
// return isFavourite;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/ArticleListAdapter.java
// public class ArticleListAdapter extends RecyclerView.Adapter<ArticleListAdapter.ArticleViewHolder> {
//
// private final List<Article> mArticles;
// private final OnArticleClickListener mOnArticleClickListener;
//
// public ArticleListAdapter(@NonNull final List<Article> articles,
// @NonNull final OnArticleClickListener onArticleClickListener) {
// this.mArticles = articles;
// this.mOnArticleClickListener = onArticleClickListener;
// }
//
// @Override
// public ArticleViewHolder onCreateViewHolder(final ViewGroup parent, final int viewType) {
// return new ArticleViewHolder(new Button(parent.getContext()));
// }
//
// @Override
// public void onBindViewHolder(final ArticleViewHolder holder, final int position) {
// final Article article = mArticles.get(position);
// ((Button) holder.itemView).setText(article.getTitle());
// holder.itemView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(final View v) {
// mOnArticleClickListener.onArticleClick(article.getId());
// }
// });
// }
//
// @Override
// public int getItemCount() {
// return mArticles.size();
// }
//
// static class ArticleViewHolder extends RecyclerView.ViewHolder {
// public ArticleViewHolder(final View itemView) {
// super(itemView);
// }
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/OnArticleClickListener.java
// public interface OnArticleClickListener {
// void onArticleClick(int id);
// }
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/favorite_list/FavoriteListFragment.java
import java.util.List;
import org.kaerdan.mvp_navigation.R;
import org.kaerdan.mvp_navigation.core.data.Article;
import org.kaerdan.mvp_navigation.core.ui.ArticleListAdapter;
import org.kaerdan.mvp_navigation.core.ui.OnArticleClickListener;
import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@NonNull
protected FavoriteListContract.Navigator getNavigator(final FavoriteListContract.Presenter presenter) {
Fragment parentFragment = getParentFragment();
if (parentFragment != null && parentFragment instanceof FavoriteListContract.NavigatorProvider) {
return ((FavoriteListContract.NavigatorProvider) parentFragment).getNavigator(presenter);
} else {
Activity activity = getActivity();
if (activity instanceof FavoriteListContract.NavigatorProvider) {
return ((FavoriteListContract.NavigatorProvider) activity).getNavigator(presenter);
}
}
throw new IllegalStateException("Activity or parent Fragment must implement "
+ "FavoriteListContract.NavigatorProvider");
}
@Override
public void onStart() {
super.onStart();
mPresenter.onAttachView(this);
}
@Override
public void onStop() {
super.onStop();
mPresenter.onDetachView();
}
@Override
public void displayArticles(@NonNull final List<Article> articles, | @NonNull final OnArticleClickListener onArticleClickListener) { |
NikitaKozlov/MVP-Navigation | app/src/main/java/org/kaerdan/mvp_navigation/core/ui/favorite_list/FavoriteListFragment.java | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/Article.java
// public class Article {
// private final int id;
// private final String title;
// private final String body;
// private final boolean isFavourite;
//
// public Article(int id, String title, String body, boolean isFavourite) {
// this.id = id;
// this.title = title;
// this.body = body;
// this.isFavourite = isFavourite;
// }
//
// public int getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getBody() {
// return body;
// }
//
// public boolean isFavourite() {
// return isFavourite;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/ArticleListAdapter.java
// public class ArticleListAdapter extends RecyclerView.Adapter<ArticleListAdapter.ArticleViewHolder> {
//
// private final List<Article> mArticles;
// private final OnArticleClickListener mOnArticleClickListener;
//
// public ArticleListAdapter(@NonNull final List<Article> articles,
// @NonNull final OnArticleClickListener onArticleClickListener) {
// this.mArticles = articles;
// this.mOnArticleClickListener = onArticleClickListener;
// }
//
// @Override
// public ArticleViewHolder onCreateViewHolder(final ViewGroup parent, final int viewType) {
// return new ArticleViewHolder(new Button(parent.getContext()));
// }
//
// @Override
// public void onBindViewHolder(final ArticleViewHolder holder, final int position) {
// final Article article = mArticles.get(position);
// ((Button) holder.itemView).setText(article.getTitle());
// holder.itemView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(final View v) {
// mOnArticleClickListener.onArticleClick(article.getId());
// }
// });
// }
//
// @Override
// public int getItemCount() {
// return mArticles.size();
// }
//
// static class ArticleViewHolder extends RecyclerView.ViewHolder {
// public ArticleViewHolder(final View itemView) {
// super(itemView);
// }
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/OnArticleClickListener.java
// public interface OnArticleClickListener {
// void onArticleClick(int id);
// }
| import java.util.List;
import org.kaerdan.mvp_navigation.R;
import org.kaerdan.mvp_navigation.core.data.Article;
import org.kaerdan.mvp_navigation.core.ui.ArticleListAdapter;
import org.kaerdan.mvp_navigation.core.ui.OnArticleClickListener;
import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup; | protected FavoriteListContract.Navigator getNavigator(final FavoriteListContract.Presenter presenter) {
Fragment parentFragment = getParentFragment();
if (parentFragment != null && parentFragment instanceof FavoriteListContract.NavigatorProvider) {
return ((FavoriteListContract.NavigatorProvider) parentFragment).getNavigator(presenter);
} else {
Activity activity = getActivity();
if (activity instanceof FavoriteListContract.NavigatorProvider) {
return ((FavoriteListContract.NavigatorProvider) activity).getNavigator(presenter);
}
}
throw new IllegalStateException("Activity or parent Fragment must implement "
+ "FavoriteListContract.NavigatorProvider");
}
@Override
public void onStart() {
super.onStart();
mPresenter.onAttachView(this);
}
@Override
public void onStop() {
super.onStop();
mPresenter.onDetachView();
}
@Override
public void displayArticles(@NonNull final List<Article> articles,
@NonNull final OnArticleClickListener onArticleClickListener) { | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/Article.java
// public class Article {
// private final int id;
// private final String title;
// private final String body;
// private final boolean isFavourite;
//
// public Article(int id, String title, String body, boolean isFavourite) {
// this.id = id;
// this.title = title;
// this.body = body;
// this.isFavourite = isFavourite;
// }
//
// public int getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getBody() {
// return body;
// }
//
// public boolean isFavourite() {
// return isFavourite;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/ArticleListAdapter.java
// public class ArticleListAdapter extends RecyclerView.Adapter<ArticleListAdapter.ArticleViewHolder> {
//
// private final List<Article> mArticles;
// private final OnArticleClickListener mOnArticleClickListener;
//
// public ArticleListAdapter(@NonNull final List<Article> articles,
// @NonNull final OnArticleClickListener onArticleClickListener) {
// this.mArticles = articles;
// this.mOnArticleClickListener = onArticleClickListener;
// }
//
// @Override
// public ArticleViewHolder onCreateViewHolder(final ViewGroup parent, final int viewType) {
// return new ArticleViewHolder(new Button(parent.getContext()));
// }
//
// @Override
// public void onBindViewHolder(final ArticleViewHolder holder, final int position) {
// final Article article = mArticles.get(position);
// ((Button) holder.itemView).setText(article.getTitle());
// holder.itemView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(final View v) {
// mOnArticleClickListener.onArticleClick(article.getId());
// }
// });
// }
//
// @Override
// public int getItemCount() {
// return mArticles.size();
// }
//
// static class ArticleViewHolder extends RecyclerView.ViewHolder {
// public ArticleViewHolder(final View itemView) {
// super(itemView);
// }
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/OnArticleClickListener.java
// public interface OnArticleClickListener {
// void onArticleClick(int id);
// }
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/favorite_list/FavoriteListFragment.java
import java.util.List;
import org.kaerdan.mvp_navigation.R;
import org.kaerdan.mvp_navigation.core.data.Article;
import org.kaerdan.mvp_navigation.core.ui.ArticleListAdapter;
import org.kaerdan.mvp_navigation.core.ui.OnArticleClickListener;
import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
protected FavoriteListContract.Navigator getNavigator(final FavoriteListContract.Presenter presenter) {
Fragment parentFragment = getParentFragment();
if (parentFragment != null && parentFragment instanceof FavoriteListContract.NavigatorProvider) {
return ((FavoriteListContract.NavigatorProvider) parentFragment).getNavigator(presenter);
} else {
Activity activity = getActivity();
if (activity instanceof FavoriteListContract.NavigatorProvider) {
return ((FavoriteListContract.NavigatorProvider) activity).getNavigator(presenter);
}
}
throw new IllegalStateException("Activity or parent Fragment must implement "
+ "FavoriteListContract.NavigatorProvider");
}
@Override
public void onStart() {
super.onStart();
mPresenter.onAttachView(this);
}
@Override
public void onStop() {
super.onStop();
mPresenter.onDetachView();
}
@Override
public void displayArticles(@NonNull final List<Article> articles,
@NonNull final OnArticleClickListener onArticleClickListener) { | mRecyclerView.setAdapter(new ArticleListAdapter(articles, onArticleClickListener)); |
NikitaKozlov/MVP-Navigation | app/src/main/java/org/kaerdan/mvp_navigation/core/ui/favorite_list/FavoriteListPresenter.java | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/DataProvider.java
// public class DataProvider {
//
// private static final Article ARTICLE_1 = new Article(1, "Article 1", "Article 1 body", false);
// private static final Article ARTICLE_2 = new Article(2, "Article 2", "Article 2 body", true);
// private static final Article ARTICLE_3 = new Article(3, "Article 3", "Article 3 body", false);
// private static final Article ARTICLE_4 = new Article(4, "Article 4", "Article 4 body", true);
// private static final Article ARTICLE_5 = new Article(5, "Article 5", "Article 5 body", false);
// private static final Article ARTICLE_6 = new Article(6, "Article 6", "Article 6 body", true);
// private static final Article ARTICLE_7 = new Article(7, "Article 7", "Article 7 body", false);
// private static final Article ARTICLE_8 = new Article(8, "Article 8", "Article 8 body", true);
// private static final Article ARTICLE_9 = new Article(9, "Article 9", "Article 9 body", false);
// private static final Article ARTICLE_10 = new Article(10, "Article 10", "Article 10 body", true);
//
// private static DataProvider sInstance = new DataProvider();
//
// public static DataProvider getInstance() {
// return sInstance;
// }
//
// private final List<Article> mArticles;
//
// private DataProvider() {
// mArticles = Arrays.asList(ARTICLE_1, ARTICLE_2, ARTICLE_3, ARTICLE_4, ARTICLE_5, ARTICLE_6, ARTICLE_7,
// ARTICLE_8, ARTICLE_9, ARTICLE_10);
// }
//
// public List<Article> getmArticles() {
// return mArticles;
// }
//
// public List<Article> getFavouriteArticles() {
// List<Article> favouriteArticles = new ArrayList<>();
// for (Article article : mArticles) {
// if (article.isFavourite()) {
// favouriteArticles.add(article);
// }
// }
//
// return favouriteArticles;
// }
//
// @Nullable
// public Article getArticleById(final int id) {
// for (Article article : mArticles) {
// if (id == article.getId()) {
// return article;
// }
// }
//
// return null;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/OnArticleClickListener.java
// public interface OnArticleClickListener {
// void onArticleClick(int id);
// }
| import org.kaerdan.mvp_navigation.core.data.DataProvider;
import org.kaerdan.mvp_navigation.core.ui.OnArticleClickListener;
import android.support.annotation.NonNull; | package org.kaerdan.mvp_navigation.core.ui.favorite_list;
public class FavoriteListPresenter implements FavoriteListContract.Presenter, OnArticleClickListener {
private FavoriteListContract.View view;
private FavoriteListContract.Navigator navigator;
@Override
public void onAttachView(final FavoriteListContract.View view) {
this.view = view;
// Usually this call goes asynchronous, but for this example it doesn't matter | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/DataProvider.java
// public class DataProvider {
//
// private static final Article ARTICLE_1 = new Article(1, "Article 1", "Article 1 body", false);
// private static final Article ARTICLE_2 = new Article(2, "Article 2", "Article 2 body", true);
// private static final Article ARTICLE_3 = new Article(3, "Article 3", "Article 3 body", false);
// private static final Article ARTICLE_4 = new Article(4, "Article 4", "Article 4 body", true);
// private static final Article ARTICLE_5 = new Article(5, "Article 5", "Article 5 body", false);
// private static final Article ARTICLE_6 = new Article(6, "Article 6", "Article 6 body", true);
// private static final Article ARTICLE_7 = new Article(7, "Article 7", "Article 7 body", false);
// private static final Article ARTICLE_8 = new Article(8, "Article 8", "Article 8 body", true);
// private static final Article ARTICLE_9 = new Article(9, "Article 9", "Article 9 body", false);
// private static final Article ARTICLE_10 = new Article(10, "Article 10", "Article 10 body", true);
//
// private static DataProvider sInstance = new DataProvider();
//
// public static DataProvider getInstance() {
// return sInstance;
// }
//
// private final List<Article> mArticles;
//
// private DataProvider() {
// mArticles = Arrays.asList(ARTICLE_1, ARTICLE_2, ARTICLE_3, ARTICLE_4, ARTICLE_5, ARTICLE_6, ARTICLE_7,
// ARTICLE_8, ARTICLE_9, ARTICLE_10);
// }
//
// public List<Article> getmArticles() {
// return mArticles;
// }
//
// public List<Article> getFavouriteArticles() {
// List<Article> favouriteArticles = new ArrayList<>();
// for (Article article : mArticles) {
// if (article.isFavourite()) {
// favouriteArticles.add(article);
// }
// }
//
// return favouriteArticles;
// }
//
// @Nullable
// public Article getArticleById(final int id) {
// for (Article article : mArticles) {
// if (id == article.getId()) {
// return article;
// }
// }
//
// return null;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/OnArticleClickListener.java
// public interface OnArticleClickListener {
// void onArticleClick(int id);
// }
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/favorite_list/FavoriteListPresenter.java
import org.kaerdan.mvp_navigation.core.data.DataProvider;
import org.kaerdan.mvp_navigation.core.ui.OnArticleClickListener;
import android.support.annotation.NonNull;
package org.kaerdan.mvp_navigation.core.ui.favorite_list;
public class FavoriteListPresenter implements FavoriteListContract.Presenter, OnArticleClickListener {
private FavoriteListContract.View view;
private FavoriteListContract.Navigator navigator;
@Override
public void onAttachView(final FavoriteListContract.View view) {
this.view = view;
// Usually this call goes asynchronous, but for this example it doesn't matter | view.displayArticles(DataProvider.getInstance().getFavouriteArticles(), this); |
NikitaKozlov/MVP-Navigation | app/src/main/java/org/kaerdan/mvp_navigation/example5_retainpresenter/RetainPresenterArticleListPresenter.java | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/DataProvider.java
// public class DataProvider {
//
// private static final Article ARTICLE_1 = new Article(1, "Article 1", "Article 1 body", false);
// private static final Article ARTICLE_2 = new Article(2, "Article 2", "Article 2 body", true);
// private static final Article ARTICLE_3 = new Article(3, "Article 3", "Article 3 body", false);
// private static final Article ARTICLE_4 = new Article(4, "Article 4", "Article 4 body", true);
// private static final Article ARTICLE_5 = new Article(5, "Article 5", "Article 5 body", false);
// private static final Article ARTICLE_6 = new Article(6, "Article 6", "Article 6 body", true);
// private static final Article ARTICLE_7 = new Article(7, "Article 7", "Article 7 body", false);
// private static final Article ARTICLE_8 = new Article(8, "Article 8", "Article 8 body", true);
// private static final Article ARTICLE_9 = new Article(9, "Article 9", "Article 9 body", false);
// private static final Article ARTICLE_10 = new Article(10, "Article 10", "Article 10 body", true);
//
// private static DataProvider sInstance = new DataProvider();
//
// public static DataProvider getInstance() {
// return sInstance;
// }
//
// private final List<Article> mArticles;
//
// private DataProvider() {
// mArticles = Arrays.asList(ARTICLE_1, ARTICLE_2, ARTICLE_3, ARTICLE_4, ARTICLE_5, ARTICLE_6, ARTICLE_7,
// ARTICLE_8, ARTICLE_9, ARTICLE_10);
// }
//
// public List<Article> getmArticles() {
// return mArticles;
// }
//
// public List<Article> getFavouriteArticles() {
// List<Article> favouriteArticles = new ArrayList<>();
// for (Article article : mArticles) {
// if (article.isFavourite()) {
// favouriteArticles.add(article);
// }
// }
//
// return favouriteArticles;
// }
//
// @Nullable
// public Article getArticleById(final int id) {
// for (Article article : mArticles) {
// if (id == article.getId()) {
// return article;
// }
// }
//
// return null;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/OnArticleClickListener.java
// public interface OnArticleClickListener {
// void onArticleClick(int id);
// }
| import org.kaerdan.mvp_navigation.core.data.DataProvider;
import org.kaerdan.mvp_navigation.core.ui.OnArticleClickListener;
import android.support.annotation.NonNull; | package org.kaerdan.mvp_navigation.example5_retainpresenter;
public class RetainPresenterArticleListPresenter implements RetainPresenterArticleListContract.Presenter,
OnArticleClickListener {
private RetainPresenterArticleListContract.View mView;
private RetainPresenterArticleListContract.Navigator mNavigator;
@Override
public void onAttachView(final RetainPresenterArticleListContract.View view) {
this.mView = view;
// Usually this call goes asynchronous, but for this example it doesn't matter | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/DataProvider.java
// public class DataProvider {
//
// private static final Article ARTICLE_1 = new Article(1, "Article 1", "Article 1 body", false);
// private static final Article ARTICLE_2 = new Article(2, "Article 2", "Article 2 body", true);
// private static final Article ARTICLE_3 = new Article(3, "Article 3", "Article 3 body", false);
// private static final Article ARTICLE_4 = new Article(4, "Article 4", "Article 4 body", true);
// private static final Article ARTICLE_5 = new Article(5, "Article 5", "Article 5 body", false);
// private static final Article ARTICLE_6 = new Article(6, "Article 6", "Article 6 body", true);
// private static final Article ARTICLE_7 = new Article(7, "Article 7", "Article 7 body", false);
// private static final Article ARTICLE_8 = new Article(8, "Article 8", "Article 8 body", true);
// private static final Article ARTICLE_9 = new Article(9, "Article 9", "Article 9 body", false);
// private static final Article ARTICLE_10 = new Article(10, "Article 10", "Article 10 body", true);
//
// private static DataProvider sInstance = new DataProvider();
//
// public static DataProvider getInstance() {
// return sInstance;
// }
//
// private final List<Article> mArticles;
//
// private DataProvider() {
// mArticles = Arrays.asList(ARTICLE_1, ARTICLE_2, ARTICLE_3, ARTICLE_4, ARTICLE_5, ARTICLE_6, ARTICLE_7,
// ARTICLE_8, ARTICLE_9, ARTICLE_10);
// }
//
// public List<Article> getmArticles() {
// return mArticles;
// }
//
// public List<Article> getFavouriteArticles() {
// List<Article> favouriteArticles = new ArrayList<>();
// for (Article article : mArticles) {
// if (article.isFavourite()) {
// favouriteArticles.add(article);
// }
// }
//
// return favouriteArticles;
// }
//
// @Nullable
// public Article getArticleById(final int id) {
// for (Article article : mArticles) {
// if (id == article.getId()) {
// return article;
// }
// }
//
// return null;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/OnArticleClickListener.java
// public interface OnArticleClickListener {
// void onArticleClick(int id);
// }
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example5_retainpresenter/RetainPresenterArticleListPresenter.java
import org.kaerdan.mvp_navigation.core.data.DataProvider;
import org.kaerdan.mvp_navigation.core.ui.OnArticleClickListener;
import android.support.annotation.NonNull;
package org.kaerdan.mvp_navigation.example5_retainpresenter;
public class RetainPresenterArticleListPresenter implements RetainPresenterArticleListContract.Presenter,
OnArticleClickListener {
private RetainPresenterArticleListContract.View mView;
private RetainPresenterArticleListContract.Navigator mNavigator;
@Override
public void onAttachView(final RetainPresenterArticleListContract.View view) {
this.mView = view;
// Usually this call goes asynchronous, but for this example it doesn't matter | view.displayArticles(DataProvider.getInstance().getmArticles(), this); |
NikitaKozlov/MVP-Navigation | app/src/main/java/org/kaerdan/mvp_navigation/core/ui/article/ArticlePresenter.java | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/Article.java
// public class Article {
// private final int id;
// private final String title;
// private final String body;
// private final boolean isFavourite;
//
// public Article(int id, String title, String body, boolean isFavourite) {
// this.id = id;
// this.title = title;
// this.body = body;
// this.isFavourite = isFavourite;
// }
//
// public int getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getBody() {
// return body;
// }
//
// public boolean isFavourite() {
// return isFavourite;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/DataProvider.java
// public class DataProvider {
//
// private static final Article ARTICLE_1 = new Article(1, "Article 1", "Article 1 body", false);
// private static final Article ARTICLE_2 = new Article(2, "Article 2", "Article 2 body", true);
// private static final Article ARTICLE_3 = new Article(3, "Article 3", "Article 3 body", false);
// private static final Article ARTICLE_4 = new Article(4, "Article 4", "Article 4 body", true);
// private static final Article ARTICLE_5 = new Article(5, "Article 5", "Article 5 body", false);
// private static final Article ARTICLE_6 = new Article(6, "Article 6", "Article 6 body", true);
// private static final Article ARTICLE_7 = new Article(7, "Article 7", "Article 7 body", false);
// private static final Article ARTICLE_8 = new Article(8, "Article 8", "Article 8 body", true);
// private static final Article ARTICLE_9 = new Article(9, "Article 9", "Article 9 body", false);
// private static final Article ARTICLE_10 = new Article(10, "Article 10", "Article 10 body", true);
//
// private static DataProvider sInstance = new DataProvider();
//
// public static DataProvider getInstance() {
// return sInstance;
// }
//
// private final List<Article> mArticles;
//
// private DataProvider() {
// mArticles = Arrays.asList(ARTICLE_1, ARTICLE_2, ARTICLE_3, ARTICLE_4, ARTICLE_5, ARTICLE_6, ARTICLE_7,
// ARTICLE_8, ARTICLE_9, ARTICLE_10);
// }
//
// public List<Article> getmArticles() {
// return mArticles;
// }
//
// public List<Article> getFavouriteArticles() {
// List<Article> favouriteArticles = new ArrayList<>();
// for (Article article : mArticles) {
// if (article.isFavourite()) {
// favouriteArticles.add(article);
// }
// }
//
// return favouriteArticles;
// }
//
// @Nullable
// public Article getArticleById(final int id) {
// for (Article article : mArticles) {
// if (id == article.getId()) {
// return article;
// }
// }
//
// return null;
// }
// }
| import org.kaerdan.mvp_navigation.core.data.Article;
import org.kaerdan.mvp_navigation.core.data.DataProvider; | package org.kaerdan.mvp_navigation.core.ui.article;
public class ArticlePresenter implements ArticleContract.Presenter {
private final int mArticleId;
private ArticleContract.View mView;
public ArticlePresenter(final int articleId) {
this.mArticleId = articleId;
}
@Override
public void onAttachView(final ArticleContract.View view) {
this.mView = view;
// Usually this call goes asynchronous but for this example it doesn't matter | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/Article.java
// public class Article {
// private final int id;
// private final String title;
// private final String body;
// private final boolean isFavourite;
//
// public Article(int id, String title, String body, boolean isFavourite) {
// this.id = id;
// this.title = title;
// this.body = body;
// this.isFavourite = isFavourite;
// }
//
// public int getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getBody() {
// return body;
// }
//
// public boolean isFavourite() {
// return isFavourite;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/DataProvider.java
// public class DataProvider {
//
// private static final Article ARTICLE_1 = new Article(1, "Article 1", "Article 1 body", false);
// private static final Article ARTICLE_2 = new Article(2, "Article 2", "Article 2 body", true);
// private static final Article ARTICLE_3 = new Article(3, "Article 3", "Article 3 body", false);
// private static final Article ARTICLE_4 = new Article(4, "Article 4", "Article 4 body", true);
// private static final Article ARTICLE_5 = new Article(5, "Article 5", "Article 5 body", false);
// private static final Article ARTICLE_6 = new Article(6, "Article 6", "Article 6 body", true);
// private static final Article ARTICLE_7 = new Article(7, "Article 7", "Article 7 body", false);
// private static final Article ARTICLE_8 = new Article(8, "Article 8", "Article 8 body", true);
// private static final Article ARTICLE_9 = new Article(9, "Article 9", "Article 9 body", false);
// private static final Article ARTICLE_10 = new Article(10, "Article 10", "Article 10 body", true);
//
// private static DataProvider sInstance = new DataProvider();
//
// public static DataProvider getInstance() {
// return sInstance;
// }
//
// private final List<Article> mArticles;
//
// private DataProvider() {
// mArticles = Arrays.asList(ARTICLE_1, ARTICLE_2, ARTICLE_3, ARTICLE_4, ARTICLE_5, ARTICLE_6, ARTICLE_7,
// ARTICLE_8, ARTICLE_9, ARTICLE_10);
// }
//
// public List<Article> getmArticles() {
// return mArticles;
// }
//
// public List<Article> getFavouriteArticles() {
// List<Article> favouriteArticles = new ArrayList<>();
// for (Article article : mArticles) {
// if (article.isFavourite()) {
// favouriteArticles.add(article);
// }
// }
//
// return favouriteArticles;
// }
//
// @Nullable
// public Article getArticleById(final int id) {
// for (Article article : mArticles) {
// if (id == article.getId()) {
// return article;
// }
// }
//
// return null;
// }
// }
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/article/ArticlePresenter.java
import org.kaerdan.mvp_navigation.core.data.Article;
import org.kaerdan.mvp_navigation.core.data.DataProvider;
package org.kaerdan.mvp_navigation.core.ui.article;
public class ArticlePresenter implements ArticleContract.Presenter {
private final int mArticleId;
private ArticleContract.View mView;
public ArticlePresenter(final int articleId) {
this.mArticleId = articleId;
}
@Override
public void onAttachView(final ArticleContract.View view) {
this.mView = view;
// Usually this call goes asynchronous but for this example it doesn't matter | Article article = DataProvider.getInstance().getArticleById(mArticleId); |
NikitaKozlov/MVP-Navigation | app/src/main/java/org/kaerdan/mvp_navigation/core/ui/article/ArticlePresenter.java | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/Article.java
// public class Article {
// private final int id;
// private final String title;
// private final String body;
// private final boolean isFavourite;
//
// public Article(int id, String title, String body, boolean isFavourite) {
// this.id = id;
// this.title = title;
// this.body = body;
// this.isFavourite = isFavourite;
// }
//
// public int getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getBody() {
// return body;
// }
//
// public boolean isFavourite() {
// return isFavourite;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/DataProvider.java
// public class DataProvider {
//
// private static final Article ARTICLE_1 = new Article(1, "Article 1", "Article 1 body", false);
// private static final Article ARTICLE_2 = new Article(2, "Article 2", "Article 2 body", true);
// private static final Article ARTICLE_3 = new Article(3, "Article 3", "Article 3 body", false);
// private static final Article ARTICLE_4 = new Article(4, "Article 4", "Article 4 body", true);
// private static final Article ARTICLE_5 = new Article(5, "Article 5", "Article 5 body", false);
// private static final Article ARTICLE_6 = new Article(6, "Article 6", "Article 6 body", true);
// private static final Article ARTICLE_7 = new Article(7, "Article 7", "Article 7 body", false);
// private static final Article ARTICLE_8 = new Article(8, "Article 8", "Article 8 body", true);
// private static final Article ARTICLE_9 = new Article(9, "Article 9", "Article 9 body", false);
// private static final Article ARTICLE_10 = new Article(10, "Article 10", "Article 10 body", true);
//
// private static DataProvider sInstance = new DataProvider();
//
// public static DataProvider getInstance() {
// return sInstance;
// }
//
// private final List<Article> mArticles;
//
// private DataProvider() {
// mArticles = Arrays.asList(ARTICLE_1, ARTICLE_2, ARTICLE_3, ARTICLE_4, ARTICLE_5, ARTICLE_6, ARTICLE_7,
// ARTICLE_8, ARTICLE_9, ARTICLE_10);
// }
//
// public List<Article> getmArticles() {
// return mArticles;
// }
//
// public List<Article> getFavouriteArticles() {
// List<Article> favouriteArticles = new ArrayList<>();
// for (Article article : mArticles) {
// if (article.isFavourite()) {
// favouriteArticles.add(article);
// }
// }
//
// return favouriteArticles;
// }
//
// @Nullable
// public Article getArticleById(final int id) {
// for (Article article : mArticles) {
// if (id == article.getId()) {
// return article;
// }
// }
//
// return null;
// }
// }
| import org.kaerdan.mvp_navigation.core.data.Article;
import org.kaerdan.mvp_navigation.core.data.DataProvider; | package org.kaerdan.mvp_navigation.core.ui.article;
public class ArticlePresenter implements ArticleContract.Presenter {
private final int mArticleId;
private ArticleContract.View mView;
public ArticlePresenter(final int articleId) {
this.mArticleId = articleId;
}
@Override
public void onAttachView(final ArticleContract.View view) {
this.mView = view;
// Usually this call goes asynchronous but for this example it doesn't matter | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/Article.java
// public class Article {
// private final int id;
// private final String title;
// private final String body;
// private final boolean isFavourite;
//
// public Article(int id, String title, String body, boolean isFavourite) {
// this.id = id;
// this.title = title;
// this.body = body;
// this.isFavourite = isFavourite;
// }
//
// public int getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getBody() {
// return body;
// }
//
// public boolean isFavourite() {
// return isFavourite;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/DataProvider.java
// public class DataProvider {
//
// private static final Article ARTICLE_1 = new Article(1, "Article 1", "Article 1 body", false);
// private static final Article ARTICLE_2 = new Article(2, "Article 2", "Article 2 body", true);
// private static final Article ARTICLE_3 = new Article(3, "Article 3", "Article 3 body", false);
// private static final Article ARTICLE_4 = new Article(4, "Article 4", "Article 4 body", true);
// private static final Article ARTICLE_5 = new Article(5, "Article 5", "Article 5 body", false);
// private static final Article ARTICLE_6 = new Article(6, "Article 6", "Article 6 body", true);
// private static final Article ARTICLE_7 = new Article(7, "Article 7", "Article 7 body", false);
// private static final Article ARTICLE_8 = new Article(8, "Article 8", "Article 8 body", true);
// private static final Article ARTICLE_9 = new Article(9, "Article 9", "Article 9 body", false);
// private static final Article ARTICLE_10 = new Article(10, "Article 10", "Article 10 body", true);
//
// private static DataProvider sInstance = new DataProvider();
//
// public static DataProvider getInstance() {
// return sInstance;
// }
//
// private final List<Article> mArticles;
//
// private DataProvider() {
// mArticles = Arrays.asList(ARTICLE_1, ARTICLE_2, ARTICLE_3, ARTICLE_4, ARTICLE_5, ARTICLE_6, ARTICLE_7,
// ARTICLE_8, ARTICLE_9, ARTICLE_10);
// }
//
// public List<Article> getmArticles() {
// return mArticles;
// }
//
// public List<Article> getFavouriteArticles() {
// List<Article> favouriteArticles = new ArrayList<>();
// for (Article article : mArticles) {
// if (article.isFavourite()) {
// favouriteArticles.add(article);
// }
// }
//
// return favouriteArticles;
// }
//
// @Nullable
// public Article getArticleById(final int id) {
// for (Article article : mArticles) {
// if (id == article.getId()) {
// return article;
// }
// }
//
// return null;
// }
// }
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/article/ArticlePresenter.java
import org.kaerdan.mvp_navigation.core.data.Article;
import org.kaerdan.mvp_navigation.core.data.DataProvider;
package org.kaerdan.mvp_navigation.core.ui.article;
public class ArticlePresenter implements ArticleContract.Presenter {
private final int mArticleId;
private ArticleContract.View mView;
public ArticlePresenter(final int articleId) {
this.mArticleId = articleId;
}
@Override
public void onAttachView(final ArticleContract.View view) {
this.mView = view;
// Usually this call goes asynchronous but for this example it doesn't matter | Article article = DataProvider.getInstance().getArticleById(mArticleId); |
NikitaKozlov/MVP-Navigation | app/src/main/java/org/kaerdan/mvp_navigation/example5_retainpresenter/RetainPresenterArticleListContract.java | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/Article.java
// public class Article {
// private final int id;
// private final String title;
// private final String body;
// private final boolean isFavourite;
//
// public Article(int id, String title, String body, boolean isFavourite) {
// this.id = id;
// this.title = title;
// this.body = body;
// this.isFavourite = isFavourite;
// }
//
// public int getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getBody() {
// return body;
// }
//
// public boolean isFavourite() {
// return isFavourite;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/OnArticleClickListener.java
// public interface OnArticleClickListener {
// void onArticleClick(int id);
// }
| import java.util.List;
import org.kaerdan.mvp_navigation.core.data.Article;
import org.kaerdan.mvp_navigation.core.ui.OnArticleClickListener;
import android.support.annotation.NonNull; | package org.kaerdan.mvp_navigation.example5_retainpresenter;
public interface RetainPresenterArticleListContract {
interface Presenter extends org.kaerdan.presenterretainer.Presenter<View> {
void setNavigator(@NonNull Navigator navigator);
void onFavoriteArticleClick();
}
interface View extends org.kaerdan.presenterretainer.Presenter.View { | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/Article.java
// public class Article {
// private final int id;
// private final String title;
// private final String body;
// private final boolean isFavourite;
//
// public Article(int id, String title, String body, boolean isFavourite) {
// this.id = id;
// this.title = title;
// this.body = body;
// this.isFavourite = isFavourite;
// }
//
// public int getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getBody() {
// return body;
// }
//
// public boolean isFavourite() {
// return isFavourite;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/OnArticleClickListener.java
// public interface OnArticleClickListener {
// void onArticleClick(int id);
// }
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example5_retainpresenter/RetainPresenterArticleListContract.java
import java.util.List;
import org.kaerdan.mvp_navigation.core.data.Article;
import org.kaerdan.mvp_navigation.core.ui.OnArticleClickListener;
import android.support.annotation.NonNull;
package org.kaerdan.mvp_navigation.example5_retainpresenter;
public interface RetainPresenterArticleListContract {
interface Presenter extends org.kaerdan.presenterretainer.Presenter<View> {
void setNavigator(@NonNull Navigator navigator);
void onFavoriteArticleClick();
}
interface View extends org.kaerdan.presenterretainer.Presenter.View { | void displayArticles(@NonNull List<Article> articles, @NonNull OnArticleClickListener onArticleClickListener); |
NikitaKozlov/MVP-Navigation | app/src/main/java/org/kaerdan/mvp_navigation/example5_retainpresenter/RetainPresenterArticleListContract.java | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/Article.java
// public class Article {
// private final int id;
// private final String title;
// private final String body;
// private final boolean isFavourite;
//
// public Article(int id, String title, String body, boolean isFavourite) {
// this.id = id;
// this.title = title;
// this.body = body;
// this.isFavourite = isFavourite;
// }
//
// public int getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getBody() {
// return body;
// }
//
// public boolean isFavourite() {
// return isFavourite;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/OnArticleClickListener.java
// public interface OnArticleClickListener {
// void onArticleClick(int id);
// }
| import java.util.List;
import org.kaerdan.mvp_navigation.core.data.Article;
import org.kaerdan.mvp_navigation.core.ui.OnArticleClickListener;
import android.support.annotation.NonNull; | package org.kaerdan.mvp_navigation.example5_retainpresenter;
public interface RetainPresenterArticleListContract {
interface Presenter extends org.kaerdan.presenterretainer.Presenter<View> {
void setNavigator(@NonNull Navigator navigator);
void onFavoriteArticleClick();
}
interface View extends org.kaerdan.presenterretainer.Presenter.View { | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/Article.java
// public class Article {
// private final int id;
// private final String title;
// private final String body;
// private final boolean isFavourite;
//
// public Article(int id, String title, String body, boolean isFavourite) {
// this.id = id;
// this.title = title;
// this.body = body;
// this.isFavourite = isFavourite;
// }
//
// public int getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getBody() {
// return body;
// }
//
// public boolean isFavourite() {
// return isFavourite;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/OnArticleClickListener.java
// public interface OnArticleClickListener {
// void onArticleClick(int id);
// }
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example5_retainpresenter/RetainPresenterArticleListContract.java
import java.util.List;
import org.kaerdan.mvp_navigation.core.data.Article;
import org.kaerdan.mvp_navigation.core.ui.OnArticleClickListener;
import android.support.annotation.NonNull;
package org.kaerdan.mvp_navigation.example5_retainpresenter;
public interface RetainPresenterArticleListContract {
interface Presenter extends org.kaerdan.presenterretainer.Presenter<View> {
void setNavigator(@NonNull Navigator navigator);
void onFavoriteArticleClick();
}
interface View extends org.kaerdan.presenterretainer.Presenter.View { | void displayArticles(@NonNull List<Article> articles, @NonNull OnArticleClickListener onArticleClickListener); |
NikitaKozlov/MVP-Navigation | app/src/main/java/org/kaerdan/mvp_navigation/example4_injection/InjectArticleListContract.java | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/Article.java
// public class Article {
// private final int id;
// private final String title;
// private final String body;
// private final boolean isFavourite;
//
// public Article(int id, String title, String body, boolean isFavourite) {
// this.id = id;
// this.title = title;
// this.body = body;
// this.isFavourite = isFavourite;
// }
//
// public int getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getBody() {
// return body;
// }
//
// public boolean isFavourite() {
// return isFavourite;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/OnArticleClickListener.java
// public interface OnArticleClickListener {
// void onArticleClick(int id);
// }
| import java.util.List;
import org.kaerdan.mvp_navigation.core.data.Article;
import org.kaerdan.mvp_navigation.core.ui.OnArticleClickListener;
import android.support.annotation.NonNull; | package org.kaerdan.mvp_navigation.example4_injection;
public interface InjectArticleListContract {
interface Presenter extends org.kaerdan.mvp_navigation.core.Presenter<View> {
void onFavoriteArticleClick();
}
interface View extends org.kaerdan.mvp_navigation.core.Presenter.View { | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/Article.java
// public class Article {
// private final int id;
// private final String title;
// private final String body;
// private final boolean isFavourite;
//
// public Article(int id, String title, String body, boolean isFavourite) {
// this.id = id;
// this.title = title;
// this.body = body;
// this.isFavourite = isFavourite;
// }
//
// public int getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getBody() {
// return body;
// }
//
// public boolean isFavourite() {
// return isFavourite;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/OnArticleClickListener.java
// public interface OnArticleClickListener {
// void onArticleClick(int id);
// }
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example4_injection/InjectArticleListContract.java
import java.util.List;
import org.kaerdan.mvp_navigation.core.data.Article;
import org.kaerdan.mvp_navigation.core.ui.OnArticleClickListener;
import android.support.annotation.NonNull;
package org.kaerdan.mvp_navigation.example4_injection;
public interface InjectArticleListContract {
interface Presenter extends org.kaerdan.mvp_navigation.core.Presenter<View> {
void onFavoriteArticleClick();
}
interface View extends org.kaerdan.mvp_navigation.core.Presenter.View { | void displayArticles(@NonNull List<Article> articles, |
NikitaKozlov/MVP-Navigation | app/src/main/java/org/kaerdan/mvp_navigation/example4_injection/InjectArticleListContract.java | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/Article.java
// public class Article {
// private final int id;
// private final String title;
// private final String body;
// private final boolean isFavourite;
//
// public Article(int id, String title, String body, boolean isFavourite) {
// this.id = id;
// this.title = title;
// this.body = body;
// this.isFavourite = isFavourite;
// }
//
// public int getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getBody() {
// return body;
// }
//
// public boolean isFavourite() {
// return isFavourite;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/OnArticleClickListener.java
// public interface OnArticleClickListener {
// void onArticleClick(int id);
// }
| import java.util.List;
import org.kaerdan.mvp_navigation.core.data.Article;
import org.kaerdan.mvp_navigation.core.ui.OnArticleClickListener;
import android.support.annotation.NonNull; | package org.kaerdan.mvp_navigation.example4_injection;
public interface InjectArticleListContract {
interface Presenter extends org.kaerdan.mvp_navigation.core.Presenter<View> {
void onFavoriteArticleClick();
}
interface View extends org.kaerdan.mvp_navigation.core.Presenter.View {
void displayArticles(@NonNull List<Article> articles, | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/Article.java
// public class Article {
// private final int id;
// private final String title;
// private final String body;
// private final boolean isFavourite;
//
// public Article(int id, String title, String body, boolean isFavourite) {
// this.id = id;
// this.title = title;
// this.body = body;
// this.isFavourite = isFavourite;
// }
//
// public int getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getBody() {
// return body;
// }
//
// public boolean isFavourite() {
// return isFavourite;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/OnArticleClickListener.java
// public interface OnArticleClickListener {
// void onArticleClick(int id);
// }
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example4_injection/InjectArticleListContract.java
import java.util.List;
import org.kaerdan.mvp_navigation.core.data.Article;
import org.kaerdan.mvp_navigation.core.ui.OnArticleClickListener;
import android.support.annotation.NonNull;
package org.kaerdan.mvp_navigation.example4_injection;
public interface InjectArticleListContract {
interface Presenter extends org.kaerdan.mvp_navigation.core.Presenter<View> {
void onFavoriteArticleClick();
}
interface View extends org.kaerdan.mvp_navigation.core.Presenter.View {
void displayArticles(@NonNull List<Article> articles, | @NonNull OnArticleClickListener onArticleClickListener); |
NikitaKozlov/MVP-Navigation | app/src/main/java/org/kaerdan/mvp_navigation/example3_viewpager/ViewPagerArticleListNavigator.java | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/article_list/ArticleListContract.java
// public interface ArticleListContract {
// interface Presenter extends org.kaerdan.mvp_navigation.core.Presenter<View> {
// void setNavigator(@NonNull Navigator navigator);
//
// void onFavoriteArticleClick();
// }
//
// interface View extends org.kaerdan.mvp_navigation.core.Presenter.View {
// void displayArticles(@NonNull List<Article> articles, @NonNull OnArticleClickListener onArticleClickListener);
// }
//
// interface Navigator {
// void openArticle(int id);
//
// void openFavoriteArticles();
// }
//
// interface NavigatorProvider {
//
// @NonNull
// Navigator getNavigator(ArticleListContract.Presenter presenter);
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example1_activities/ArticleActivity.java
// public class ArticleActivity extends AppCompatActivity {
//
// private static final String ARTICLE_ID_TAG = "Article id";
//
// public static Intent createIntent(final Context context, final int id) {
// Intent intent = new Intent(context, ArticleActivity.class);
// intent.putExtra(ARTICLE_ID_TAG, id);
// return intent;
// }
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_single_fragment);
// if (savedInstanceState == null) {
// getSupportFragmentManager().beginTransaction()
// .add(R.id.content_frame,
// ArticleFragment.newInstance(getIntent().getIntExtra(ARTICLE_ID_TAG, 0)), null).commit();
// }
//
// getSupportActionBar().setHomeButtonEnabled(true);
// getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// }
//
// @Override
// public boolean onOptionsItemSelected(final MenuItem item) {
// if (item.getItemId() == android.R.id.home) {
// onBackPressed();
// return true;
// }
//
// return super.onOptionsItemSelected(item);
// }
// }
| import org.kaerdan.mvp_navigation.core.ui.article_list.ArticleListContract;
import org.kaerdan.mvp_navigation.example1_activities.ArticleActivity;
import android.content.Context;
import android.support.v4.view.ViewPager; | package org.kaerdan.mvp_navigation.example3_viewpager;
public class ViewPagerArticleListNavigator implements ArticleListContract.Navigator {
private final Context mActivityContext;
private final ViewPager mViewPager;
public ViewPagerArticleListNavigator(final Context mActivityContext, final ViewPager mViewPager) {
this.mActivityContext = mActivityContext;
this.mViewPager = mViewPager;
}
@Override
public void openArticle(final int id) { | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/article_list/ArticleListContract.java
// public interface ArticleListContract {
// interface Presenter extends org.kaerdan.mvp_navigation.core.Presenter<View> {
// void setNavigator(@NonNull Navigator navigator);
//
// void onFavoriteArticleClick();
// }
//
// interface View extends org.kaerdan.mvp_navigation.core.Presenter.View {
// void displayArticles(@NonNull List<Article> articles, @NonNull OnArticleClickListener onArticleClickListener);
// }
//
// interface Navigator {
// void openArticle(int id);
//
// void openFavoriteArticles();
// }
//
// interface NavigatorProvider {
//
// @NonNull
// Navigator getNavigator(ArticleListContract.Presenter presenter);
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example1_activities/ArticleActivity.java
// public class ArticleActivity extends AppCompatActivity {
//
// private static final String ARTICLE_ID_TAG = "Article id";
//
// public static Intent createIntent(final Context context, final int id) {
// Intent intent = new Intent(context, ArticleActivity.class);
// intent.putExtra(ARTICLE_ID_TAG, id);
// return intent;
// }
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_single_fragment);
// if (savedInstanceState == null) {
// getSupportFragmentManager().beginTransaction()
// .add(R.id.content_frame,
// ArticleFragment.newInstance(getIntent().getIntExtra(ARTICLE_ID_TAG, 0)), null).commit();
// }
//
// getSupportActionBar().setHomeButtonEnabled(true);
// getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// }
//
// @Override
// public boolean onOptionsItemSelected(final MenuItem item) {
// if (item.getItemId() == android.R.id.home) {
// onBackPressed();
// return true;
// }
//
// return super.onOptionsItemSelected(item);
// }
// }
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example3_viewpager/ViewPagerArticleListNavigator.java
import org.kaerdan.mvp_navigation.core.ui.article_list.ArticleListContract;
import org.kaerdan.mvp_navigation.example1_activities.ArticleActivity;
import android.content.Context;
import android.support.v4.view.ViewPager;
package org.kaerdan.mvp_navigation.example3_viewpager;
public class ViewPagerArticleListNavigator implements ArticleListContract.Navigator {
private final Context mActivityContext;
private final ViewPager mViewPager;
public ViewPagerArticleListNavigator(final Context mActivityContext, final ViewPager mViewPager) {
this.mActivityContext = mActivityContext;
this.mViewPager = mViewPager;
}
@Override
public void openArticle(final int id) { | mActivityContext.startActivity(ArticleActivity.createIntent(mActivityContext, id)); |
NikitaKozlov/MVP-Navigation | app/src/main/java/org/kaerdan/mvp_navigation/example3_viewpager/ViewPagerAdapter.java | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/article_list/ArticleListFragment.java
// public class ArticleListFragment extends Fragment implements ArticleListContract.View {
//
// private ArticleListContract.Presenter mPresenter;
//
// private RecyclerView mRecyclerView;
//
// public ArticleListFragment() {
// // Required empty public constructor
// }
//
// @Override
// public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
// final Bundle savedInstanceState) {
// mPresenter = createPresenter();
//
// // Inflate the layout for this fragment
// View view = inflater.inflate(R.layout.fragment_article_list, container, false);
// mRecyclerView = (RecyclerView) view.findViewById(R.id.article_list);
// mRecyclerView.setLayoutManager(new LinearLayoutManager(container.getContext(), LinearLayoutManager.VERTICAL,
// false));
//
// view.findViewById(R.id.favorite_articles).setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(final View v) {
// mPresenter.onFavoriteArticleClick();
// }
// });
//
// return view;
// }
//
// @NonNull
// protected ArticleListContract.Presenter createPresenter() {
// ArticleListContract.Presenter presenter = new ArticleListPresenter();
// presenter.setNavigator(getNavigator(presenter));
// return presenter;
// }
//
// @NonNull
// protected ArticleListContract.Navigator getNavigator(final ArticleListContract.Presenter presenter) {
// Fragment parentFragment = getParentFragment();
// if (parentFragment != null && parentFragment instanceof ArticleListContract.NavigatorProvider) {
// return ((ArticleListContract.NavigatorProvider) parentFragment).getNavigator(presenter);
// } else {
// Activity activity = getActivity();
// if (activity instanceof ArticleListContract.NavigatorProvider) {
// return ((ArticleListContract.NavigatorProvider) activity).getNavigator(presenter);
// }
// }
//
// throw new IllegalStateException("Activity or parent Fragment must implement "
// + "ArticleListContract.NavigatorProvider");
// }
//
// @Override
// public void onStart() {
// super.onStart();
// mPresenter.onAttachView(this);
// }
//
// @Override
// public void onStop() {
// super.onStop();
// mPresenter.onDetachView();
// }
//
// @Override
// public void displayArticles(@NonNull final List<Article> articles,
// @NonNull final OnArticleClickListener onArticleClickListener) {
// mRecyclerView.setAdapter(new ArticleListAdapter(articles, onArticleClickListener));
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/favorite_list/FavoriteListFragment.java
// public class FavoriteListFragment extends Fragment implements FavoriteListContract.View {
//
// private FavoriteListContract.Presenter mPresenter;
//
// private RecyclerView mRecyclerView;
//
// public FavoriteListFragment() {
// // Required empty public constructor
// }
//
// @Override
// public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
// final Bundle savedInstanceState) {
// mPresenter = createPresenter();
//
// // Inflate the layout for this fragment
// mRecyclerView = (RecyclerView) inflater.inflate(R.layout.fragment_favorite_article_list, container, false);
// mRecyclerView.setLayoutManager(new LinearLayoutManager(container.getContext(), LinearLayoutManager.VERTICAL,
// false));
// return mRecyclerView;
// }
//
// @NonNull
// protected FavoriteListContract.Presenter createPresenter() {
// FavoriteListContract.Presenter presenter = new FavoriteListPresenter();
// presenter.setNavigator(getNavigator(presenter));
// return presenter;
// }
//
// @NonNull
// protected FavoriteListContract.Navigator getNavigator(final FavoriteListContract.Presenter presenter) {
// Fragment parentFragment = getParentFragment();
// if (parentFragment != null && parentFragment instanceof FavoriteListContract.NavigatorProvider) {
// return ((FavoriteListContract.NavigatorProvider) parentFragment).getNavigator(presenter);
// } else {
// Activity activity = getActivity();
// if (activity instanceof FavoriteListContract.NavigatorProvider) {
// return ((FavoriteListContract.NavigatorProvider) activity).getNavigator(presenter);
// }
// }
//
// throw new IllegalStateException("Activity or parent Fragment must implement "
// + "FavoriteListContract.NavigatorProvider");
// }
//
// @Override
// public void onStart() {
// super.onStart();
// mPresenter.onAttachView(this);
// }
//
// @Override
// public void onStop() {
// super.onStop();
// mPresenter.onDetachView();
// }
//
// @Override
// public void displayArticles(@NonNull final List<Article> articles,
// @NonNull final OnArticleClickListener onArticleClickListener) {
// mRecyclerView.setAdapter(new ArticleListAdapter(articles, onArticleClickListener));
// }
// }
| import org.kaerdan.mvp_navigation.core.ui.article_list.ArticleListFragment;
import org.kaerdan.mvp_navigation.core.ui.favorite_list.FavoriteListFragment;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter; | package org.kaerdan.mvp_navigation.example3_viewpager;
public class ViewPagerAdapter extends FragmentPagerAdapter {
public ViewPagerAdapter(final FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(final int position) {
if (position == 0) { | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/article_list/ArticleListFragment.java
// public class ArticleListFragment extends Fragment implements ArticleListContract.View {
//
// private ArticleListContract.Presenter mPresenter;
//
// private RecyclerView mRecyclerView;
//
// public ArticleListFragment() {
// // Required empty public constructor
// }
//
// @Override
// public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
// final Bundle savedInstanceState) {
// mPresenter = createPresenter();
//
// // Inflate the layout for this fragment
// View view = inflater.inflate(R.layout.fragment_article_list, container, false);
// mRecyclerView = (RecyclerView) view.findViewById(R.id.article_list);
// mRecyclerView.setLayoutManager(new LinearLayoutManager(container.getContext(), LinearLayoutManager.VERTICAL,
// false));
//
// view.findViewById(R.id.favorite_articles).setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(final View v) {
// mPresenter.onFavoriteArticleClick();
// }
// });
//
// return view;
// }
//
// @NonNull
// protected ArticleListContract.Presenter createPresenter() {
// ArticleListContract.Presenter presenter = new ArticleListPresenter();
// presenter.setNavigator(getNavigator(presenter));
// return presenter;
// }
//
// @NonNull
// protected ArticleListContract.Navigator getNavigator(final ArticleListContract.Presenter presenter) {
// Fragment parentFragment = getParentFragment();
// if (parentFragment != null && parentFragment instanceof ArticleListContract.NavigatorProvider) {
// return ((ArticleListContract.NavigatorProvider) parentFragment).getNavigator(presenter);
// } else {
// Activity activity = getActivity();
// if (activity instanceof ArticleListContract.NavigatorProvider) {
// return ((ArticleListContract.NavigatorProvider) activity).getNavigator(presenter);
// }
// }
//
// throw new IllegalStateException("Activity or parent Fragment must implement "
// + "ArticleListContract.NavigatorProvider");
// }
//
// @Override
// public void onStart() {
// super.onStart();
// mPresenter.onAttachView(this);
// }
//
// @Override
// public void onStop() {
// super.onStop();
// mPresenter.onDetachView();
// }
//
// @Override
// public void displayArticles(@NonNull final List<Article> articles,
// @NonNull final OnArticleClickListener onArticleClickListener) {
// mRecyclerView.setAdapter(new ArticleListAdapter(articles, onArticleClickListener));
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/favorite_list/FavoriteListFragment.java
// public class FavoriteListFragment extends Fragment implements FavoriteListContract.View {
//
// private FavoriteListContract.Presenter mPresenter;
//
// private RecyclerView mRecyclerView;
//
// public FavoriteListFragment() {
// // Required empty public constructor
// }
//
// @Override
// public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
// final Bundle savedInstanceState) {
// mPresenter = createPresenter();
//
// // Inflate the layout for this fragment
// mRecyclerView = (RecyclerView) inflater.inflate(R.layout.fragment_favorite_article_list, container, false);
// mRecyclerView.setLayoutManager(new LinearLayoutManager(container.getContext(), LinearLayoutManager.VERTICAL,
// false));
// return mRecyclerView;
// }
//
// @NonNull
// protected FavoriteListContract.Presenter createPresenter() {
// FavoriteListContract.Presenter presenter = new FavoriteListPresenter();
// presenter.setNavigator(getNavigator(presenter));
// return presenter;
// }
//
// @NonNull
// protected FavoriteListContract.Navigator getNavigator(final FavoriteListContract.Presenter presenter) {
// Fragment parentFragment = getParentFragment();
// if (parentFragment != null && parentFragment instanceof FavoriteListContract.NavigatorProvider) {
// return ((FavoriteListContract.NavigatorProvider) parentFragment).getNavigator(presenter);
// } else {
// Activity activity = getActivity();
// if (activity instanceof FavoriteListContract.NavigatorProvider) {
// return ((FavoriteListContract.NavigatorProvider) activity).getNavigator(presenter);
// }
// }
//
// throw new IllegalStateException("Activity or parent Fragment must implement "
// + "FavoriteListContract.NavigatorProvider");
// }
//
// @Override
// public void onStart() {
// super.onStart();
// mPresenter.onAttachView(this);
// }
//
// @Override
// public void onStop() {
// super.onStop();
// mPresenter.onDetachView();
// }
//
// @Override
// public void displayArticles(@NonNull final List<Article> articles,
// @NonNull final OnArticleClickListener onArticleClickListener) {
// mRecyclerView.setAdapter(new ArticleListAdapter(articles, onArticleClickListener));
// }
// }
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example3_viewpager/ViewPagerAdapter.java
import org.kaerdan.mvp_navigation.core.ui.article_list.ArticleListFragment;
import org.kaerdan.mvp_navigation.core.ui.favorite_list.FavoriteListFragment;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
package org.kaerdan.mvp_navigation.example3_viewpager;
public class ViewPagerAdapter extends FragmentPagerAdapter {
public ViewPagerAdapter(final FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(final int position) {
if (position == 0) { | return new ArticleListFragment(); |
NikitaKozlov/MVP-Navigation | app/src/main/java/org/kaerdan/mvp_navigation/example3_viewpager/ViewPagerAdapter.java | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/article_list/ArticleListFragment.java
// public class ArticleListFragment extends Fragment implements ArticleListContract.View {
//
// private ArticleListContract.Presenter mPresenter;
//
// private RecyclerView mRecyclerView;
//
// public ArticleListFragment() {
// // Required empty public constructor
// }
//
// @Override
// public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
// final Bundle savedInstanceState) {
// mPresenter = createPresenter();
//
// // Inflate the layout for this fragment
// View view = inflater.inflate(R.layout.fragment_article_list, container, false);
// mRecyclerView = (RecyclerView) view.findViewById(R.id.article_list);
// mRecyclerView.setLayoutManager(new LinearLayoutManager(container.getContext(), LinearLayoutManager.VERTICAL,
// false));
//
// view.findViewById(R.id.favorite_articles).setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(final View v) {
// mPresenter.onFavoriteArticleClick();
// }
// });
//
// return view;
// }
//
// @NonNull
// protected ArticleListContract.Presenter createPresenter() {
// ArticleListContract.Presenter presenter = new ArticleListPresenter();
// presenter.setNavigator(getNavigator(presenter));
// return presenter;
// }
//
// @NonNull
// protected ArticleListContract.Navigator getNavigator(final ArticleListContract.Presenter presenter) {
// Fragment parentFragment = getParentFragment();
// if (parentFragment != null && parentFragment instanceof ArticleListContract.NavigatorProvider) {
// return ((ArticleListContract.NavigatorProvider) parentFragment).getNavigator(presenter);
// } else {
// Activity activity = getActivity();
// if (activity instanceof ArticleListContract.NavigatorProvider) {
// return ((ArticleListContract.NavigatorProvider) activity).getNavigator(presenter);
// }
// }
//
// throw new IllegalStateException("Activity or parent Fragment must implement "
// + "ArticleListContract.NavigatorProvider");
// }
//
// @Override
// public void onStart() {
// super.onStart();
// mPresenter.onAttachView(this);
// }
//
// @Override
// public void onStop() {
// super.onStop();
// mPresenter.onDetachView();
// }
//
// @Override
// public void displayArticles(@NonNull final List<Article> articles,
// @NonNull final OnArticleClickListener onArticleClickListener) {
// mRecyclerView.setAdapter(new ArticleListAdapter(articles, onArticleClickListener));
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/favorite_list/FavoriteListFragment.java
// public class FavoriteListFragment extends Fragment implements FavoriteListContract.View {
//
// private FavoriteListContract.Presenter mPresenter;
//
// private RecyclerView mRecyclerView;
//
// public FavoriteListFragment() {
// // Required empty public constructor
// }
//
// @Override
// public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
// final Bundle savedInstanceState) {
// mPresenter = createPresenter();
//
// // Inflate the layout for this fragment
// mRecyclerView = (RecyclerView) inflater.inflate(R.layout.fragment_favorite_article_list, container, false);
// mRecyclerView.setLayoutManager(new LinearLayoutManager(container.getContext(), LinearLayoutManager.VERTICAL,
// false));
// return mRecyclerView;
// }
//
// @NonNull
// protected FavoriteListContract.Presenter createPresenter() {
// FavoriteListContract.Presenter presenter = new FavoriteListPresenter();
// presenter.setNavigator(getNavigator(presenter));
// return presenter;
// }
//
// @NonNull
// protected FavoriteListContract.Navigator getNavigator(final FavoriteListContract.Presenter presenter) {
// Fragment parentFragment = getParentFragment();
// if (parentFragment != null && parentFragment instanceof FavoriteListContract.NavigatorProvider) {
// return ((FavoriteListContract.NavigatorProvider) parentFragment).getNavigator(presenter);
// } else {
// Activity activity = getActivity();
// if (activity instanceof FavoriteListContract.NavigatorProvider) {
// return ((FavoriteListContract.NavigatorProvider) activity).getNavigator(presenter);
// }
// }
//
// throw new IllegalStateException("Activity or parent Fragment must implement "
// + "FavoriteListContract.NavigatorProvider");
// }
//
// @Override
// public void onStart() {
// super.onStart();
// mPresenter.onAttachView(this);
// }
//
// @Override
// public void onStop() {
// super.onStop();
// mPresenter.onDetachView();
// }
//
// @Override
// public void displayArticles(@NonNull final List<Article> articles,
// @NonNull final OnArticleClickListener onArticleClickListener) {
// mRecyclerView.setAdapter(new ArticleListAdapter(articles, onArticleClickListener));
// }
// }
| import org.kaerdan.mvp_navigation.core.ui.article_list.ArticleListFragment;
import org.kaerdan.mvp_navigation.core.ui.favorite_list.FavoriteListFragment;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter; | package org.kaerdan.mvp_navigation.example3_viewpager;
public class ViewPagerAdapter extends FragmentPagerAdapter {
public ViewPagerAdapter(final FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(final int position) {
if (position == 0) {
return new ArticleListFragment();
} | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/article_list/ArticleListFragment.java
// public class ArticleListFragment extends Fragment implements ArticleListContract.View {
//
// private ArticleListContract.Presenter mPresenter;
//
// private RecyclerView mRecyclerView;
//
// public ArticleListFragment() {
// // Required empty public constructor
// }
//
// @Override
// public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
// final Bundle savedInstanceState) {
// mPresenter = createPresenter();
//
// // Inflate the layout for this fragment
// View view = inflater.inflate(R.layout.fragment_article_list, container, false);
// mRecyclerView = (RecyclerView) view.findViewById(R.id.article_list);
// mRecyclerView.setLayoutManager(new LinearLayoutManager(container.getContext(), LinearLayoutManager.VERTICAL,
// false));
//
// view.findViewById(R.id.favorite_articles).setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(final View v) {
// mPresenter.onFavoriteArticleClick();
// }
// });
//
// return view;
// }
//
// @NonNull
// protected ArticleListContract.Presenter createPresenter() {
// ArticleListContract.Presenter presenter = new ArticleListPresenter();
// presenter.setNavigator(getNavigator(presenter));
// return presenter;
// }
//
// @NonNull
// protected ArticleListContract.Navigator getNavigator(final ArticleListContract.Presenter presenter) {
// Fragment parentFragment = getParentFragment();
// if (parentFragment != null && parentFragment instanceof ArticleListContract.NavigatorProvider) {
// return ((ArticleListContract.NavigatorProvider) parentFragment).getNavigator(presenter);
// } else {
// Activity activity = getActivity();
// if (activity instanceof ArticleListContract.NavigatorProvider) {
// return ((ArticleListContract.NavigatorProvider) activity).getNavigator(presenter);
// }
// }
//
// throw new IllegalStateException("Activity or parent Fragment must implement "
// + "ArticleListContract.NavigatorProvider");
// }
//
// @Override
// public void onStart() {
// super.onStart();
// mPresenter.onAttachView(this);
// }
//
// @Override
// public void onStop() {
// super.onStop();
// mPresenter.onDetachView();
// }
//
// @Override
// public void displayArticles(@NonNull final List<Article> articles,
// @NonNull final OnArticleClickListener onArticleClickListener) {
// mRecyclerView.setAdapter(new ArticleListAdapter(articles, onArticleClickListener));
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/favorite_list/FavoriteListFragment.java
// public class FavoriteListFragment extends Fragment implements FavoriteListContract.View {
//
// private FavoriteListContract.Presenter mPresenter;
//
// private RecyclerView mRecyclerView;
//
// public FavoriteListFragment() {
// // Required empty public constructor
// }
//
// @Override
// public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
// final Bundle savedInstanceState) {
// mPresenter = createPresenter();
//
// // Inflate the layout for this fragment
// mRecyclerView = (RecyclerView) inflater.inflate(R.layout.fragment_favorite_article_list, container, false);
// mRecyclerView.setLayoutManager(new LinearLayoutManager(container.getContext(), LinearLayoutManager.VERTICAL,
// false));
// return mRecyclerView;
// }
//
// @NonNull
// protected FavoriteListContract.Presenter createPresenter() {
// FavoriteListContract.Presenter presenter = new FavoriteListPresenter();
// presenter.setNavigator(getNavigator(presenter));
// return presenter;
// }
//
// @NonNull
// protected FavoriteListContract.Navigator getNavigator(final FavoriteListContract.Presenter presenter) {
// Fragment parentFragment = getParentFragment();
// if (parentFragment != null && parentFragment instanceof FavoriteListContract.NavigatorProvider) {
// return ((FavoriteListContract.NavigatorProvider) parentFragment).getNavigator(presenter);
// } else {
// Activity activity = getActivity();
// if (activity instanceof FavoriteListContract.NavigatorProvider) {
// return ((FavoriteListContract.NavigatorProvider) activity).getNavigator(presenter);
// }
// }
//
// throw new IllegalStateException("Activity or parent Fragment must implement "
// + "FavoriteListContract.NavigatorProvider");
// }
//
// @Override
// public void onStart() {
// super.onStart();
// mPresenter.onAttachView(this);
// }
//
// @Override
// public void onStop() {
// super.onStop();
// mPresenter.onDetachView();
// }
//
// @Override
// public void displayArticles(@NonNull final List<Article> articles,
// @NonNull final OnArticleClickListener onArticleClickListener) {
// mRecyclerView.setAdapter(new ArticleListAdapter(articles, onArticleClickListener));
// }
// }
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example3_viewpager/ViewPagerAdapter.java
import org.kaerdan.mvp_navigation.core.ui.article_list.ArticleListFragment;
import org.kaerdan.mvp_navigation.core.ui.favorite_list.FavoriteListFragment;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
package org.kaerdan.mvp_navigation.example3_viewpager;
public class ViewPagerAdapter extends FragmentPagerAdapter {
public ViewPagerAdapter(final FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(final int position) {
if (position == 0) {
return new ArticleListFragment();
} | return new FavoriteListFragment(); |
NikitaKozlov/MVP-Navigation | app/src/main/java/org/kaerdan/mvp_navigation/core/ui/article_list/ArticleListFragment.java | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/Article.java
// public class Article {
// private final int id;
// private final String title;
// private final String body;
// private final boolean isFavourite;
//
// public Article(int id, String title, String body, boolean isFavourite) {
// this.id = id;
// this.title = title;
// this.body = body;
// this.isFavourite = isFavourite;
// }
//
// public int getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getBody() {
// return body;
// }
//
// public boolean isFavourite() {
// return isFavourite;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/ArticleListAdapter.java
// public class ArticleListAdapter extends RecyclerView.Adapter<ArticleListAdapter.ArticleViewHolder> {
//
// private final List<Article> mArticles;
// private final OnArticleClickListener mOnArticleClickListener;
//
// public ArticleListAdapter(@NonNull final List<Article> articles,
// @NonNull final OnArticleClickListener onArticleClickListener) {
// this.mArticles = articles;
// this.mOnArticleClickListener = onArticleClickListener;
// }
//
// @Override
// public ArticleViewHolder onCreateViewHolder(final ViewGroup parent, final int viewType) {
// return new ArticleViewHolder(new Button(parent.getContext()));
// }
//
// @Override
// public void onBindViewHolder(final ArticleViewHolder holder, final int position) {
// final Article article = mArticles.get(position);
// ((Button) holder.itemView).setText(article.getTitle());
// holder.itemView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(final View v) {
// mOnArticleClickListener.onArticleClick(article.getId());
// }
// });
// }
//
// @Override
// public int getItemCount() {
// return mArticles.size();
// }
//
// static class ArticleViewHolder extends RecyclerView.ViewHolder {
// public ArticleViewHolder(final View itemView) {
// super(itemView);
// }
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/OnArticleClickListener.java
// public interface OnArticleClickListener {
// void onArticleClick(int id);
// }
| import java.util.List;
import org.kaerdan.mvp_navigation.R;
import org.kaerdan.mvp_navigation.core.data.Article;
import org.kaerdan.mvp_navigation.core.ui.ArticleListAdapter;
import org.kaerdan.mvp_navigation.core.ui.OnArticleClickListener;
import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup; |
@NonNull
protected ArticleListContract.Navigator getNavigator(final ArticleListContract.Presenter presenter) {
Fragment parentFragment = getParentFragment();
if (parentFragment != null && parentFragment instanceof ArticleListContract.NavigatorProvider) {
return ((ArticleListContract.NavigatorProvider) parentFragment).getNavigator(presenter);
} else {
Activity activity = getActivity();
if (activity instanceof ArticleListContract.NavigatorProvider) {
return ((ArticleListContract.NavigatorProvider) activity).getNavigator(presenter);
}
}
throw new IllegalStateException("Activity or parent Fragment must implement "
+ "ArticleListContract.NavigatorProvider");
}
@Override
public void onStart() {
super.onStart();
mPresenter.onAttachView(this);
}
@Override
public void onStop() {
super.onStop();
mPresenter.onDetachView();
}
@Override | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/Article.java
// public class Article {
// private final int id;
// private final String title;
// private final String body;
// private final boolean isFavourite;
//
// public Article(int id, String title, String body, boolean isFavourite) {
// this.id = id;
// this.title = title;
// this.body = body;
// this.isFavourite = isFavourite;
// }
//
// public int getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getBody() {
// return body;
// }
//
// public boolean isFavourite() {
// return isFavourite;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/ArticleListAdapter.java
// public class ArticleListAdapter extends RecyclerView.Adapter<ArticleListAdapter.ArticleViewHolder> {
//
// private final List<Article> mArticles;
// private final OnArticleClickListener mOnArticleClickListener;
//
// public ArticleListAdapter(@NonNull final List<Article> articles,
// @NonNull final OnArticleClickListener onArticleClickListener) {
// this.mArticles = articles;
// this.mOnArticleClickListener = onArticleClickListener;
// }
//
// @Override
// public ArticleViewHolder onCreateViewHolder(final ViewGroup parent, final int viewType) {
// return new ArticleViewHolder(new Button(parent.getContext()));
// }
//
// @Override
// public void onBindViewHolder(final ArticleViewHolder holder, final int position) {
// final Article article = mArticles.get(position);
// ((Button) holder.itemView).setText(article.getTitle());
// holder.itemView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(final View v) {
// mOnArticleClickListener.onArticleClick(article.getId());
// }
// });
// }
//
// @Override
// public int getItemCount() {
// return mArticles.size();
// }
//
// static class ArticleViewHolder extends RecyclerView.ViewHolder {
// public ArticleViewHolder(final View itemView) {
// super(itemView);
// }
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/OnArticleClickListener.java
// public interface OnArticleClickListener {
// void onArticleClick(int id);
// }
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/article_list/ArticleListFragment.java
import java.util.List;
import org.kaerdan.mvp_navigation.R;
import org.kaerdan.mvp_navigation.core.data.Article;
import org.kaerdan.mvp_navigation.core.ui.ArticleListAdapter;
import org.kaerdan.mvp_navigation.core.ui.OnArticleClickListener;
import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@NonNull
protected ArticleListContract.Navigator getNavigator(final ArticleListContract.Presenter presenter) {
Fragment parentFragment = getParentFragment();
if (parentFragment != null && parentFragment instanceof ArticleListContract.NavigatorProvider) {
return ((ArticleListContract.NavigatorProvider) parentFragment).getNavigator(presenter);
} else {
Activity activity = getActivity();
if (activity instanceof ArticleListContract.NavigatorProvider) {
return ((ArticleListContract.NavigatorProvider) activity).getNavigator(presenter);
}
}
throw new IllegalStateException("Activity or parent Fragment must implement "
+ "ArticleListContract.NavigatorProvider");
}
@Override
public void onStart() {
super.onStart();
mPresenter.onAttachView(this);
}
@Override
public void onStop() {
super.onStop();
mPresenter.onDetachView();
}
@Override | public void displayArticles(@NonNull final List<Article> articles, |
NikitaKozlov/MVP-Navigation | app/src/main/java/org/kaerdan/mvp_navigation/core/ui/article_list/ArticleListFragment.java | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/Article.java
// public class Article {
// private final int id;
// private final String title;
// private final String body;
// private final boolean isFavourite;
//
// public Article(int id, String title, String body, boolean isFavourite) {
// this.id = id;
// this.title = title;
// this.body = body;
// this.isFavourite = isFavourite;
// }
//
// public int getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getBody() {
// return body;
// }
//
// public boolean isFavourite() {
// return isFavourite;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/ArticleListAdapter.java
// public class ArticleListAdapter extends RecyclerView.Adapter<ArticleListAdapter.ArticleViewHolder> {
//
// private final List<Article> mArticles;
// private final OnArticleClickListener mOnArticleClickListener;
//
// public ArticleListAdapter(@NonNull final List<Article> articles,
// @NonNull final OnArticleClickListener onArticleClickListener) {
// this.mArticles = articles;
// this.mOnArticleClickListener = onArticleClickListener;
// }
//
// @Override
// public ArticleViewHolder onCreateViewHolder(final ViewGroup parent, final int viewType) {
// return new ArticleViewHolder(new Button(parent.getContext()));
// }
//
// @Override
// public void onBindViewHolder(final ArticleViewHolder holder, final int position) {
// final Article article = mArticles.get(position);
// ((Button) holder.itemView).setText(article.getTitle());
// holder.itemView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(final View v) {
// mOnArticleClickListener.onArticleClick(article.getId());
// }
// });
// }
//
// @Override
// public int getItemCount() {
// return mArticles.size();
// }
//
// static class ArticleViewHolder extends RecyclerView.ViewHolder {
// public ArticleViewHolder(final View itemView) {
// super(itemView);
// }
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/OnArticleClickListener.java
// public interface OnArticleClickListener {
// void onArticleClick(int id);
// }
| import java.util.List;
import org.kaerdan.mvp_navigation.R;
import org.kaerdan.mvp_navigation.core.data.Article;
import org.kaerdan.mvp_navigation.core.ui.ArticleListAdapter;
import org.kaerdan.mvp_navigation.core.ui.OnArticleClickListener;
import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup; | @NonNull
protected ArticleListContract.Navigator getNavigator(final ArticleListContract.Presenter presenter) {
Fragment parentFragment = getParentFragment();
if (parentFragment != null && parentFragment instanceof ArticleListContract.NavigatorProvider) {
return ((ArticleListContract.NavigatorProvider) parentFragment).getNavigator(presenter);
} else {
Activity activity = getActivity();
if (activity instanceof ArticleListContract.NavigatorProvider) {
return ((ArticleListContract.NavigatorProvider) activity).getNavigator(presenter);
}
}
throw new IllegalStateException("Activity or parent Fragment must implement "
+ "ArticleListContract.NavigatorProvider");
}
@Override
public void onStart() {
super.onStart();
mPresenter.onAttachView(this);
}
@Override
public void onStop() {
super.onStop();
mPresenter.onDetachView();
}
@Override
public void displayArticles(@NonNull final List<Article> articles, | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/Article.java
// public class Article {
// private final int id;
// private final String title;
// private final String body;
// private final boolean isFavourite;
//
// public Article(int id, String title, String body, boolean isFavourite) {
// this.id = id;
// this.title = title;
// this.body = body;
// this.isFavourite = isFavourite;
// }
//
// public int getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getBody() {
// return body;
// }
//
// public boolean isFavourite() {
// return isFavourite;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/ArticleListAdapter.java
// public class ArticleListAdapter extends RecyclerView.Adapter<ArticleListAdapter.ArticleViewHolder> {
//
// private final List<Article> mArticles;
// private final OnArticleClickListener mOnArticleClickListener;
//
// public ArticleListAdapter(@NonNull final List<Article> articles,
// @NonNull final OnArticleClickListener onArticleClickListener) {
// this.mArticles = articles;
// this.mOnArticleClickListener = onArticleClickListener;
// }
//
// @Override
// public ArticleViewHolder onCreateViewHolder(final ViewGroup parent, final int viewType) {
// return new ArticleViewHolder(new Button(parent.getContext()));
// }
//
// @Override
// public void onBindViewHolder(final ArticleViewHolder holder, final int position) {
// final Article article = mArticles.get(position);
// ((Button) holder.itemView).setText(article.getTitle());
// holder.itemView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(final View v) {
// mOnArticleClickListener.onArticleClick(article.getId());
// }
// });
// }
//
// @Override
// public int getItemCount() {
// return mArticles.size();
// }
//
// static class ArticleViewHolder extends RecyclerView.ViewHolder {
// public ArticleViewHolder(final View itemView) {
// super(itemView);
// }
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/OnArticleClickListener.java
// public interface OnArticleClickListener {
// void onArticleClick(int id);
// }
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/article_list/ArticleListFragment.java
import java.util.List;
import org.kaerdan.mvp_navigation.R;
import org.kaerdan.mvp_navigation.core.data.Article;
import org.kaerdan.mvp_navigation.core.ui.ArticleListAdapter;
import org.kaerdan.mvp_navigation.core.ui.OnArticleClickListener;
import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@NonNull
protected ArticleListContract.Navigator getNavigator(final ArticleListContract.Presenter presenter) {
Fragment parentFragment = getParentFragment();
if (parentFragment != null && parentFragment instanceof ArticleListContract.NavigatorProvider) {
return ((ArticleListContract.NavigatorProvider) parentFragment).getNavigator(presenter);
} else {
Activity activity = getActivity();
if (activity instanceof ArticleListContract.NavigatorProvider) {
return ((ArticleListContract.NavigatorProvider) activity).getNavigator(presenter);
}
}
throw new IllegalStateException("Activity or parent Fragment must implement "
+ "ArticleListContract.NavigatorProvider");
}
@Override
public void onStart() {
super.onStart();
mPresenter.onAttachView(this);
}
@Override
public void onStop() {
super.onStop();
mPresenter.onDetachView();
}
@Override
public void displayArticles(@NonNull final List<Article> articles, | @NonNull final OnArticleClickListener onArticleClickListener) { |
NikitaKozlov/MVP-Navigation | app/src/main/java/org/kaerdan/mvp_navigation/core/ui/article_list/ArticleListFragment.java | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/Article.java
// public class Article {
// private final int id;
// private final String title;
// private final String body;
// private final boolean isFavourite;
//
// public Article(int id, String title, String body, boolean isFavourite) {
// this.id = id;
// this.title = title;
// this.body = body;
// this.isFavourite = isFavourite;
// }
//
// public int getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getBody() {
// return body;
// }
//
// public boolean isFavourite() {
// return isFavourite;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/ArticleListAdapter.java
// public class ArticleListAdapter extends RecyclerView.Adapter<ArticleListAdapter.ArticleViewHolder> {
//
// private final List<Article> mArticles;
// private final OnArticleClickListener mOnArticleClickListener;
//
// public ArticleListAdapter(@NonNull final List<Article> articles,
// @NonNull final OnArticleClickListener onArticleClickListener) {
// this.mArticles = articles;
// this.mOnArticleClickListener = onArticleClickListener;
// }
//
// @Override
// public ArticleViewHolder onCreateViewHolder(final ViewGroup parent, final int viewType) {
// return new ArticleViewHolder(new Button(parent.getContext()));
// }
//
// @Override
// public void onBindViewHolder(final ArticleViewHolder holder, final int position) {
// final Article article = mArticles.get(position);
// ((Button) holder.itemView).setText(article.getTitle());
// holder.itemView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(final View v) {
// mOnArticleClickListener.onArticleClick(article.getId());
// }
// });
// }
//
// @Override
// public int getItemCount() {
// return mArticles.size();
// }
//
// static class ArticleViewHolder extends RecyclerView.ViewHolder {
// public ArticleViewHolder(final View itemView) {
// super(itemView);
// }
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/OnArticleClickListener.java
// public interface OnArticleClickListener {
// void onArticleClick(int id);
// }
| import java.util.List;
import org.kaerdan.mvp_navigation.R;
import org.kaerdan.mvp_navigation.core.data.Article;
import org.kaerdan.mvp_navigation.core.ui.ArticleListAdapter;
import org.kaerdan.mvp_navigation.core.ui.OnArticleClickListener;
import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup; | protected ArticleListContract.Navigator getNavigator(final ArticleListContract.Presenter presenter) {
Fragment parentFragment = getParentFragment();
if (parentFragment != null && parentFragment instanceof ArticleListContract.NavigatorProvider) {
return ((ArticleListContract.NavigatorProvider) parentFragment).getNavigator(presenter);
} else {
Activity activity = getActivity();
if (activity instanceof ArticleListContract.NavigatorProvider) {
return ((ArticleListContract.NavigatorProvider) activity).getNavigator(presenter);
}
}
throw new IllegalStateException("Activity or parent Fragment must implement "
+ "ArticleListContract.NavigatorProvider");
}
@Override
public void onStart() {
super.onStart();
mPresenter.onAttachView(this);
}
@Override
public void onStop() {
super.onStop();
mPresenter.onDetachView();
}
@Override
public void displayArticles(@NonNull final List<Article> articles,
@NonNull final OnArticleClickListener onArticleClickListener) { | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/Article.java
// public class Article {
// private final int id;
// private final String title;
// private final String body;
// private final boolean isFavourite;
//
// public Article(int id, String title, String body, boolean isFavourite) {
// this.id = id;
// this.title = title;
// this.body = body;
// this.isFavourite = isFavourite;
// }
//
// public int getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getBody() {
// return body;
// }
//
// public boolean isFavourite() {
// return isFavourite;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/ArticleListAdapter.java
// public class ArticleListAdapter extends RecyclerView.Adapter<ArticleListAdapter.ArticleViewHolder> {
//
// private final List<Article> mArticles;
// private final OnArticleClickListener mOnArticleClickListener;
//
// public ArticleListAdapter(@NonNull final List<Article> articles,
// @NonNull final OnArticleClickListener onArticleClickListener) {
// this.mArticles = articles;
// this.mOnArticleClickListener = onArticleClickListener;
// }
//
// @Override
// public ArticleViewHolder onCreateViewHolder(final ViewGroup parent, final int viewType) {
// return new ArticleViewHolder(new Button(parent.getContext()));
// }
//
// @Override
// public void onBindViewHolder(final ArticleViewHolder holder, final int position) {
// final Article article = mArticles.get(position);
// ((Button) holder.itemView).setText(article.getTitle());
// holder.itemView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(final View v) {
// mOnArticleClickListener.onArticleClick(article.getId());
// }
// });
// }
//
// @Override
// public int getItemCount() {
// return mArticles.size();
// }
//
// static class ArticleViewHolder extends RecyclerView.ViewHolder {
// public ArticleViewHolder(final View itemView) {
// super(itemView);
// }
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/OnArticleClickListener.java
// public interface OnArticleClickListener {
// void onArticleClick(int id);
// }
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/article_list/ArticleListFragment.java
import java.util.List;
import org.kaerdan.mvp_navigation.R;
import org.kaerdan.mvp_navigation.core.data.Article;
import org.kaerdan.mvp_navigation.core.ui.ArticleListAdapter;
import org.kaerdan.mvp_navigation.core.ui.OnArticleClickListener;
import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
protected ArticleListContract.Navigator getNavigator(final ArticleListContract.Presenter presenter) {
Fragment parentFragment = getParentFragment();
if (parentFragment != null && parentFragment instanceof ArticleListContract.NavigatorProvider) {
return ((ArticleListContract.NavigatorProvider) parentFragment).getNavigator(presenter);
} else {
Activity activity = getActivity();
if (activity instanceof ArticleListContract.NavigatorProvider) {
return ((ArticleListContract.NavigatorProvider) activity).getNavigator(presenter);
}
}
throw new IllegalStateException("Activity or parent Fragment must implement "
+ "ArticleListContract.NavigatorProvider");
}
@Override
public void onStart() {
super.onStart();
mPresenter.onAttachView(this);
}
@Override
public void onStop() {
super.onStop();
mPresenter.onDetachView();
}
@Override
public void displayArticles(@NonNull final List<Article> articles,
@NonNull final OnArticleClickListener onArticleClickListener) { | mRecyclerView.setAdapter(new ArticleListAdapter(articles, onArticleClickListener)); |
NikitaKozlov/MVP-Navigation | app/src/main/java/org/kaerdan/mvp_navigation/core/ui/article/ArticleFragment.java | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/Article.java
// public class Article {
// private final int id;
// private final String title;
// private final String body;
// private final boolean isFavourite;
//
// public Article(int id, String title, String body, boolean isFavourite) {
// this.id = id;
// this.title = title;
// this.body = body;
// this.isFavourite = isFavourite;
// }
//
// public int getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getBody() {
// return body;
// }
//
// public boolean isFavourite() {
// return isFavourite;
// }
// }
| import org.kaerdan.mvp_navigation.R;
import org.kaerdan.mvp_navigation.core.data.Article;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView; |
public ArticleFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
final Bundle savedInstanceState) {
// Inflate the layout for this fragment
mPresenter = new ArticlePresenter(getArguments().getInt(ARTICLE_ID_TAG));
View v = inflater.inflate(R.layout.fragment_article, container, false);
mArticleTextView = (TextView) v.findViewById(R.id.article_body);
return v;
}
@Override
public void onStart() {
super.onStart();
mPresenter.onAttachView(this);
}
@Override
public void onStop() {
super.onStop();
mPresenter.onDetachView();
}
@Override | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/Article.java
// public class Article {
// private final int id;
// private final String title;
// private final String body;
// private final boolean isFavourite;
//
// public Article(int id, String title, String body, boolean isFavourite) {
// this.id = id;
// this.title = title;
// this.body = body;
// this.isFavourite = isFavourite;
// }
//
// public int getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getBody() {
// return body;
// }
//
// public boolean isFavourite() {
// return isFavourite;
// }
// }
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/article/ArticleFragment.java
import org.kaerdan.mvp_navigation.R;
import org.kaerdan.mvp_navigation.core.data.Article;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
public ArticleFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
final Bundle savedInstanceState) {
// Inflate the layout for this fragment
mPresenter = new ArticlePresenter(getArguments().getInt(ARTICLE_ID_TAG));
View v = inflater.inflate(R.layout.fragment_article, container, false);
mArticleTextView = (TextView) v.findViewById(R.id.article_body);
return v;
}
@Override
public void onStart() {
super.onStart();
mPresenter.onAttachView(this);
}
@Override
public void onStop() {
super.onStop();
mPresenter.onDetachView();
}
@Override | public void displayArticle(@NonNull final Article article) { |
NikitaKozlov/MVP-Navigation | app/src/main/java/org/kaerdan/mvp_navigation/example4_injection/InjectArticleListFragment.java | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/Article.java
// public class Article {
// private final int id;
// private final String title;
// private final String body;
// private final boolean isFavourite;
//
// public Article(int id, String title, String body, boolean isFavourite) {
// this.id = id;
// this.title = title;
// this.body = body;
// this.isFavourite = isFavourite;
// }
//
// public int getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getBody() {
// return body;
// }
//
// public boolean isFavourite() {
// return isFavourite;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/ArticleListAdapter.java
// public class ArticleListAdapter extends RecyclerView.Adapter<ArticleListAdapter.ArticleViewHolder> {
//
// private final List<Article> mArticles;
// private final OnArticleClickListener mOnArticleClickListener;
//
// public ArticleListAdapter(@NonNull final List<Article> articles,
// @NonNull final OnArticleClickListener onArticleClickListener) {
// this.mArticles = articles;
// this.mOnArticleClickListener = onArticleClickListener;
// }
//
// @Override
// public ArticleViewHolder onCreateViewHolder(final ViewGroup parent, final int viewType) {
// return new ArticleViewHolder(new Button(parent.getContext()));
// }
//
// @Override
// public void onBindViewHolder(final ArticleViewHolder holder, final int position) {
// final Article article = mArticles.get(position);
// ((Button) holder.itemView).setText(article.getTitle());
// holder.itemView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(final View v) {
// mOnArticleClickListener.onArticleClick(article.getId());
// }
// });
// }
//
// @Override
// public int getItemCount() {
// return mArticles.size();
// }
//
// static class ArticleViewHolder extends RecyclerView.ViewHolder {
// public ArticleViewHolder(final View itemView) {
// super(itemView);
// }
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/OnArticleClickListener.java
// public interface OnArticleClickListener {
// void onArticleClick(int id);
// }
| import java.util.List;
import org.kaerdan.mvp_navigation.R;
import org.kaerdan.mvp_navigation.core.data.Article;
import org.kaerdan.mvp_navigation.core.ui.ArticleListAdapter;
import org.kaerdan.mvp_navigation.core.ui.OnArticleClickListener;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup; | View view = inflater.inflate(R.layout.fragment_article_list, container, false);
mRecyclerView = (RecyclerView) view.findViewById(R.id.article_list);
mRecyclerView.setLayoutManager(new LinearLayoutManager(container.getContext(), LinearLayoutManager.VERTICAL,
false));
Injector.inject(this);
view.findViewById(R.id.favorite_articles).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View v) {
mPresenter.onFavoriteArticleClick();
}
});
return view;
}
@Override
public void onStart() {
super.onStart();
mPresenter.onAttachView(this);
}
@Override
public void onStop() {
super.onStop();
mPresenter.onDetachView();
}
@Override | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/Article.java
// public class Article {
// private final int id;
// private final String title;
// private final String body;
// private final boolean isFavourite;
//
// public Article(int id, String title, String body, boolean isFavourite) {
// this.id = id;
// this.title = title;
// this.body = body;
// this.isFavourite = isFavourite;
// }
//
// public int getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getBody() {
// return body;
// }
//
// public boolean isFavourite() {
// return isFavourite;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/ArticleListAdapter.java
// public class ArticleListAdapter extends RecyclerView.Adapter<ArticleListAdapter.ArticleViewHolder> {
//
// private final List<Article> mArticles;
// private final OnArticleClickListener mOnArticleClickListener;
//
// public ArticleListAdapter(@NonNull final List<Article> articles,
// @NonNull final OnArticleClickListener onArticleClickListener) {
// this.mArticles = articles;
// this.mOnArticleClickListener = onArticleClickListener;
// }
//
// @Override
// public ArticleViewHolder onCreateViewHolder(final ViewGroup parent, final int viewType) {
// return new ArticleViewHolder(new Button(parent.getContext()));
// }
//
// @Override
// public void onBindViewHolder(final ArticleViewHolder holder, final int position) {
// final Article article = mArticles.get(position);
// ((Button) holder.itemView).setText(article.getTitle());
// holder.itemView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(final View v) {
// mOnArticleClickListener.onArticleClick(article.getId());
// }
// });
// }
//
// @Override
// public int getItemCount() {
// return mArticles.size();
// }
//
// static class ArticleViewHolder extends RecyclerView.ViewHolder {
// public ArticleViewHolder(final View itemView) {
// super(itemView);
// }
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/OnArticleClickListener.java
// public interface OnArticleClickListener {
// void onArticleClick(int id);
// }
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example4_injection/InjectArticleListFragment.java
import java.util.List;
import org.kaerdan.mvp_navigation.R;
import org.kaerdan.mvp_navigation.core.data.Article;
import org.kaerdan.mvp_navigation.core.ui.ArticleListAdapter;
import org.kaerdan.mvp_navigation.core.ui.OnArticleClickListener;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
View view = inflater.inflate(R.layout.fragment_article_list, container, false);
mRecyclerView = (RecyclerView) view.findViewById(R.id.article_list);
mRecyclerView.setLayoutManager(new LinearLayoutManager(container.getContext(), LinearLayoutManager.VERTICAL,
false));
Injector.inject(this);
view.findViewById(R.id.favorite_articles).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View v) {
mPresenter.onFavoriteArticleClick();
}
});
return view;
}
@Override
public void onStart() {
super.onStart();
mPresenter.onAttachView(this);
}
@Override
public void onStop() {
super.onStop();
mPresenter.onDetachView();
}
@Override | public void displayArticles(@NonNull final List<Article> articles, |
NikitaKozlov/MVP-Navigation | app/src/main/java/org/kaerdan/mvp_navigation/example4_injection/InjectArticleListFragment.java | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/Article.java
// public class Article {
// private final int id;
// private final String title;
// private final String body;
// private final boolean isFavourite;
//
// public Article(int id, String title, String body, boolean isFavourite) {
// this.id = id;
// this.title = title;
// this.body = body;
// this.isFavourite = isFavourite;
// }
//
// public int getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getBody() {
// return body;
// }
//
// public boolean isFavourite() {
// return isFavourite;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/ArticleListAdapter.java
// public class ArticleListAdapter extends RecyclerView.Adapter<ArticleListAdapter.ArticleViewHolder> {
//
// private final List<Article> mArticles;
// private final OnArticleClickListener mOnArticleClickListener;
//
// public ArticleListAdapter(@NonNull final List<Article> articles,
// @NonNull final OnArticleClickListener onArticleClickListener) {
// this.mArticles = articles;
// this.mOnArticleClickListener = onArticleClickListener;
// }
//
// @Override
// public ArticleViewHolder onCreateViewHolder(final ViewGroup parent, final int viewType) {
// return new ArticleViewHolder(new Button(parent.getContext()));
// }
//
// @Override
// public void onBindViewHolder(final ArticleViewHolder holder, final int position) {
// final Article article = mArticles.get(position);
// ((Button) holder.itemView).setText(article.getTitle());
// holder.itemView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(final View v) {
// mOnArticleClickListener.onArticleClick(article.getId());
// }
// });
// }
//
// @Override
// public int getItemCount() {
// return mArticles.size();
// }
//
// static class ArticleViewHolder extends RecyclerView.ViewHolder {
// public ArticleViewHolder(final View itemView) {
// super(itemView);
// }
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/OnArticleClickListener.java
// public interface OnArticleClickListener {
// void onArticleClick(int id);
// }
| import java.util.List;
import org.kaerdan.mvp_navigation.R;
import org.kaerdan.mvp_navigation.core.data.Article;
import org.kaerdan.mvp_navigation.core.ui.ArticleListAdapter;
import org.kaerdan.mvp_navigation.core.ui.OnArticleClickListener;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup; | mRecyclerView = (RecyclerView) view.findViewById(R.id.article_list);
mRecyclerView.setLayoutManager(new LinearLayoutManager(container.getContext(), LinearLayoutManager.VERTICAL,
false));
Injector.inject(this);
view.findViewById(R.id.favorite_articles).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View v) {
mPresenter.onFavoriteArticleClick();
}
});
return view;
}
@Override
public void onStart() {
super.onStart();
mPresenter.onAttachView(this);
}
@Override
public void onStop() {
super.onStop();
mPresenter.onDetachView();
}
@Override
public void displayArticles(@NonNull final List<Article> articles, | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/Article.java
// public class Article {
// private final int id;
// private final String title;
// private final String body;
// private final boolean isFavourite;
//
// public Article(int id, String title, String body, boolean isFavourite) {
// this.id = id;
// this.title = title;
// this.body = body;
// this.isFavourite = isFavourite;
// }
//
// public int getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getBody() {
// return body;
// }
//
// public boolean isFavourite() {
// return isFavourite;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/ArticleListAdapter.java
// public class ArticleListAdapter extends RecyclerView.Adapter<ArticleListAdapter.ArticleViewHolder> {
//
// private final List<Article> mArticles;
// private final OnArticleClickListener mOnArticleClickListener;
//
// public ArticleListAdapter(@NonNull final List<Article> articles,
// @NonNull final OnArticleClickListener onArticleClickListener) {
// this.mArticles = articles;
// this.mOnArticleClickListener = onArticleClickListener;
// }
//
// @Override
// public ArticleViewHolder onCreateViewHolder(final ViewGroup parent, final int viewType) {
// return new ArticleViewHolder(new Button(parent.getContext()));
// }
//
// @Override
// public void onBindViewHolder(final ArticleViewHolder holder, final int position) {
// final Article article = mArticles.get(position);
// ((Button) holder.itemView).setText(article.getTitle());
// holder.itemView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(final View v) {
// mOnArticleClickListener.onArticleClick(article.getId());
// }
// });
// }
//
// @Override
// public int getItemCount() {
// return mArticles.size();
// }
//
// static class ArticleViewHolder extends RecyclerView.ViewHolder {
// public ArticleViewHolder(final View itemView) {
// super(itemView);
// }
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/OnArticleClickListener.java
// public interface OnArticleClickListener {
// void onArticleClick(int id);
// }
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example4_injection/InjectArticleListFragment.java
import java.util.List;
import org.kaerdan.mvp_navigation.R;
import org.kaerdan.mvp_navigation.core.data.Article;
import org.kaerdan.mvp_navigation.core.ui.ArticleListAdapter;
import org.kaerdan.mvp_navigation.core.ui.OnArticleClickListener;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
mRecyclerView = (RecyclerView) view.findViewById(R.id.article_list);
mRecyclerView.setLayoutManager(new LinearLayoutManager(container.getContext(), LinearLayoutManager.VERTICAL,
false));
Injector.inject(this);
view.findViewById(R.id.favorite_articles).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View v) {
mPresenter.onFavoriteArticleClick();
}
});
return view;
}
@Override
public void onStart() {
super.onStart();
mPresenter.onAttachView(this);
}
@Override
public void onStop() {
super.onStop();
mPresenter.onDetachView();
}
@Override
public void displayArticles(@NonNull final List<Article> articles, | @NonNull final OnArticleClickListener onArticleClickListener) { |
NikitaKozlov/MVP-Navigation | app/src/main/java/org/kaerdan/mvp_navigation/example4_injection/InjectArticleListFragment.java | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/Article.java
// public class Article {
// private final int id;
// private final String title;
// private final String body;
// private final boolean isFavourite;
//
// public Article(int id, String title, String body, boolean isFavourite) {
// this.id = id;
// this.title = title;
// this.body = body;
// this.isFavourite = isFavourite;
// }
//
// public int getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getBody() {
// return body;
// }
//
// public boolean isFavourite() {
// return isFavourite;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/ArticleListAdapter.java
// public class ArticleListAdapter extends RecyclerView.Adapter<ArticleListAdapter.ArticleViewHolder> {
//
// private final List<Article> mArticles;
// private final OnArticleClickListener mOnArticleClickListener;
//
// public ArticleListAdapter(@NonNull final List<Article> articles,
// @NonNull final OnArticleClickListener onArticleClickListener) {
// this.mArticles = articles;
// this.mOnArticleClickListener = onArticleClickListener;
// }
//
// @Override
// public ArticleViewHolder onCreateViewHolder(final ViewGroup parent, final int viewType) {
// return new ArticleViewHolder(new Button(parent.getContext()));
// }
//
// @Override
// public void onBindViewHolder(final ArticleViewHolder holder, final int position) {
// final Article article = mArticles.get(position);
// ((Button) holder.itemView).setText(article.getTitle());
// holder.itemView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(final View v) {
// mOnArticleClickListener.onArticleClick(article.getId());
// }
// });
// }
//
// @Override
// public int getItemCount() {
// return mArticles.size();
// }
//
// static class ArticleViewHolder extends RecyclerView.ViewHolder {
// public ArticleViewHolder(final View itemView) {
// super(itemView);
// }
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/OnArticleClickListener.java
// public interface OnArticleClickListener {
// void onArticleClick(int id);
// }
| import java.util.List;
import org.kaerdan.mvp_navigation.R;
import org.kaerdan.mvp_navigation.core.data.Article;
import org.kaerdan.mvp_navigation.core.ui.ArticleListAdapter;
import org.kaerdan.mvp_navigation.core.ui.OnArticleClickListener;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup; | mRecyclerView.setLayoutManager(new LinearLayoutManager(container.getContext(), LinearLayoutManager.VERTICAL,
false));
Injector.inject(this);
view.findViewById(R.id.favorite_articles).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View v) {
mPresenter.onFavoriteArticleClick();
}
});
return view;
}
@Override
public void onStart() {
super.onStart();
mPresenter.onAttachView(this);
}
@Override
public void onStop() {
super.onStop();
mPresenter.onDetachView();
}
@Override
public void displayArticles(@NonNull final List<Article> articles,
@NonNull final OnArticleClickListener onArticleClickListener) { | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/Article.java
// public class Article {
// private final int id;
// private final String title;
// private final String body;
// private final boolean isFavourite;
//
// public Article(int id, String title, String body, boolean isFavourite) {
// this.id = id;
// this.title = title;
// this.body = body;
// this.isFavourite = isFavourite;
// }
//
// public int getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getBody() {
// return body;
// }
//
// public boolean isFavourite() {
// return isFavourite;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/ArticleListAdapter.java
// public class ArticleListAdapter extends RecyclerView.Adapter<ArticleListAdapter.ArticleViewHolder> {
//
// private final List<Article> mArticles;
// private final OnArticleClickListener mOnArticleClickListener;
//
// public ArticleListAdapter(@NonNull final List<Article> articles,
// @NonNull final OnArticleClickListener onArticleClickListener) {
// this.mArticles = articles;
// this.mOnArticleClickListener = onArticleClickListener;
// }
//
// @Override
// public ArticleViewHolder onCreateViewHolder(final ViewGroup parent, final int viewType) {
// return new ArticleViewHolder(new Button(parent.getContext()));
// }
//
// @Override
// public void onBindViewHolder(final ArticleViewHolder holder, final int position) {
// final Article article = mArticles.get(position);
// ((Button) holder.itemView).setText(article.getTitle());
// holder.itemView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(final View v) {
// mOnArticleClickListener.onArticleClick(article.getId());
// }
// });
// }
//
// @Override
// public int getItemCount() {
// return mArticles.size();
// }
//
// static class ArticleViewHolder extends RecyclerView.ViewHolder {
// public ArticleViewHolder(final View itemView) {
// super(itemView);
// }
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/OnArticleClickListener.java
// public interface OnArticleClickListener {
// void onArticleClick(int id);
// }
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example4_injection/InjectArticleListFragment.java
import java.util.List;
import org.kaerdan.mvp_navigation.R;
import org.kaerdan.mvp_navigation.core.data.Article;
import org.kaerdan.mvp_navigation.core.ui.ArticleListAdapter;
import org.kaerdan.mvp_navigation.core.ui.OnArticleClickListener;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
mRecyclerView.setLayoutManager(new LinearLayoutManager(container.getContext(), LinearLayoutManager.VERTICAL,
false));
Injector.inject(this);
view.findViewById(R.id.favorite_articles).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View v) {
mPresenter.onFavoriteArticleClick();
}
});
return view;
}
@Override
public void onStart() {
super.onStart();
mPresenter.onAttachView(this);
}
@Override
public void onStop() {
super.onStop();
mPresenter.onDetachView();
}
@Override
public void displayArticles(@NonNull final List<Article> articles,
@NonNull final OnArticleClickListener onArticleClickListener) { | mRecyclerView.setAdapter(new ArticleListAdapter(articles, onArticleClickListener)); |
NikitaKozlov/MVP-Navigation | app/src/main/java/org/kaerdan/mvp_navigation/example3_viewpager/ViewPagerFavoriteListNavigator.java | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/favorite_list/FavoriteListContract.java
// public interface FavoriteListContract {
// interface Presenter extends org.kaerdan.mvp_navigation.core.Presenter<View> {
// void setNavigator(@NonNull Navigator navigator);
// }
//
// interface View extends org.kaerdan.mvp_navigation.core.Presenter.View {
// void displayArticles(@NonNull List<Article> articles, @NonNull OnArticleClickListener onArticleClickListener);
// }
//
// interface Navigator {
// void openArticle(int id);
// }
//
// interface NavigatorProvider {
//
// @NonNull
// Navigator getNavigator(FavoriteListContract.Presenter presenter);
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example1_activities/ArticleActivity.java
// public class ArticleActivity extends AppCompatActivity {
//
// private static final String ARTICLE_ID_TAG = "Article id";
//
// public static Intent createIntent(final Context context, final int id) {
// Intent intent = new Intent(context, ArticleActivity.class);
// intent.putExtra(ARTICLE_ID_TAG, id);
// return intent;
// }
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_single_fragment);
// if (savedInstanceState == null) {
// getSupportFragmentManager().beginTransaction()
// .add(R.id.content_frame,
// ArticleFragment.newInstance(getIntent().getIntExtra(ARTICLE_ID_TAG, 0)), null).commit();
// }
//
// getSupportActionBar().setHomeButtonEnabled(true);
// getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// }
//
// @Override
// public boolean onOptionsItemSelected(final MenuItem item) {
// if (item.getItemId() == android.R.id.home) {
// onBackPressed();
// return true;
// }
//
// return super.onOptionsItemSelected(item);
// }
// }
| import org.kaerdan.mvp_navigation.core.ui.favorite_list.FavoriteListContract;
import org.kaerdan.mvp_navigation.example1_activities.ArticleActivity;
import android.content.Context; | package org.kaerdan.mvp_navigation.example3_viewpager;
public class ViewPagerFavoriteListNavigator implements FavoriteListContract.Navigator {
private final Context mActivityContext;
public ViewPagerFavoriteListNavigator(final Context mActivityContext) {
this.mActivityContext = mActivityContext;
}
@Override
public void openArticle(final int id) { | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/favorite_list/FavoriteListContract.java
// public interface FavoriteListContract {
// interface Presenter extends org.kaerdan.mvp_navigation.core.Presenter<View> {
// void setNavigator(@NonNull Navigator navigator);
// }
//
// interface View extends org.kaerdan.mvp_navigation.core.Presenter.View {
// void displayArticles(@NonNull List<Article> articles, @NonNull OnArticleClickListener onArticleClickListener);
// }
//
// interface Navigator {
// void openArticle(int id);
// }
//
// interface NavigatorProvider {
//
// @NonNull
// Navigator getNavigator(FavoriteListContract.Presenter presenter);
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example1_activities/ArticleActivity.java
// public class ArticleActivity extends AppCompatActivity {
//
// private static final String ARTICLE_ID_TAG = "Article id";
//
// public static Intent createIntent(final Context context, final int id) {
// Intent intent = new Intent(context, ArticleActivity.class);
// intent.putExtra(ARTICLE_ID_TAG, id);
// return intent;
// }
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_single_fragment);
// if (savedInstanceState == null) {
// getSupportFragmentManager().beginTransaction()
// .add(R.id.content_frame,
// ArticleFragment.newInstance(getIntent().getIntExtra(ARTICLE_ID_TAG, 0)), null).commit();
// }
//
// getSupportActionBar().setHomeButtonEnabled(true);
// getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// }
//
// @Override
// public boolean onOptionsItemSelected(final MenuItem item) {
// if (item.getItemId() == android.R.id.home) {
// onBackPressed();
// return true;
// }
//
// return super.onOptionsItemSelected(item);
// }
// }
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example3_viewpager/ViewPagerFavoriteListNavigator.java
import org.kaerdan.mvp_navigation.core.ui.favorite_list.FavoriteListContract;
import org.kaerdan.mvp_navigation.example1_activities.ArticleActivity;
import android.content.Context;
package org.kaerdan.mvp_navigation.example3_viewpager;
public class ViewPagerFavoriteListNavigator implements FavoriteListContract.Navigator {
private final Context mActivityContext;
public ViewPagerFavoriteListNavigator(final Context mActivityContext) {
this.mActivityContext = mActivityContext;
}
@Override
public void openArticle(final int id) { | mActivityContext.startActivity(ArticleActivity.createIntent(mActivityContext, id)); |
NikitaKozlov/MVP-Navigation | app/src/main/java/org/kaerdan/mvp_navigation/example5_retainpresenter/RetainPresenterActivityNavigator.java | // Path: app/src/main/java/org/kaerdan/mvp_navigation/example1_activities/ArticleActivity.java
// public class ArticleActivity extends AppCompatActivity {
//
// private static final String ARTICLE_ID_TAG = "Article id";
//
// public static Intent createIntent(final Context context, final int id) {
// Intent intent = new Intent(context, ArticleActivity.class);
// intent.putExtra(ARTICLE_ID_TAG, id);
// return intent;
// }
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_single_fragment);
// if (savedInstanceState == null) {
// getSupportFragmentManager().beginTransaction()
// .add(R.id.content_frame,
// ArticleFragment.newInstance(getIntent().getIntExtra(ARTICLE_ID_TAG, 0)), null).commit();
// }
//
// getSupportActionBar().setHomeButtonEnabled(true);
// getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// }
//
// @Override
// public boolean onOptionsItemSelected(final MenuItem item) {
// if (item.getItemId() == android.R.id.home) {
// onBackPressed();
// return true;
// }
//
// return super.onOptionsItemSelected(item);
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example1_activities/FavoriteListActivity.java
// public class FavoriteListActivity extends AppCompatActivity implements FavoriteListContract.NavigatorProvider {
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_single_fragment);
// if (savedInstanceState == null) {
// getSupportFragmentManager().beginTransaction().add(R.id.content_frame, new FavoriteListFragment(), null)
// .commit();
// }
//
// getSupportActionBar().setHomeButtonEnabled(true);
// getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// }
//
// @Override
// public boolean onOptionsItemSelected(final MenuItem item) {
// if (item.getItemId() == android.R.id.home) {
// onBackPressed();
// return true;
// }
//
// return super.onOptionsItemSelected(item);
// }
//
// @NonNull
// @Override
// public FavoriteListContract.Navigator getNavigator(final FavoriteListContract.Presenter presenter) {
// return new ActivitiesFavoriteListNavigator(this);
// }
// }
| import org.kaerdan.mvp_navigation.example1_activities.ArticleActivity;
import org.kaerdan.mvp_navigation.example1_activities.FavoriteListActivity;
import android.content.Context;
import android.content.Intent; | package org.kaerdan.mvp_navigation.example5_retainpresenter;
public class RetainPresenterActivityNavigator implements RetainPresenterArticleListContract.Navigator {
private final Context mActivityContext;
public RetainPresenterActivityNavigator(final Context activityContext) {
this.mActivityContext = activityContext;
}
@Override
public void openArticle(final int id) { | // Path: app/src/main/java/org/kaerdan/mvp_navigation/example1_activities/ArticleActivity.java
// public class ArticleActivity extends AppCompatActivity {
//
// private static final String ARTICLE_ID_TAG = "Article id";
//
// public static Intent createIntent(final Context context, final int id) {
// Intent intent = new Intent(context, ArticleActivity.class);
// intent.putExtra(ARTICLE_ID_TAG, id);
// return intent;
// }
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_single_fragment);
// if (savedInstanceState == null) {
// getSupportFragmentManager().beginTransaction()
// .add(R.id.content_frame,
// ArticleFragment.newInstance(getIntent().getIntExtra(ARTICLE_ID_TAG, 0)), null).commit();
// }
//
// getSupportActionBar().setHomeButtonEnabled(true);
// getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// }
//
// @Override
// public boolean onOptionsItemSelected(final MenuItem item) {
// if (item.getItemId() == android.R.id.home) {
// onBackPressed();
// return true;
// }
//
// return super.onOptionsItemSelected(item);
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example1_activities/FavoriteListActivity.java
// public class FavoriteListActivity extends AppCompatActivity implements FavoriteListContract.NavigatorProvider {
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_single_fragment);
// if (savedInstanceState == null) {
// getSupportFragmentManager().beginTransaction().add(R.id.content_frame, new FavoriteListFragment(), null)
// .commit();
// }
//
// getSupportActionBar().setHomeButtonEnabled(true);
// getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// }
//
// @Override
// public boolean onOptionsItemSelected(final MenuItem item) {
// if (item.getItemId() == android.R.id.home) {
// onBackPressed();
// return true;
// }
//
// return super.onOptionsItemSelected(item);
// }
//
// @NonNull
// @Override
// public FavoriteListContract.Navigator getNavigator(final FavoriteListContract.Presenter presenter) {
// return new ActivitiesFavoriteListNavigator(this);
// }
// }
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example5_retainpresenter/RetainPresenterActivityNavigator.java
import org.kaerdan.mvp_navigation.example1_activities.ArticleActivity;
import org.kaerdan.mvp_navigation.example1_activities.FavoriteListActivity;
import android.content.Context;
import android.content.Intent;
package org.kaerdan.mvp_navigation.example5_retainpresenter;
public class RetainPresenterActivityNavigator implements RetainPresenterArticleListContract.Navigator {
private final Context mActivityContext;
public RetainPresenterActivityNavigator(final Context activityContext) {
this.mActivityContext = activityContext;
}
@Override
public void openArticle(final int id) { | mActivityContext.startActivity(ArticleActivity.createIntent(mActivityContext, id)); |
NikitaKozlov/MVP-Navigation | app/src/main/java/org/kaerdan/mvp_navigation/example5_retainpresenter/RetainPresenterActivityNavigator.java | // Path: app/src/main/java/org/kaerdan/mvp_navigation/example1_activities/ArticleActivity.java
// public class ArticleActivity extends AppCompatActivity {
//
// private static final String ARTICLE_ID_TAG = "Article id";
//
// public static Intent createIntent(final Context context, final int id) {
// Intent intent = new Intent(context, ArticleActivity.class);
// intent.putExtra(ARTICLE_ID_TAG, id);
// return intent;
// }
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_single_fragment);
// if (savedInstanceState == null) {
// getSupportFragmentManager().beginTransaction()
// .add(R.id.content_frame,
// ArticleFragment.newInstance(getIntent().getIntExtra(ARTICLE_ID_TAG, 0)), null).commit();
// }
//
// getSupportActionBar().setHomeButtonEnabled(true);
// getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// }
//
// @Override
// public boolean onOptionsItemSelected(final MenuItem item) {
// if (item.getItemId() == android.R.id.home) {
// onBackPressed();
// return true;
// }
//
// return super.onOptionsItemSelected(item);
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example1_activities/FavoriteListActivity.java
// public class FavoriteListActivity extends AppCompatActivity implements FavoriteListContract.NavigatorProvider {
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_single_fragment);
// if (savedInstanceState == null) {
// getSupportFragmentManager().beginTransaction().add(R.id.content_frame, new FavoriteListFragment(), null)
// .commit();
// }
//
// getSupportActionBar().setHomeButtonEnabled(true);
// getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// }
//
// @Override
// public boolean onOptionsItemSelected(final MenuItem item) {
// if (item.getItemId() == android.R.id.home) {
// onBackPressed();
// return true;
// }
//
// return super.onOptionsItemSelected(item);
// }
//
// @NonNull
// @Override
// public FavoriteListContract.Navigator getNavigator(final FavoriteListContract.Presenter presenter) {
// return new ActivitiesFavoriteListNavigator(this);
// }
// }
| import org.kaerdan.mvp_navigation.example1_activities.ArticleActivity;
import org.kaerdan.mvp_navigation.example1_activities.FavoriteListActivity;
import android.content.Context;
import android.content.Intent; | package org.kaerdan.mvp_navigation.example5_retainpresenter;
public class RetainPresenterActivityNavigator implements RetainPresenterArticleListContract.Navigator {
private final Context mActivityContext;
public RetainPresenterActivityNavigator(final Context activityContext) {
this.mActivityContext = activityContext;
}
@Override
public void openArticle(final int id) {
mActivityContext.startActivity(ArticleActivity.createIntent(mActivityContext, id));
}
@Override
public void openFavoriteArticles() { | // Path: app/src/main/java/org/kaerdan/mvp_navigation/example1_activities/ArticleActivity.java
// public class ArticleActivity extends AppCompatActivity {
//
// private static final String ARTICLE_ID_TAG = "Article id";
//
// public static Intent createIntent(final Context context, final int id) {
// Intent intent = new Intent(context, ArticleActivity.class);
// intent.putExtra(ARTICLE_ID_TAG, id);
// return intent;
// }
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_single_fragment);
// if (savedInstanceState == null) {
// getSupportFragmentManager().beginTransaction()
// .add(R.id.content_frame,
// ArticleFragment.newInstance(getIntent().getIntExtra(ARTICLE_ID_TAG, 0)), null).commit();
// }
//
// getSupportActionBar().setHomeButtonEnabled(true);
// getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// }
//
// @Override
// public boolean onOptionsItemSelected(final MenuItem item) {
// if (item.getItemId() == android.R.id.home) {
// onBackPressed();
// return true;
// }
//
// return super.onOptionsItemSelected(item);
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example1_activities/FavoriteListActivity.java
// public class FavoriteListActivity extends AppCompatActivity implements FavoriteListContract.NavigatorProvider {
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_single_fragment);
// if (savedInstanceState == null) {
// getSupportFragmentManager().beginTransaction().add(R.id.content_frame, new FavoriteListFragment(), null)
// .commit();
// }
//
// getSupportActionBar().setHomeButtonEnabled(true);
// getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// }
//
// @Override
// public boolean onOptionsItemSelected(final MenuItem item) {
// if (item.getItemId() == android.R.id.home) {
// onBackPressed();
// return true;
// }
//
// return super.onOptionsItemSelected(item);
// }
//
// @NonNull
// @Override
// public FavoriteListContract.Navigator getNavigator(final FavoriteListContract.Presenter presenter) {
// return new ActivitiesFavoriteListNavigator(this);
// }
// }
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example5_retainpresenter/RetainPresenterActivityNavigator.java
import org.kaerdan.mvp_navigation.example1_activities.ArticleActivity;
import org.kaerdan.mvp_navigation.example1_activities.FavoriteListActivity;
import android.content.Context;
import android.content.Intent;
package org.kaerdan.mvp_navigation.example5_retainpresenter;
public class RetainPresenterActivityNavigator implements RetainPresenterArticleListContract.Navigator {
private final Context mActivityContext;
public RetainPresenterActivityNavigator(final Context activityContext) {
this.mActivityContext = activityContext;
}
@Override
public void openArticle(final int id) {
mActivityContext.startActivity(ArticleActivity.createIntent(mActivityContext, id));
}
@Override
public void openFavoriteArticles() { | mActivityContext.startActivity(new Intent(mActivityContext, FavoriteListActivity.class)); |
NikitaKozlov/MVP-Navigation | app/src/main/java/org/kaerdan/mvp_navigation/core/ui/favorite_list/FavoriteListContract.java | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/Article.java
// public class Article {
// private final int id;
// private final String title;
// private final String body;
// private final boolean isFavourite;
//
// public Article(int id, String title, String body, boolean isFavourite) {
// this.id = id;
// this.title = title;
// this.body = body;
// this.isFavourite = isFavourite;
// }
//
// public int getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getBody() {
// return body;
// }
//
// public boolean isFavourite() {
// return isFavourite;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/OnArticleClickListener.java
// public interface OnArticleClickListener {
// void onArticleClick(int id);
// }
| import java.util.List;
import org.kaerdan.mvp_navigation.core.data.Article;
import org.kaerdan.mvp_navigation.core.ui.OnArticleClickListener;
import android.support.annotation.NonNull; | package org.kaerdan.mvp_navigation.core.ui.favorite_list;
public interface FavoriteListContract {
interface Presenter extends org.kaerdan.mvp_navigation.core.Presenter<View> {
void setNavigator(@NonNull Navigator navigator);
}
interface View extends org.kaerdan.mvp_navigation.core.Presenter.View { | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/Article.java
// public class Article {
// private final int id;
// private final String title;
// private final String body;
// private final boolean isFavourite;
//
// public Article(int id, String title, String body, boolean isFavourite) {
// this.id = id;
// this.title = title;
// this.body = body;
// this.isFavourite = isFavourite;
// }
//
// public int getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getBody() {
// return body;
// }
//
// public boolean isFavourite() {
// return isFavourite;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/OnArticleClickListener.java
// public interface OnArticleClickListener {
// void onArticleClick(int id);
// }
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/favorite_list/FavoriteListContract.java
import java.util.List;
import org.kaerdan.mvp_navigation.core.data.Article;
import org.kaerdan.mvp_navigation.core.ui.OnArticleClickListener;
import android.support.annotation.NonNull;
package org.kaerdan.mvp_navigation.core.ui.favorite_list;
public interface FavoriteListContract {
interface Presenter extends org.kaerdan.mvp_navigation.core.Presenter<View> {
void setNavigator(@NonNull Navigator navigator);
}
interface View extends org.kaerdan.mvp_navigation.core.Presenter.View { | void displayArticles(@NonNull List<Article> articles, @NonNull OnArticleClickListener onArticleClickListener); |
NikitaKozlov/MVP-Navigation | app/src/main/java/org/kaerdan/mvp_navigation/core/ui/favorite_list/FavoriteListContract.java | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/Article.java
// public class Article {
// private final int id;
// private final String title;
// private final String body;
// private final boolean isFavourite;
//
// public Article(int id, String title, String body, boolean isFavourite) {
// this.id = id;
// this.title = title;
// this.body = body;
// this.isFavourite = isFavourite;
// }
//
// public int getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getBody() {
// return body;
// }
//
// public boolean isFavourite() {
// return isFavourite;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/OnArticleClickListener.java
// public interface OnArticleClickListener {
// void onArticleClick(int id);
// }
| import java.util.List;
import org.kaerdan.mvp_navigation.core.data.Article;
import org.kaerdan.mvp_navigation.core.ui.OnArticleClickListener;
import android.support.annotation.NonNull; | package org.kaerdan.mvp_navigation.core.ui.favorite_list;
public interface FavoriteListContract {
interface Presenter extends org.kaerdan.mvp_navigation.core.Presenter<View> {
void setNavigator(@NonNull Navigator navigator);
}
interface View extends org.kaerdan.mvp_navigation.core.Presenter.View { | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/Article.java
// public class Article {
// private final int id;
// private final String title;
// private final String body;
// private final boolean isFavourite;
//
// public Article(int id, String title, String body, boolean isFavourite) {
// this.id = id;
// this.title = title;
// this.body = body;
// this.isFavourite = isFavourite;
// }
//
// public int getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getBody() {
// return body;
// }
//
// public boolean isFavourite() {
// return isFavourite;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/OnArticleClickListener.java
// public interface OnArticleClickListener {
// void onArticleClick(int id);
// }
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/favorite_list/FavoriteListContract.java
import java.util.List;
import org.kaerdan.mvp_navigation.core.data.Article;
import org.kaerdan.mvp_navigation.core.ui.OnArticleClickListener;
import android.support.annotation.NonNull;
package org.kaerdan.mvp_navigation.core.ui.favorite_list;
public interface FavoriteListContract {
interface Presenter extends org.kaerdan.mvp_navigation.core.Presenter<View> {
void setNavigator(@NonNull Navigator navigator);
}
interface View extends org.kaerdan.mvp_navigation.core.Presenter.View { | void displayArticles(@NonNull List<Article> articles, @NonNull OnArticleClickListener onArticleClickListener); |
NikitaKozlov/MVP-Navigation | app/src/main/java/org/kaerdan/mvp_navigation/example2_fragments/FragmentsFavoriteListActivity.java | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/favorite_list/FavoriteListContract.java
// public interface FavoriteListContract {
// interface Presenter extends org.kaerdan.mvp_navigation.core.Presenter<View> {
// void setNavigator(@NonNull Navigator navigator);
// }
//
// interface View extends org.kaerdan.mvp_navigation.core.Presenter.View {
// void displayArticles(@NonNull List<Article> articles, @NonNull OnArticleClickListener onArticleClickListener);
// }
//
// interface Navigator {
// void openArticle(int id);
// }
//
// interface NavigatorProvider {
//
// @NonNull
// Navigator getNavigator(FavoriteListContract.Presenter presenter);
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/favorite_list/FavoriteListFragment.java
// public class FavoriteListFragment extends Fragment implements FavoriteListContract.View {
//
// private FavoriteListContract.Presenter mPresenter;
//
// private RecyclerView mRecyclerView;
//
// public FavoriteListFragment() {
// // Required empty public constructor
// }
//
// @Override
// public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
// final Bundle savedInstanceState) {
// mPresenter = createPresenter();
//
// // Inflate the layout for this fragment
// mRecyclerView = (RecyclerView) inflater.inflate(R.layout.fragment_favorite_article_list, container, false);
// mRecyclerView.setLayoutManager(new LinearLayoutManager(container.getContext(), LinearLayoutManager.VERTICAL,
// false));
// return mRecyclerView;
// }
//
// @NonNull
// protected FavoriteListContract.Presenter createPresenter() {
// FavoriteListContract.Presenter presenter = new FavoriteListPresenter();
// presenter.setNavigator(getNavigator(presenter));
// return presenter;
// }
//
// @NonNull
// protected FavoriteListContract.Navigator getNavigator(final FavoriteListContract.Presenter presenter) {
// Fragment parentFragment = getParentFragment();
// if (parentFragment != null && parentFragment instanceof FavoriteListContract.NavigatorProvider) {
// return ((FavoriteListContract.NavigatorProvider) parentFragment).getNavigator(presenter);
// } else {
// Activity activity = getActivity();
// if (activity instanceof FavoriteListContract.NavigatorProvider) {
// return ((FavoriteListContract.NavigatorProvider) activity).getNavigator(presenter);
// }
// }
//
// throw new IllegalStateException("Activity or parent Fragment must implement "
// + "FavoriteListContract.NavigatorProvider");
// }
//
// @Override
// public void onStart() {
// super.onStart();
// mPresenter.onAttachView(this);
// }
//
// @Override
// public void onStop() {
// super.onStop();
// mPresenter.onDetachView();
// }
//
// @Override
// public void displayArticles(@NonNull final List<Article> articles,
// @NonNull final OnArticleClickListener onArticleClickListener) {
// mRecyclerView.setAdapter(new ArticleListAdapter(articles, onArticleClickListener));
// }
// }
| import org.kaerdan.mvp_navigation.R;
import org.kaerdan.mvp_navigation.core.ui.favorite_list.FavoriteListContract;
import org.kaerdan.mvp_navigation.core.ui.favorite_list.FavoriteListFragment;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.view.MenuItem; | package org.kaerdan.mvp_navigation.example2_fragments;
public class FragmentsFavoriteListActivity extends AppCompatActivity implements FavoriteListContract.NavigatorProvider {
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_single);
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction() | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/favorite_list/FavoriteListContract.java
// public interface FavoriteListContract {
// interface Presenter extends org.kaerdan.mvp_navigation.core.Presenter<View> {
// void setNavigator(@NonNull Navigator navigator);
// }
//
// interface View extends org.kaerdan.mvp_navigation.core.Presenter.View {
// void displayArticles(@NonNull List<Article> articles, @NonNull OnArticleClickListener onArticleClickListener);
// }
//
// interface Navigator {
// void openArticle(int id);
// }
//
// interface NavigatorProvider {
//
// @NonNull
// Navigator getNavigator(FavoriteListContract.Presenter presenter);
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/favorite_list/FavoriteListFragment.java
// public class FavoriteListFragment extends Fragment implements FavoriteListContract.View {
//
// private FavoriteListContract.Presenter mPresenter;
//
// private RecyclerView mRecyclerView;
//
// public FavoriteListFragment() {
// // Required empty public constructor
// }
//
// @Override
// public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
// final Bundle savedInstanceState) {
// mPresenter = createPresenter();
//
// // Inflate the layout for this fragment
// mRecyclerView = (RecyclerView) inflater.inflate(R.layout.fragment_favorite_article_list, container, false);
// mRecyclerView.setLayoutManager(new LinearLayoutManager(container.getContext(), LinearLayoutManager.VERTICAL,
// false));
// return mRecyclerView;
// }
//
// @NonNull
// protected FavoriteListContract.Presenter createPresenter() {
// FavoriteListContract.Presenter presenter = new FavoriteListPresenter();
// presenter.setNavigator(getNavigator(presenter));
// return presenter;
// }
//
// @NonNull
// protected FavoriteListContract.Navigator getNavigator(final FavoriteListContract.Presenter presenter) {
// Fragment parentFragment = getParentFragment();
// if (parentFragment != null && parentFragment instanceof FavoriteListContract.NavigatorProvider) {
// return ((FavoriteListContract.NavigatorProvider) parentFragment).getNavigator(presenter);
// } else {
// Activity activity = getActivity();
// if (activity instanceof FavoriteListContract.NavigatorProvider) {
// return ((FavoriteListContract.NavigatorProvider) activity).getNavigator(presenter);
// }
// }
//
// throw new IllegalStateException("Activity or parent Fragment must implement "
// + "FavoriteListContract.NavigatorProvider");
// }
//
// @Override
// public void onStart() {
// super.onStart();
// mPresenter.onAttachView(this);
// }
//
// @Override
// public void onStop() {
// super.onStop();
// mPresenter.onDetachView();
// }
//
// @Override
// public void displayArticles(@NonNull final List<Article> articles,
// @NonNull final OnArticleClickListener onArticleClickListener) {
// mRecyclerView.setAdapter(new ArticleListAdapter(articles, onArticleClickListener));
// }
// }
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example2_fragments/FragmentsFavoriteListActivity.java
import org.kaerdan.mvp_navigation.R;
import org.kaerdan.mvp_navigation.core.ui.favorite_list.FavoriteListContract;
import org.kaerdan.mvp_navigation.core.ui.favorite_list.FavoriteListFragment;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.view.MenuItem;
package org.kaerdan.mvp_navigation.example2_fragments;
public class FragmentsFavoriteListActivity extends AppCompatActivity implements FavoriteListContract.NavigatorProvider {
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_single);
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction() | .add(R.id.main_content, new FavoriteListFragment(), null) |
NikitaKozlov/MVP-Navigation | app/src/main/java/org/kaerdan/mvp_navigation/example2_fragments/FragmentsArticleListNavigator.java | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/article/ArticleFragment.java
// public class ArticleFragment extends Fragment implements ArticleContract.View {
//
// private static final String ARTICLE_ID_TAG = "Article id";
//
// public static ArticleFragment newInstance(final int id) {
// Bundle args = new Bundle();
// args.putInt(ARTICLE_ID_TAG, id);
//
// ArticleFragment fragment = new ArticleFragment();
// fragment.setArguments(args);
// return fragment;
// }
//
// private ArticleContract.Presenter mPresenter;
// private TextView mArticleTextView;
//
// public ArticleFragment() {
// // Required empty public constructor
// }
//
// @Override
// public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
// final Bundle savedInstanceState) {
//
// // Inflate the layout for this fragment
// mPresenter = new ArticlePresenter(getArguments().getInt(ARTICLE_ID_TAG));
//
// View v = inflater.inflate(R.layout.fragment_article, container, false);
// mArticleTextView = (TextView) v.findViewById(R.id.article_body);
// return v;
// }
//
// @Override
// public void onStart() {
// super.onStart();
// mPresenter.onAttachView(this);
// }
//
// @Override
// public void onStop() {
// super.onStop();
// mPresenter.onDetachView();
// }
//
// @Override
// public void displayArticle(@NonNull final Article article) {
// mArticleTextView.setText(article.getBody());
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/article_list/ArticleListContract.java
// public interface ArticleListContract {
// interface Presenter extends org.kaerdan.mvp_navigation.core.Presenter<View> {
// void setNavigator(@NonNull Navigator navigator);
//
// void onFavoriteArticleClick();
// }
//
// interface View extends org.kaerdan.mvp_navigation.core.Presenter.View {
// void displayArticles(@NonNull List<Article> articles, @NonNull OnArticleClickListener onArticleClickListener);
// }
//
// interface Navigator {
// void openArticle(int id);
//
// void openFavoriteArticles();
// }
//
// interface NavigatorProvider {
//
// @NonNull
// Navigator getNavigator(ArticleListContract.Presenter presenter);
// }
// }
| import org.kaerdan.mvp_navigation.R;
import org.kaerdan.mvp_navigation.core.ui.article.ArticleFragment;
import org.kaerdan.mvp_navigation.core.ui.article_list.ArticleListContract;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity; | package org.kaerdan.mvp_navigation.example2_fragments;
public class FragmentsArticleListNavigator implements ArticleListContract.Navigator {
private final AppCompatActivity mActivity;
public FragmentsArticleListNavigator(final AppCompatActivity activity) {
this.mActivity = activity;
}
@Override
public void openArticle(final int id) {
mActivity.getSupportFragmentManager()
.beginTransaction() | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/article/ArticleFragment.java
// public class ArticleFragment extends Fragment implements ArticleContract.View {
//
// private static final String ARTICLE_ID_TAG = "Article id";
//
// public static ArticleFragment newInstance(final int id) {
// Bundle args = new Bundle();
// args.putInt(ARTICLE_ID_TAG, id);
//
// ArticleFragment fragment = new ArticleFragment();
// fragment.setArguments(args);
// return fragment;
// }
//
// private ArticleContract.Presenter mPresenter;
// private TextView mArticleTextView;
//
// public ArticleFragment() {
// // Required empty public constructor
// }
//
// @Override
// public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
// final Bundle savedInstanceState) {
//
// // Inflate the layout for this fragment
// mPresenter = new ArticlePresenter(getArguments().getInt(ARTICLE_ID_TAG));
//
// View v = inflater.inflate(R.layout.fragment_article, container, false);
// mArticleTextView = (TextView) v.findViewById(R.id.article_body);
// return v;
// }
//
// @Override
// public void onStart() {
// super.onStart();
// mPresenter.onAttachView(this);
// }
//
// @Override
// public void onStop() {
// super.onStop();
// mPresenter.onDetachView();
// }
//
// @Override
// public void displayArticle(@NonNull final Article article) {
// mArticleTextView.setText(article.getBody());
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/article_list/ArticleListContract.java
// public interface ArticleListContract {
// interface Presenter extends org.kaerdan.mvp_navigation.core.Presenter<View> {
// void setNavigator(@NonNull Navigator navigator);
//
// void onFavoriteArticleClick();
// }
//
// interface View extends org.kaerdan.mvp_navigation.core.Presenter.View {
// void displayArticles(@NonNull List<Article> articles, @NonNull OnArticleClickListener onArticleClickListener);
// }
//
// interface Navigator {
// void openArticle(int id);
//
// void openFavoriteArticles();
// }
//
// interface NavigatorProvider {
//
// @NonNull
// Navigator getNavigator(ArticleListContract.Presenter presenter);
// }
// }
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example2_fragments/FragmentsArticleListNavigator.java
import org.kaerdan.mvp_navigation.R;
import org.kaerdan.mvp_navigation.core.ui.article.ArticleFragment;
import org.kaerdan.mvp_navigation.core.ui.article_list.ArticleListContract;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
package org.kaerdan.mvp_navigation.example2_fragments;
public class FragmentsArticleListNavigator implements ArticleListContract.Navigator {
private final AppCompatActivity mActivity;
public FragmentsArticleListNavigator(final AppCompatActivity activity) {
this.mActivity = activity;
}
@Override
public void openArticle(final int id) {
mActivity.getSupportFragmentManager()
.beginTransaction() | .replace(R.id.secondary_content, ArticleFragment.newInstance(id), null) |
NikitaKozlov/MVP-Navigation | app/src/main/java/org/kaerdan/mvp_navigation/core/ui/article_list/ArticleListContract.java | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/Article.java
// public class Article {
// private final int id;
// private final String title;
// private final String body;
// private final boolean isFavourite;
//
// public Article(int id, String title, String body, boolean isFavourite) {
// this.id = id;
// this.title = title;
// this.body = body;
// this.isFavourite = isFavourite;
// }
//
// public int getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getBody() {
// return body;
// }
//
// public boolean isFavourite() {
// return isFavourite;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/OnArticleClickListener.java
// public interface OnArticleClickListener {
// void onArticleClick(int id);
// }
| import java.util.List;
import org.kaerdan.mvp_navigation.core.data.Article;
import org.kaerdan.mvp_navigation.core.ui.OnArticleClickListener;
import android.support.annotation.NonNull; | package org.kaerdan.mvp_navigation.core.ui.article_list;
public interface ArticleListContract {
interface Presenter extends org.kaerdan.mvp_navigation.core.Presenter<View> {
void setNavigator(@NonNull Navigator navigator);
void onFavoriteArticleClick();
}
interface View extends org.kaerdan.mvp_navigation.core.Presenter.View { | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/Article.java
// public class Article {
// private final int id;
// private final String title;
// private final String body;
// private final boolean isFavourite;
//
// public Article(int id, String title, String body, boolean isFavourite) {
// this.id = id;
// this.title = title;
// this.body = body;
// this.isFavourite = isFavourite;
// }
//
// public int getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getBody() {
// return body;
// }
//
// public boolean isFavourite() {
// return isFavourite;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/OnArticleClickListener.java
// public interface OnArticleClickListener {
// void onArticleClick(int id);
// }
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/article_list/ArticleListContract.java
import java.util.List;
import org.kaerdan.mvp_navigation.core.data.Article;
import org.kaerdan.mvp_navigation.core.ui.OnArticleClickListener;
import android.support.annotation.NonNull;
package org.kaerdan.mvp_navigation.core.ui.article_list;
public interface ArticleListContract {
interface Presenter extends org.kaerdan.mvp_navigation.core.Presenter<View> {
void setNavigator(@NonNull Navigator navigator);
void onFavoriteArticleClick();
}
interface View extends org.kaerdan.mvp_navigation.core.Presenter.View { | void displayArticles(@NonNull List<Article> articles, @NonNull OnArticleClickListener onArticleClickListener); |
NikitaKozlov/MVP-Navigation | app/src/main/java/org/kaerdan/mvp_navigation/core/ui/article_list/ArticleListContract.java | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/Article.java
// public class Article {
// private final int id;
// private final String title;
// private final String body;
// private final boolean isFavourite;
//
// public Article(int id, String title, String body, boolean isFavourite) {
// this.id = id;
// this.title = title;
// this.body = body;
// this.isFavourite = isFavourite;
// }
//
// public int getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getBody() {
// return body;
// }
//
// public boolean isFavourite() {
// return isFavourite;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/OnArticleClickListener.java
// public interface OnArticleClickListener {
// void onArticleClick(int id);
// }
| import java.util.List;
import org.kaerdan.mvp_navigation.core.data.Article;
import org.kaerdan.mvp_navigation.core.ui.OnArticleClickListener;
import android.support.annotation.NonNull; | package org.kaerdan.mvp_navigation.core.ui.article_list;
public interface ArticleListContract {
interface Presenter extends org.kaerdan.mvp_navigation.core.Presenter<View> {
void setNavigator(@NonNull Navigator navigator);
void onFavoriteArticleClick();
}
interface View extends org.kaerdan.mvp_navigation.core.Presenter.View { | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/Article.java
// public class Article {
// private final int id;
// private final String title;
// private final String body;
// private final boolean isFavourite;
//
// public Article(int id, String title, String body, boolean isFavourite) {
// this.id = id;
// this.title = title;
// this.body = body;
// this.isFavourite = isFavourite;
// }
//
// public int getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getBody() {
// return body;
// }
//
// public boolean isFavourite() {
// return isFavourite;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/OnArticleClickListener.java
// public interface OnArticleClickListener {
// void onArticleClick(int id);
// }
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/article_list/ArticleListContract.java
import java.util.List;
import org.kaerdan.mvp_navigation.core.data.Article;
import org.kaerdan.mvp_navigation.core.ui.OnArticleClickListener;
import android.support.annotation.NonNull;
package org.kaerdan.mvp_navigation.core.ui.article_list;
public interface ArticleListContract {
interface Presenter extends org.kaerdan.mvp_navigation.core.Presenter<View> {
void setNavigator(@NonNull Navigator navigator);
void onFavoriteArticleClick();
}
interface View extends org.kaerdan.mvp_navigation.core.Presenter.View { | void displayArticles(@NonNull List<Article> articles, @NonNull OnArticleClickListener onArticleClickListener); |
NikitaKozlov/MVP-Navigation | app/src/main/java/org/kaerdan/mvp_navigation/core/ui/article_list/ArticleListPresenter.java | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/DataProvider.java
// public class DataProvider {
//
// private static final Article ARTICLE_1 = new Article(1, "Article 1", "Article 1 body", false);
// private static final Article ARTICLE_2 = new Article(2, "Article 2", "Article 2 body", true);
// private static final Article ARTICLE_3 = new Article(3, "Article 3", "Article 3 body", false);
// private static final Article ARTICLE_4 = new Article(4, "Article 4", "Article 4 body", true);
// private static final Article ARTICLE_5 = new Article(5, "Article 5", "Article 5 body", false);
// private static final Article ARTICLE_6 = new Article(6, "Article 6", "Article 6 body", true);
// private static final Article ARTICLE_7 = new Article(7, "Article 7", "Article 7 body", false);
// private static final Article ARTICLE_8 = new Article(8, "Article 8", "Article 8 body", true);
// private static final Article ARTICLE_9 = new Article(9, "Article 9", "Article 9 body", false);
// private static final Article ARTICLE_10 = new Article(10, "Article 10", "Article 10 body", true);
//
// private static DataProvider sInstance = new DataProvider();
//
// public static DataProvider getInstance() {
// return sInstance;
// }
//
// private final List<Article> mArticles;
//
// private DataProvider() {
// mArticles = Arrays.asList(ARTICLE_1, ARTICLE_2, ARTICLE_3, ARTICLE_4, ARTICLE_5, ARTICLE_6, ARTICLE_7,
// ARTICLE_8, ARTICLE_9, ARTICLE_10);
// }
//
// public List<Article> getmArticles() {
// return mArticles;
// }
//
// public List<Article> getFavouriteArticles() {
// List<Article> favouriteArticles = new ArrayList<>();
// for (Article article : mArticles) {
// if (article.isFavourite()) {
// favouriteArticles.add(article);
// }
// }
//
// return favouriteArticles;
// }
//
// @Nullable
// public Article getArticleById(final int id) {
// for (Article article : mArticles) {
// if (id == article.getId()) {
// return article;
// }
// }
//
// return null;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/OnArticleClickListener.java
// public interface OnArticleClickListener {
// void onArticleClick(int id);
// }
| import org.kaerdan.mvp_navigation.core.data.DataProvider;
import org.kaerdan.mvp_navigation.core.ui.OnArticleClickListener;
import android.support.annotation.NonNull; | package org.kaerdan.mvp_navigation.core.ui.article_list;
public class ArticleListPresenter implements ArticleListContract.Presenter, OnArticleClickListener {
private ArticleListContract.View view;
private ArticleListContract.Navigator navigator;
@Override
public void onAttachView(final ArticleListContract.View view) {
this.view = view;
// Usually this call goes asynchronous, but for this example it doesn't matter | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/DataProvider.java
// public class DataProvider {
//
// private static final Article ARTICLE_1 = new Article(1, "Article 1", "Article 1 body", false);
// private static final Article ARTICLE_2 = new Article(2, "Article 2", "Article 2 body", true);
// private static final Article ARTICLE_3 = new Article(3, "Article 3", "Article 3 body", false);
// private static final Article ARTICLE_4 = new Article(4, "Article 4", "Article 4 body", true);
// private static final Article ARTICLE_5 = new Article(5, "Article 5", "Article 5 body", false);
// private static final Article ARTICLE_6 = new Article(6, "Article 6", "Article 6 body", true);
// private static final Article ARTICLE_7 = new Article(7, "Article 7", "Article 7 body", false);
// private static final Article ARTICLE_8 = new Article(8, "Article 8", "Article 8 body", true);
// private static final Article ARTICLE_9 = new Article(9, "Article 9", "Article 9 body", false);
// private static final Article ARTICLE_10 = new Article(10, "Article 10", "Article 10 body", true);
//
// private static DataProvider sInstance = new DataProvider();
//
// public static DataProvider getInstance() {
// return sInstance;
// }
//
// private final List<Article> mArticles;
//
// private DataProvider() {
// mArticles = Arrays.asList(ARTICLE_1, ARTICLE_2, ARTICLE_3, ARTICLE_4, ARTICLE_5, ARTICLE_6, ARTICLE_7,
// ARTICLE_8, ARTICLE_9, ARTICLE_10);
// }
//
// public List<Article> getmArticles() {
// return mArticles;
// }
//
// public List<Article> getFavouriteArticles() {
// List<Article> favouriteArticles = new ArrayList<>();
// for (Article article : mArticles) {
// if (article.isFavourite()) {
// favouriteArticles.add(article);
// }
// }
//
// return favouriteArticles;
// }
//
// @Nullable
// public Article getArticleById(final int id) {
// for (Article article : mArticles) {
// if (id == article.getId()) {
// return article;
// }
// }
//
// return null;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/OnArticleClickListener.java
// public interface OnArticleClickListener {
// void onArticleClick(int id);
// }
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/article_list/ArticleListPresenter.java
import org.kaerdan.mvp_navigation.core.data.DataProvider;
import org.kaerdan.mvp_navigation.core.ui.OnArticleClickListener;
import android.support.annotation.NonNull;
package org.kaerdan.mvp_navigation.core.ui.article_list;
public class ArticleListPresenter implements ArticleListContract.Presenter, OnArticleClickListener {
private ArticleListContract.View view;
private ArticleListContract.Navigator navigator;
@Override
public void onAttachView(final ArticleListContract.View view) {
this.view = view;
// Usually this call goes asynchronous, but for this example it doesn't matter | view.displayArticles(DataProvider.getInstance().getmArticles(), this); |
NikitaKozlov/MVP-Navigation | app/src/main/java/org/kaerdan/mvp_navigation/example5_retainpresenter/RetainPresenterArticleListFragment.java | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/Article.java
// public class Article {
// private final int id;
// private final String title;
// private final String body;
// private final boolean isFavourite;
//
// public Article(int id, String title, String body, boolean isFavourite) {
// this.id = id;
// this.title = title;
// this.body = body;
// this.isFavourite = isFavourite;
// }
//
// public int getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getBody() {
// return body;
// }
//
// public boolean isFavourite() {
// return isFavourite;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/ArticleListAdapter.java
// public class ArticleListAdapter extends RecyclerView.Adapter<ArticleListAdapter.ArticleViewHolder> {
//
// private final List<Article> mArticles;
// private final OnArticleClickListener mOnArticleClickListener;
//
// public ArticleListAdapter(@NonNull final List<Article> articles,
// @NonNull final OnArticleClickListener onArticleClickListener) {
// this.mArticles = articles;
// this.mOnArticleClickListener = onArticleClickListener;
// }
//
// @Override
// public ArticleViewHolder onCreateViewHolder(final ViewGroup parent, final int viewType) {
// return new ArticleViewHolder(new Button(parent.getContext()));
// }
//
// @Override
// public void onBindViewHolder(final ArticleViewHolder holder, final int position) {
// final Article article = mArticles.get(position);
// ((Button) holder.itemView).setText(article.getTitle());
// holder.itemView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(final View v) {
// mOnArticleClickListener.onArticleClick(article.getId());
// }
// });
// }
//
// @Override
// public int getItemCount() {
// return mArticles.size();
// }
//
// static class ArticleViewHolder extends RecyclerView.ViewHolder {
// public ArticleViewHolder(final View itemView) {
// super(itemView);
// }
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/OnArticleClickListener.java
// public interface OnArticleClickListener {
// void onArticleClick(int id);
// }
| import java.util.List;
import org.kaerdan.mvp_navigation.R;
import org.kaerdan.mvp_navigation.core.data.Article;
import org.kaerdan.mvp_navigation.core.ui.ArticleListAdapter;
import org.kaerdan.mvp_navigation.core.ui.OnArticleClickListener;
import org.kaerdan.presenterretainer.PresenterFragment;
import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup; | @Override
protected RetainPresenterArticleListContract.Presenter onCreatePresenter() {
RetainPresenterArticleListContract.Presenter presenter = new RetainPresenterArticleListPresenter();
presenter.setNavigator(getNavigator(presenter));
return presenter;
}
@Override
protected RetainPresenterArticleListContract.View getPresenterView() {
return this;
}
@NonNull
protected RetainPresenterArticleListContract.Navigator getNavigator(
final RetainPresenterArticleListContract.Presenter presenter) {
Fragment parentFragment = getParentFragment();
if (parentFragment != null && parentFragment instanceof RetainPresenterArticleListContract.NavigatorProvider) {
return ((RetainPresenterArticleListContract.NavigatorProvider) parentFragment).getNavigator(presenter);
} else {
Activity activity = getActivity();
if (activity instanceof RetainPresenterArticleListContract.NavigatorProvider) {
return ((RetainPresenterArticleListContract.NavigatorProvider) activity).getNavigator(presenter);
}
}
throw new IllegalStateException("Activity or parent Fragment must implement "
+ "ArticleListNavigationContract.NavigatorProvider");
}
@Override | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/Article.java
// public class Article {
// private final int id;
// private final String title;
// private final String body;
// private final boolean isFavourite;
//
// public Article(int id, String title, String body, boolean isFavourite) {
// this.id = id;
// this.title = title;
// this.body = body;
// this.isFavourite = isFavourite;
// }
//
// public int getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getBody() {
// return body;
// }
//
// public boolean isFavourite() {
// return isFavourite;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/ArticleListAdapter.java
// public class ArticleListAdapter extends RecyclerView.Adapter<ArticleListAdapter.ArticleViewHolder> {
//
// private final List<Article> mArticles;
// private final OnArticleClickListener mOnArticleClickListener;
//
// public ArticleListAdapter(@NonNull final List<Article> articles,
// @NonNull final OnArticleClickListener onArticleClickListener) {
// this.mArticles = articles;
// this.mOnArticleClickListener = onArticleClickListener;
// }
//
// @Override
// public ArticleViewHolder onCreateViewHolder(final ViewGroup parent, final int viewType) {
// return new ArticleViewHolder(new Button(parent.getContext()));
// }
//
// @Override
// public void onBindViewHolder(final ArticleViewHolder holder, final int position) {
// final Article article = mArticles.get(position);
// ((Button) holder.itemView).setText(article.getTitle());
// holder.itemView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(final View v) {
// mOnArticleClickListener.onArticleClick(article.getId());
// }
// });
// }
//
// @Override
// public int getItemCount() {
// return mArticles.size();
// }
//
// static class ArticleViewHolder extends RecyclerView.ViewHolder {
// public ArticleViewHolder(final View itemView) {
// super(itemView);
// }
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/OnArticleClickListener.java
// public interface OnArticleClickListener {
// void onArticleClick(int id);
// }
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example5_retainpresenter/RetainPresenterArticleListFragment.java
import java.util.List;
import org.kaerdan.mvp_navigation.R;
import org.kaerdan.mvp_navigation.core.data.Article;
import org.kaerdan.mvp_navigation.core.ui.ArticleListAdapter;
import org.kaerdan.mvp_navigation.core.ui.OnArticleClickListener;
import org.kaerdan.presenterretainer.PresenterFragment;
import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@Override
protected RetainPresenterArticleListContract.Presenter onCreatePresenter() {
RetainPresenterArticleListContract.Presenter presenter = new RetainPresenterArticleListPresenter();
presenter.setNavigator(getNavigator(presenter));
return presenter;
}
@Override
protected RetainPresenterArticleListContract.View getPresenterView() {
return this;
}
@NonNull
protected RetainPresenterArticleListContract.Navigator getNavigator(
final RetainPresenterArticleListContract.Presenter presenter) {
Fragment parentFragment = getParentFragment();
if (parentFragment != null && parentFragment instanceof RetainPresenterArticleListContract.NavigatorProvider) {
return ((RetainPresenterArticleListContract.NavigatorProvider) parentFragment).getNavigator(presenter);
} else {
Activity activity = getActivity();
if (activity instanceof RetainPresenterArticleListContract.NavigatorProvider) {
return ((RetainPresenterArticleListContract.NavigatorProvider) activity).getNavigator(presenter);
}
}
throw new IllegalStateException("Activity or parent Fragment must implement "
+ "ArticleListNavigationContract.NavigatorProvider");
}
@Override | public void displayArticles(@NonNull final List<Article> articles, |
NikitaKozlov/MVP-Navigation | app/src/main/java/org/kaerdan/mvp_navigation/example5_retainpresenter/RetainPresenterArticleListFragment.java | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/Article.java
// public class Article {
// private final int id;
// private final String title;
// private final String body;
// private final boolean isFavourite;
//
// public Article(int id, String title, String body, boolean isFavourite) {
// this.id = id;
// this.title = title;
// this.body = body;
// this.isFavourite = isFavourite;
// }
//
// public int getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getBody() {
// return body;
// }
//
// public boolean isFavourite() {
// return isFavourite;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/ArticleListAdapter.java
// public class ArticleListAdapter extends RecyclerView.Adapter<ArticleListAdapter.ArticleViewHolder> {
//
// private final List<Article> mArticles;
// private final OnArticleClickListener mOnArticleClickListener;
//
// public ArticleListAdapter(@NonNull final List<Article> articles,
// @NonNull final OnArticleClickListener onArticleClickListener) {
// this.mArticles = articles;
// this.mOnArticleClickListener = onArticleClickListener;
// }
//
// @Override
// public ArticleViewHolder onCreateViewHolder(final ViewGroup parent, final int viewType) {
// return new ArticleViewHolder(new Button(parent.getContext()));
// }
//
// @Override
// public void onBindViewHolder(final ArticleViewHolder holder, final int position) {
// final Article article = mArticles.get(position);
// ((Button) holder.itemView).setText(article.getTitle());
// holder.itemView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(final View v) {
// mOnArticleClickListener.onArticleClick(article.getId());
// }
// });
// }
//
// @Override
// public int getItemCount() {
// return mArticles.size();
// }
//
// static class ArticleViewHolder extends RecyclerView.ViewHolder {
// public ArticleViewHolder(final View itemView) {
// super(itemView);
// }
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/OnArticleClickListener.java
// public interface OnArticleClickListener {
// void onArticleClick(int id);
// }
| import java.util.List;
import org.kaerdan.mvp_navigation.R;
import org.kaerdan.mvp_navigation.core.data.Article;
import org.kaerdan.mvp_navigation.core.ui.ArticleListAdapter;
import org.kaerdan.mvp_navigation.core.ui.OnArticleClickListener;
import org.kaerdan.presenterretainer.PresenterFragment;
import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup; | protected RetainPresenterArticleListContract.Presenter onCreatePresenter() {
RetainPresenterArticleListContract.Presenter presenter = new RetainPresenterArticleListPresenter();
presenter.setNavigator(getNavigator(presenter));
return presenter;
}
@Override
protected RetainPresenterArticleListContract.View getPresenterView() {
return this;
}
@NonNull
protected RetainPresenterArticleListContract.Navigator getNavigator(
final RetainPresenterArticleListContract.Presenter presenter) {
Fragment parentFragment = getParentFragment();
if (parentFragment != null && parentFragment instanceof RetainPresenterArticleListContract.NavigatorProvider) {
return ((RetainPresenterArticleListContract.NavigatorProvider) parentFragment).getNavigator(presenter);
} else {
Activity activity = getActivity();
if (activity instanceof RetainPresenterArticleListContract.NavigatorProvider) {
return ((RetainPresenterArticleListContract.NavigatorProvider) activity).getNavigator(presenter);
}
}
throw new IllegalStateException("Activity or parent Fragment must implement "
+ "ArticleListNavigationContract.NavigatorProvider");
}
@Override
public void displayArticles(@NonNull final List<Article> articles, | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/Article.java
// public class Article {
// private final int id;
// private final String title;
// private final String body;
// private final boolean isFavourite;
//
// public Article(int id, String title, String body, boolean isFavourite) {
// this.id = id;
// this.title = title;
// this.body = body;
// this.isFavourite = isFavourite;
// }
//
// public int getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getBody() {
// return body;
// }
//
// public boolean isFavourite() {
// return isFavourite;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/ArticleListAdapter.java
// public class ArticleListAdapter extends RecyclerView.Adapter<ArticleListAdapter.ArticleViewHolder> {
//
// private final List<Article> mArticles;
// private final OnArticleClickListener mOnArticleClickListener;
//
// public ArticleListAdapter(@NonNull final List<Article> articles,
// @NonNull final OnArticleClickListener onArticleClickListener) {
// this.mArticles = articles;
// this.mOnArticleClickListener = onArticleClickListener;
// }
//
// @Override
// public ArticleViewHolder onCreateViewHolder(final ViewGroup parent, final int viewType) {
// return new ArticleViewHolder(new Button(parent.getContext()));
// }
//
// @Override
// public void onBindViewHolder(final ArticleViewHolder holder, final int position) {
// final Article article = mArticles.get(position);
// ((Button) holder.itemView).setText(article.getTitle());
// holder.itemView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(final View v) {
// mOnArticleClickListener.onArticleClick(article.getId());
// }
// });
// }
//
// @Override
// public int getItemCount() {
// return mArticles.size();
// }
//
// static class ArticleViewHolder extends RecyclerView.ViewHolder {
// public ArticleViewHolder(final View itemView) {
// super(itemView);
// }
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/OnArticleClickListener.java
// public interface OnArticleClickListener {
// void onArticleClick(int id);
// }
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example5_retainpresenter/RetainPresenterArticleListFragment.java
import java.util.List;
import org.kaerdan.mvp_navigation.R;
import org.kaerdan.mvp_navigation.core.data.Article;
import org.kaerdan.mvp_navigation.core.ui.ArticleListAdapter;
import org.kaerdan.mvp_navigation.core.ui.OnArticleClickListener;
import org.kaerdan.presenterretainer.PresenterFragment;
import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
protected RetainPresenterArticleListContract.Presenter onCreatePresenter() {
RetainPresenterArticleListContract.Presenter presenter = new RetainPresenterArticleListPresenter();
presenter.setNavigator(getNavigator(presenter));
return presenter;
}
@Override
protected RetainPresenterArticleListContract.View getPresenterView() {
return this;
}
@NonNull
protected RetainPresenterArticleListContract.Navigator getNavigator(
final RetainPresenterArticleListContract.Presenter presenter) {
Fragment parentFragment = getParentFragment();
if (parentFragment != null && parentFragment instanceof RetainPresenterArticleListContract.NavigatorProvider) {
return ((RetainPresenterArticleListContract.NavigatorProvider) parentFragment).getNavigator(presenter);
} else {
Activity activity = getActivity();
if (activity instanceof RetainPresenterArticleListContract.NavigatorProvider) {
return ((RetainPresenterArticleListContract.NavigatorProvider) activity).getNavigator(presenter);
}
}
throw new IllegalStateException("Activity or parent Fragment must implement "
+ "ArticleListNavigationContract.NavigatorProvider");
}
@Override
public void displayArticles(@NonNull final List<Article> articles, | @NonNull final OnArticleClickListener onArticleClickListener) { |
NikitaKozlov/MVP-Navigation | app/src/main/java/org/kaerdan/mvp_navigation/example5_retainpresenter/RetainPresenterArticleListFragment.java | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/Article.java
// public class Article {
// private final int id;
// private final String title;
// private final String body;
// private final boolean isFavourite;
//
// public Article(int id, String title, String body, boolean isFavourite) {
// this.id = id;
// this.title = title;
// this.body = body;
// this.isFavourite = isFavourite;
// }
//
// public int getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getBody() {
// return body;
// }
//
// public boolean isFavourite() {
// return isFavourite;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/ArticleListAdapter.java
// public class ArticleListAdapter extends RecyclerView.Adapter<ArticleListAdapter.ArticleViewHolder> {
//
// private final List<Article> mArticles;
// private final OnArticleClickListener mOnArticleClickListener;
//
// public ArticleListAdapter(@NonNull final List<Article> articles,
// @NonNull final OnArticleClickListener onArticleClickListener) {
// this.mArticles = articles;
// this.mOnArticleClickListener = onArticleClickListener;
// }
//
// @Override
// public ArticleViewHolder onCreateViewHolder(final ViewGroup parent, final int viewType) {
// return new ArticleViewHolder(new Button(parent.getContext()));
// }
//
// @Override
// public void onBindViewHolder(final ArticleViewHolder holder, final int position) {
// final Article article = mArticles.get(position);
// ((Button) holder.itemView).setText(article.getTitle());
// holder.itemView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(final View v) {
// mOnArticleClickListener.onArticleClick(article.getId());
// }
// });
// }
//
// @Override
// public int getItemCount() {
// return mArticles.size();
// }
//
// static class ArticleViewHolder extends RecyclerView.ViewHolder {
// public ArticleViewHolder(final View itemView) {
// super(itemView);
// }
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/OnArticleClickListener.java
// public interface OnArticleClickListener {
// void onArticleClick(int id);
// }
| import java.util.List;
import org.kaerdan.mvp_navigation.R;
import org.kaerdan.mvp_navigation.core.data.Article;
import org.kaerdan.mvp_navigation.core.ui.ArticleListAdapter;
import org.kaerdan.mvp_navigation.core.ui.OnArticleClickListener;
import org.kaerdan.presenterretainer.PresenterFragment;
import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup; | RetainPresenterArticleListContract.Presenter presenter = new RetainPresenterArticleListPresenter();
presenter.setNavigator(getNavigator(presenter));
return presenter;
}
@Override
protected RetainPresenterArticleListContract.View getPresenterView() {
return this;
}
@NonNull
protected RetainPresenterArticleListContract.Navigator getNavigator(
final RetainPresenterArticleListContract.Presenter presenter) {
Fragment parentFragment = getParentFragment();
if (parentFragment != null && parentFragment instanceof RetainPresenterArticleListContract.NavigatorProvider) {
return ((RetainPresenterArticleListContract.NavigatorProvider) parentFragment).getNavigator(presenter);
} else {
Activity activity = getActivity();
if (activity instanceof RetainPresenterArticleListContract.NavigatorProvider) {
return ((RetainPresenterArticleListContract.NavigatorProvider) activity).getNavigator(presenter);
}
}
throw new IllegalStateException("Activity or parent Fragment must implement "
+ "ArticleListNavigationContract.NavigatorProvider");
}
@Override
public void displayArticles(@NonNull final List<Article> articles,
@NonNull final OnArticleClickListener onArticleClickListener) { | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/Article.java
// public class Article {
// private final int id;
// private final String title;
// private final String body;
// private final boolean isFavourite;
//
// public Article(int id, String title, String body, boolean isFavourite) {
// this.id = id;
// this.title = title;
// this.body = body;
// this.isFavourite = isFavourite;
// }
//
// public int getId() {
// return id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getBody() {
// return body;
// }
//
// public boolean isFavourite() {
// return isFavourite;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/ArticleListAdapter.java
// public class ArticleListAdapter extends RecyclerView.Adapter<ArticleListAdapter.ArticleViewHolder> {
//
// private final List<Article> mArticles;
// private final OnArticleClickListener mOnArticleClickListener;
//
// public ArticleListAdapter(@NonNull final List<Article> articles,
// @NonNull final OnArticleClickListener onArticleClickListener) {
// this.mArticles = articles;
// this.mOnArticleClickListener = onArticleClickListener;
// }
//
// @Override
// public ArticleViewHolder onCreateViewHolder(final ViewGroup parent, final int viewType) {
// return new ArticleViewHolder(new Button(parent.getContext()));
// }
//
// @Override
// public void onBindViewHolder(final ArticleViewHolder holder, final int position) {
// final Article article = mArticles.get(position);
// ((Button) holder.itemView).setText(article.getTitle());
// holder.itemView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(final View v) {
// mOnArticleClickListener.onArticleClick(article.getId());
// }
// });
// }
//
// @Override
// public int getItemCount() {
// return mArticles.size();
// }
//
// static class ArticleViewHolder extends RecyclerView.ViewHolder {
// public ArticleViewHolder(final View itemView) {
// super(itemView);
// }
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/OnArticleClickListener.java
// public interface OnArticleClickListener {
// void onArticleClick(int id);
// }
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example5_retainpresenter/RetainPresenterArticleListFragment.java
import java.util.List;
import org.kaerdan.mvp_navigation.R;
import org.kaerdan.mvp_navigation.core.data.Article;
import org.kaerdan.mvp_navigation.core.ui.ArticleListAdapter;
import org.kaerdan.mvp_navigation.core.ui.OnArticleClickListener;
import org.kaerdan.presenterretainer.PresenterFragment;
import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
RetainPresenterArticleListContract.Presenter presenter = new RetainPresenterArticleListPresenter();
presenter.setNavigator(getNavigator(presenter));
return presenter;
}
@Override
protected RetainPresenterArticleListContract.View getPresenterView() {
return this;
}
@NonNull
protected RetainPresenterArticleListContract.Navigator getNavigator(
final RetainPresenterArticleListContract.Presenter presenter) {
Fragment parentFragment = getParentFragment();
if (parentFragment != null && parentFragment instanceof RetainPresenterArticleListContract.NavigatorProvider) {
return ((RetainPresenterArticleListContract.NavigatorProvider) parentFragment).getNavigator(presenter);
} else {
Activity activity = getActivity();
if (activity instanceof RetainPresenterArticleListContract.NavigatorProvider) {
return ((RetainPresenterArticleListContract.NavigatorProvider) activity).getNavigator(presenter);
}
}
throw new IllegalStateException("Activity or parent Fragment must implement "
+ "ArticleListNavigationContract.NavigatorProvider");
}
@Override
public void displayArticles(@NonNull final List<Article> articles,
@NonNull final OnArticleClickListener onArticleClickListener) { | mRecyclerView.setAdapter(new ArticleListAdapter(articles, onArticleClickListener)); |
NikitaKozlov/MVP-Navigation | app/src/main/java/org/kaerdan/mvp_navigation/example4_injection/InjectArticleListPresenter.java | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/DataProvider.java
// public class DataProvider {
//
// private static final Article ARTICLE_1 = new Article(1, "Article 1", "Article 1 body", false);
// private static final Article ARTICLE_2 = new Article(2, "Article 2", "Article 2 body", true);
// private static final Article ARTICLE_3 = new Article(3, "Article 3", "Article 3 body", false);
// private static final Article ARTICLE_4 = new Article(4, "Article 4", "Article 4 body", true);
// private static final Article ARTICLE_5 = new Article(5, "Article 5", "Article 5 body", false);
// private static final Article ARTICLE_6 = new Article(6, "Article 6", "Article 6 body", true);
// private static final Article ARTICLE_7 = new Article(7, "Article 7", "Article 7 body", false);
// private static final Article ARTICLE_8 = new Article(8, "Article 8", "Article 8 body", true);
// private static final Article ARTICLE_9 = new Article(9, "Article 9", "Article 9 body", false);
// private static final Article ARTICLE_10 = new Article(10, "Article 10", "Article 10 body", true);
//
// private static DataProvider sInstance = new DataProvider();
//
// public static DataProvider getInstance() {
// return sInstance;
// }
//
// private final List<Article> mArticles;
//
// private DataProvider() {
// mArticles = Arrays.asList(ARTICLE_1, ARTICLE_2, ARTICLE_3, ARTICLE_4, ARTICLE_5, ARTICLE_6, ARTICLE_7,
// ARTICLE_8, ARTICLE_9, ARTICLE_10);
// }
//
// public List<Article> getmArticles() {
// return mArticles;
// }
//
// public List<Article> getFavouriteArticles() {
// List<Article> favouriteArticles = new ArrayList<>();
// for (Article article : mArticles) {
// if (article.isFavourite()) {
// favouriteArticles.add(article);
// }
// }
//
// return favouriteArticles;
// }
//
// @Nullable
// public Article getArticleById(final int id) {
// for (Article article : mArticles) {
// if (id == article.getId()) {
// return article;
// }
// }
//
// return null;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/OnArticleClickListener.java
// public interface OnArticleClickListener {
// void onArticleClick(int id);
// }
| import org.kaerdan.mvp_navigation.core.data.DataProvider;
import org.kaerdan.mvp_navigation.core.ui.OnArticleClickListener; | package org.kaerdan.mvp_navigation.example4_injection;
public class InjectArticleListPresenter implements InjectArticleListContract.Presenter, OnArticleClickListener {
private InjectArticleListContract.View mView;
// @Inject
InjectArticleListContract.Navigator mNavigator;
@Override
public void onAttachView(final InjectArticleListContract.View view) {
this.mView = view;
// Usually this call goes asynchronous, but for this example it doesn't matter | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/data/DataProvider.java
// public class DataProvider {
//
// private static final Article ARTICLE_1 = new Article(1, "Article 1", "Article 1 body", false);
// private static final Article ARTICLE_2 = new Article(2, "Article 2", "Article 2 body", true);
// private static final Article ARTICLE_3 = new Article(3, "Article 3", "Article 3 body", false);
// private static final Article ARTICLE_4 = new Article(4, "Article 4", "Article 4 body", true);
// private static final Article ARTICLE_5 = new Article(5, "Article 5", "Article 5 body", false);
// private static final Article ARTICLE_6 = new Article(6, "Article 6", "Article 6 body", true);
// private static final Article ARTICLE_7 = new Article(7, "Article 7", "Article 7 body", false);
// private static final Article ARTICLE_8 = new Article(8, "Article 8", "Article 8 body", true);
// private static final Article ARTICLE_9 = new Article(9, "Article 9", "Article 9 body", false);
// private static final Article ARTICLE_10 = new Article(10, "Article 10", "Article 10 body", true);
//
// private static DataProvider sInstance = new DataProvider();
//
// public static DataProvider getInstance() {
// return sInstance;
// }
//
// private final List<Article> mArticles;
//
// private DataProvider() {
// mArticles = Arrays.asList(ARTICLE_1, ARTICLE_2, ARTICLE_3, ARTICLE_4, ARTICLE_5, ARTICLE_6, ARTICLE_7,
// ARTICLE_8, ARTICLE_9, ARTICLE_10);
// }
//
// public List<Article> getmArticles() {
// return mArticles;
// }
//
// public List<Article> getFavouriteArticles() {
// List<Article> favouriteArticles = new ArrayList<>();
// for (Article article : mArticles) {
// if (article.isFavourite()) {
// favouriteArticles.add(article);
// }
// }
//
// return favouriteArticles;
// }
//
// @Nullable
// public Article getArticleById(final int id) {
// for (Article article : mArticles) {
// if (id == article.getId()) {
// return article;
// }
// }
//
// return null;
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/OnArticleClickListener.java
// public interface OnArticleClickListener {
// void onArticleClick(int id);
// }
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example4_injection/InjectArticleListPresenter.java
import org.kaerdan.mvp_navigation.core.data.DataProvider;
import org.kaerdan.mvp_navigation.core.ui.OnArticleClickListener;
package org.kaerdan.mvp_navigation.example4_injection;
public class InjectArticleListPresenter implements InjectArticleListContract.Presenter, OnArticleClickListener {
private InjectArticleListContract.View mView;
// @Inject
InjectArticleListContract.Navigator mNavigator;
@Override
public void onAttachView(final InjectArticleListContract.View view) {
this.mView = view;
// Usually this call goes asynchronous, but for this example it doesn't matter | view.displayArticles(DataProvider.getInstance().getmArticles(), this); |
NikitaKozlov/MVP-Navigation | app/src/main/java/org/kaerdan/mvp_navigation/MainPresenter.java | // Path: app/src/main/java/org/kaerdan/mvp_navigation/example2_fragments/FragmentsArticleListActivity.java
// public class FragmentsArticleListActivity extends AppCompatActivity implements ArticleListContract.NavigatorProvider {
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_single);
// if (savedInstanceState == null) {
// getSupportFragmentManager().beginTransaction()
// .add(R.id.main_content, new ArticleListFragment(), null)
// .commit();
// }
// }
//
// @NonNull
// @Override
// public ArticleListContract.Navigator getNavigator(final ArticleListContract.Presenter presenter) {
// return new FragmentsArticleListNavigator(this);
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example3_viewpager/ViewPagerActivity.java
// public class ViewPagerActivity extends AppCompatActivity implements ArticleListContract.NavigatorProvider,
// FavoriteListContract.NavigatorProvider {
//
// private ViewPager mViewPager;
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_view_pager);
//
// mViewPager = (ViewPager) findViewById(R.id.container);
// mViewPager.setAdapter(new ViewPagerAdapter(getSupportFragmentManager()));
// ((TabLayout) findViewById(R.id.tabs)).setupWithViewPager(mViewPager);
// }
//
// @NonNull
// @Override
// public ArticleListContract.Navigator getNavigator(final ArticleListContract.Presenter presenter) {
// return new ViewPagerArticleListNavigator(this, mViewPager);
// }
//
// @NonNull
// @Override
// public FavoriteListContract.Navigator getNavigator(final FavoriteListContract.Presenter presenter) {
// return new ViewPagerFavoriteListNavigator(this);
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example4_injection/InjectArticleListActivity.java
// public class InjectArticleListActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_single_fragment);
// if (savedInstanceState == null) {
// getSupportFragmentManager().beginTransaction()
// .add(R.id.content_frame, new InjectArticleListFragment(), null)
// .commit();
// }
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example5_retainpresenter/RetainPresenterArticleListActivity.java
// public class RetainPresenterArticleListActivity extends PresenterActivity
// implements RetainPresenterArticleListContract.NavigatorProvider {
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_single_fragment);
// if (savedInstanceState == null) {
// getSupportFragmentManager().beginTransaction()
// .add(R.id.content_frame, new RetainPresenterArticleListFragment(), null)
// .commit();
// }
// }
//
// @NonNull
// @Override
// public RetainPresenterArticleListContract.Navigator getNavigator(
// final RetainPresenterArticleListContract.Presenter presenter) {
// return new RetainPresenterActivityNavigator(this);
// }
// }
| import android.support.annotation.NonNull;
import java.util.Arrays;
import java.util.List;
import org.kaerdan.mvp_navigation.example2_fragments.FragmentsArticleListActivity;
import org.kaerdan.mvp_navigation.example3_viewpager.ViewPagerActivity;
import org.kaerdan.mvp_navigation.example4_injection.InjectArticleListActivity;
import org.kaerdan.mvp_navigation.example5_retainpresenter.RetainPresenterArticleListActivity; | package org.kaerdan.mvp_navigation;
public class MainPresenter implements MainContract.Presenter {
private final List<Integer> mStringIdList = Arrays.asList(R.string.example1_title, R.string.example2_title,
R.string.example3_title, R.string.example4_title, R.string.example5_title);
private final List<Class<?>> mActivityClsList = Arrays.<Class<?>>asList(
org.kaerdan.mvp_navigation.example1_activities.ArticleListActivity.class, | // Path: app/src/main/java/org/kaerdan/mvp_navigation/example2_fragments/FragmentsArticleListActivity.java
// public class FragmentsArticleListActivity extends AppCompatActivity implements ArticleListContract.NavigatorProvider {
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_single);
// if (savedInstanceState == null) {
// getSupportFragmentManager().beginTransaction()
// .add(R.id.main_content, new ArticleListFragment(), null)
// .commit();
// }
// }
//
// @NonNull
// @Override
// public ArticleListContract.Navigator getNavigator(final ArticleListContract.Presenter presenter) {
// return new FragmentsArticleListNavigator(this);
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example3_viewpager/ViewPagerActivity.java
// public class ViewPagerActivity extends AppCompatActivity implements ArticleListContract.NavigatorProvider,
// FavoriteListContract.NavigatorProvider {
//
// private ViewPager mViewPager;
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_view_pager);
//
// mViewPager = (ViewPager) findViewById(R.id.container);
// mViewPager.setAdapter(new ViewPagerAdapter(getSupportFragmentManager()));
// ((TabLayout) findViewById(R.id.tabs)).setupWithViewPager(mViewPager);
// }
//
// @NonNull
// @Override
// public ArticleListContract.Navigator getNavigator(final ArticleListContract.Presenter presenter) {
// return new ViewPagerArticleListNavigator(this, mViewPager);
// }
//
// @NonNull
// @Override
// public FavoriteListContract.Navigator getNavigator(final FavoriteListContract.Presenter presenter) {
// return new ViewPagerFavoriteListNavigator(this);
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example4_injection/InjectArticleListActivity.java
// public class InjectArticleListActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_single_fragment);
// if (savedInstanceState == null) {
// getSupportFragmentManager().beginTransaction()
// .add(R.id.content_frame, new InjectArticleListFragment(), null)
// .commit();
// }
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example5_retainpresenter/RetainPresenterArticleListActivity.java
// public class RetainPresenterArticleListActivity extends PresenterActivity
// implements RetainPresenterArticleListContract.NavigatorProvider {
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_single_fragment);
// if (savedInstanceState == null) {
// getSupportFragmentManager().beginTransaction()
// .add(R.id.content_frame, new RetainPresenterArticleListFragment(), null)
// .commit();
// }
// }
//
// @NonNull
// @Override
// public RetainPresenterArticleListContract.Navigator getNavigator(
// final RetainPresenterArticleListContract.Presenter presenter) {
// return new RetainPresenterActivityNavigator(this);
// }
// }
// Path: app/src/main/java/org/kaerdan/mvp_navigation/MainPresenter.java
import android.support.annotation.NonNull;
import java.util.Arrays;
import java.util.List;
import org.kaerdan.mvp_navigation.example2_fragments.FragmentsArticleListActivity;
import org.kaerdan.mvp_navigation.example3_viewpager.ViewPagerActivity;
import org.kaerdan.mvp_navigation.example4_injection.InjectArticleListActivity;
import org.kaerdan.mvp_navigation.example5_retainpresenter.RetainPresenterArticleListActivity;
package org.kaerdan.mvp_navigation;
public class MainPresenter implements MainContract.Presenter {
private final List<Integer> mStringIdList = Arrays.asList(R.string.example1_title, R.string.example2_title,
R.string.example3_title, R.string.example4_title, R.string.example5_title);
private final List<Class<?>> mActivityClsList = Arrays.<Class<?>>asList(
org.kaerdan.mvp_navigation.example1_activities.ArticleListActivity.class, | FragmentsArticleListActivity.class, ViewPagerActivity.class, InjectArticleListActivity.class, |
NikitaKozlov/MVP-Navigation | app/src/main/java/org/kaerdan/mvp_navigation/MainPresenter.java | // Path: app/src/main/java/org/kaerdan/mvp_navigation/example2_fragments/FragmentsArticleListActivity.java
// public class FragmentsArticleListActivity extends AppCompatActivity implements ArticleListContract.NavigatorProvider {
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_single);
// if (savedInstanceState == null) {
// getSupportFragmentManager().beginTransaction()
// .add(R.id.main_content, new ArticleListFragment(), null)
// .commit();
// }
// }
//
// @NonNull
// @Override
// public ArticleListContract.Navigator getNavigator(final ArticleListContract.Presenter presenter) {
// return new FragmentsArticleListNavigator(this);
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example3_viewpager/ViewPagerActivity.java
// public class ViewPagerActivity extends AppCompatActivity implements ArticleListContract.NavigatorProvider,
// FavoriteListContract.NavigatorProvider {
//
// private ViewPager mViewPager;
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_view_pager);
//
// mViewPager = (ViewPager) findViewById(R.id.container);
// mViewPager.setAdapter(new ViewPagerAdapter(getSupportFragmentManager()));
// ((TabLayout) findViewById(R.id.tabs)).setupWithViewPager(mViewPager);
// }
//
// @NonNull
// @Override
// public ArticleListContract.Navigator getNavigator(final ArticleListContract.Presenter presenter) {
// return new ViewPagerArticleListNavigator(this, mViewPager);
// }
//
// @NonNull
// @Override
// public FavoriteListContract.Navigator getNavigator(final FavoriteListContract.Presenter presenter) {
// return new ViewPagerFavoriteListNavigator(this);
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example4_injection/InjectArticleListActivity.java
// public class InjectArticleListActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_single_fragment);
// if (savedInstanceState == null) {
// getSupportFragmentManager().beginTransaction()
// .add(R.id.content_frame, new InjectArticleListFragment(), null)
// .commit();
// }
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example5_retainpresenter/RetainPresenterArticleListActivity.java
// public class RetainPresenterArticleListActivity extends PresenterActivity
// implements RetainPresenterArticleListContract.NavigatorProvider {
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_single_fragment);
// if (savedInstanceState == null) {
// getSupportFragmentManager().beginTransaction()
// .add(R.id.content_frame, new RetainPresenterArticleListFragment(), null)
// .commit();
// }
// }
//
// @NonNull
// @Override
// public RetainPresenterArticleListContract.Navigator getNavigator(
// final RetainPresenterArticleListContract.Presenter presenter) {
// return new RetainPresenterActivityNavigator(this);
// }
// }
| import android.support.annotation.NonNull;
import java.util.Arrays;
import java.util.List;
import org.kaerdan.mvp_navigation.example2_fragments.FragmentsArticleListActivity;
import org.kaerdan.mvp_navigation.example3_viewpager.ViewPagerActivity;
import org.kaerdan.mvp_navigation.example4_injection.InjectArticleListActivity;
import org.kaerdan.mvp_navigation.example5_retainpresenter.RetainPresenterArticleListActivity; | package org.kaerdan.mvp_navigation;
public class MainPresenter implements MainContract.Presenter {
private final List<Integer> mStringIdList = Arrays.asList(R.string.example1_title, R.string.example2_title,
R.string.example3_title, R.string.example4_title, R.string.example5_title);
private final List<Class<?>> mActivityClsList = Arrays.<Class<?>>asList(
org.kaerdan.mvp_navigation.example1_activities.ArticleListActivity.class, | // Path: app/src/main/java/org/kaerdan/mvp_navigation/example2_fragments/FragmentsArticleListActivity.java
// public class FragmentsArticleListActivity extends AppCompatActivity implements ArticleListContract.NavigatorProvider {
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_single);
// if (savedInstanceState == null) {
// getSupportFragmentManager().beginTransaction()
// .add(R.id.main_content, new ArticleListFragment(), null)
// .commit();
// }
// }
//
// @NonNull
// @Override
// public ArticleListContract.Navigator getNavigator(final ArticleListContract.Presenter presenter) {
// return new FragmentsArticleListNavigator(this);
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example3_viewpager/ViewPagerActivity.java
// public class ViewPagerActivity extends AppCompatActivity implements ArticleListContract.NavigatorProvider,
// FavoriteListContract.NavigatorProvider {
//
// private ViewPager mViewPager;
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_view_pager);
//
// mViewPager = (ViewPager) findViewById(R.id.container);
// mViewPager.setAdapter(new ViewPagerAdapter(getSupportFragmentManager()));
// ((TabLayout) findViewById(R.id.tabs)).setupWithViewPager(mViewPager);
// }
//
// @NonNull
// @Override
// public ArticleListContract.Navigator getNavigator(final ArticleListContract.Presenter presenter) {
// return new ViewPagerArticleListNavigator(this, mViewPager);
// }
//
// @NonNull
// @Override
// public FavoriteListContract.Navigator getNavigator(final FavoriteListContract.Presenter presenter) {
// return new ViewPagerFavoriteListNavigator(this);
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example4_injection/InjectArticleListActivity.java
// public class InjectArticleListActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_single_fragment);
// if (savedInstanceState == null) {
// getSupportFragmentManager().beginTransaction()
// .add(R.id.content_frame, new InjectArticleListFragment(), null)
// .commit();
// }
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example5_retainpresenter/RetainPresenterArticleListActivity.java
// public class RetainPresenterArticleListActivity extends PresenterActivity
// implements RetainPresenterArticleListContract.NavigatorProvider {
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_single_fragment);
// if (savedInstanceState == null) {
// getSupportFragmentManager().beginTransaction()
// .add(R.id.content_frame, new RetainPresenterArticleListFragment(), null)
// .commit();
// }
// }
//
// @NonNull
// @Override
// public RetainPresenterArticleListContract.Navigator getNavigator(
// final RetainPresenterArticleListContract.Presenter presenter) {
// return new RetainPresenterActivityNavigator(this);
// }
// }
// Path: app/src/main/java/org/kaerdan/mvp_navigation/MainPresenter.java
import android.support.annotation.NonNull;
import java.util.Arrays;
import java.util.List;
import org.kaerdan.mvp_navigation.example2_fragments.FragmentsArticleListActivity;
import org.kaerdan.mvp_navigation.example3_viewpager.ViewPagerActivity;
import org.kaerdan.mvp_navigation.example4_injection.InjectArticleListActivity;
import org.kaerdan.mvp_navigation.example5_retainpresenter.RetainPresenterArticleListActivity;
package org.kaerdan.mvp_navigation;
public class MainPresenter implements MainContract.Presenter {
private final List<Integer> mStringIdList = Arrays.asList(R.string.example1_title, R.string.example2_title,
R.string.example3_title, R.string.example4_title, R.string.example5_title);
private final List<Class<?>> mActivityClsList = Arrays.<Class<?>>asList(
org.kaerdan.mvp_navigation.example1_activities.ArticleListActivity.class, | FragmentsArticleListActivity.class, ViewPagerActivity.class, InjectArticleListActivity.class, |
NikitaKozlov/MVP-Navigation | app/src/main/java/org/kaerdan/mvp_navigation/MainPresenter.java | // Path: app/src/main/java/org/kaerdan/mvp_navigation/example2_fragments/FragmentsArticleListActivity.java
// public class FragmentsArticleListActivity extends AppCompatActivity implements ArticleListContract.NavigatorProvider {
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_single);
// if (savedInstanceState == null) {
// getSupportFragmentManager().beginTransaction()
// .add(R.id.main_content, new ArticleListFragment(), null)
// .commit();
// }
// }
//
// @NonNull
// @Override
// public ArticleListContract.Navigator getNavigator(final ArticleListContract.Presenter presenter) {
// return new FragmentsArticleListNavigator(this);
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example3_viewpager/ViewPagerActivity.java
// public class ViewPagerActivity extends AppCompatActivity implements ArticleListContract.NavigatorProvider,
// FavoriteListContract.NavigatorProvider {
//
// private ViewPager mViewPager;
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_view_pager);
//
// mViewPager = (ViewPager) findViewById(R.id.container);
// mViewPager.setAdapter(new ViewPagerAdapter(getSupportFragmentManager()));
// ((TabLayout) findViewById(R.id.tabs)).setupWithViewPager(mViewPager);
// }
//
// @NonNull
// @Override
// public ArticleListContract.Navigator getNavigator(final ArticleListContract.Presenter presenter) {
// return new ViewPagerArticleListNavigator(this, mViewPager);
// }
//
// @NonNull
// @Override
// public FavoriteListContract.Navigator getNavigator(final FavoriteListContract.Presenter presenter) {
// return new ViewPagerFavoriteListNavigator(this);
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example4_injection/InjectArticleListActivity.java
// public class InjectArticleListActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_single_fragment);
// if (savedInstanceState == null) {
// getSupportFragmentManager().beginTransaction()
// .add(R.id.content_frame, new InjectArticleListFragment(), null)
// .commit();
// }
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example5_retainpresenter/RetainPresenterArticleListActivity.java
// public class RetainPresenterArticleListActivity extends PresenterActivity
// implements RetainPresenterArticleListContract.NavigatorProvider {
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_single_fragment);
// if (savedInstanceState == null) {
// getSupportFragmentManager().beginTransaction()
// .add(R.id.content_frame, new RetainPresenterArticleListFragment(), null)
// .commit();
// }
// }
//
// @NonNull
// @Override
// public RetainPresenterArticleListContract.Navigator getNavigator(
// final RetainPresenterArticleListContract.Presenter presenter) {
// return new RetainPresenterActivityNavigator(this);
// }
// }
| import android.support.annotation.NonNull;
import java.util.Arrays;
import java.util.List;
import org.kaerdan.mvp_navigation.example2_fragments.FragmentsArticleListActivity;
import org.kaerdan.mvp_navigation.example3_viewpager.ViewPagerActivity;
import org.kaerdan.mvp_navigation.example4_injection.InjectArticleListActivity;
import org.kaerdan.mvp_navigation.example5_retainpresenter.RetainPresenterArticleListActivity; | package org.kaerdan.mvp_navigation;
public class MainPresenter implements MainContract.Presenter {
private final List<Integer> mStringIdList = Arrays.asList(R.string.example1_title, R.string.example2_title,
R.string.example3_title, R.string.example4_title, R.string.example5_title);
private final List<Class<?>> mActivityClsList = Arrays.<Class<?>>asList(
org.kaerdan.mvp_navigation.example1_activities.ArticleListActivity.class, | // Path: app/src/main/java/org/kaerdan/mvp_navigation/example2_fragments/FragmentsArticleListActivity.java
// public class FragmentsArticleListActivity extends AppCompatActivity implements ArticleListContract.NavigatorProvider {
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_single);
// if (savedInstanceState == null) {
// getSupportFragmentManager().beginTransaction()
// .add(R.id.main_content, new ArticleListFragment(), null)
// .commit();
// }
// }
//
// @NonNull
// @Override
// public ArticleListContract.Navigator getNavigator(final ArticleListContract.Presenter presenter) {
// return new FragmentsArticleListNavigator(this);
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example3_viewpager/ViewPagerActivity.java
// public class ViewPagerActivity extends AppCompatActivity implements ArticleListContract.NavigatorProvider,
// FavoriteListContract.NavigatorProvider {
//
// private ViewPager mViewPager;
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_view_pager);
//
// mViewPager = (ViewPager) findViewById(R.id.container);
// mViewPager.setAdapter(new ViewPagerAdapter(getSupportFragmentManager()));
// ((TabLayout) findViewById(R.id.tabs)).setupWithViewPager(mViewPager);
// }
//
// @NonNull
// @Override
// public ArticleListContract.Navigator getNavigator(final ArticleListContract.Presenter presenter) {
// return new ViewPagerArticleListNavigator(this, mViewPager);
// }
//
// @NonNull
// @Override
// public FavoriteListContract.Navigator getNavigator(final FavoriteListContract.Presenter presenter) {
// return new ViewPagerFavoriteListNavigator(this);
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example4_injection/InjectArticleListActivity.java
// public class InjectArticleListActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_single_fragment);
// if (savedInstanceState == null) {
// getSupportFragmentManager().beginTransaction()
// .add(R.id.content_frame, new InjectArticleListFragment(), null)
// .commit();
// }
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example5_retainpresenter/RetainPresenterArticleListActivity.java
// public class RetainPresenterArticleListActivity extends PresenterActivity
// implements RetainPresenterArticleListContract.NavigatorProvider {
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_single_fragment);
// if (savedInstanceState == null) {
// getSupportFragmentManager().beginTransaction()
// .add(R.id.content_frame, new RetainPresenterArticleListFragment(), null)
// .commit();
// }
// }
//
// @NonNull
// @Override
// public RetainPresenterArticleListContract.Navigator getNavigator(
// final RetainPresenterArticleListContract.Presenter presenter) {
// return new RetainPresenterActivityNavigator(this);
// }
// }
// Path: app/src/main/java/org/kaerdan/mvp_navigation/MainPresenter.java
import android.support.annotation.NonNull;
import java.util.Arrays;
import java.util.List;
import org.kaerdan.mvp_navigation.example2_fragments.FragmentsArticleListActivity;
import org.kaerdan.mvp_navigation.example3_viewpager.ViewPagerActivity;
import org.kaerdan.mvp_navigation.example4_injection.InjectArticleListActivity;
import org.kaerdan.mvp_navigation.example5_retainpresenter.RetainPresenterArticleListActivity;
package org.kaerdan.mvp_navigation;
public class MainPresenter implements MainContract.Presenter {
private final List<Integer> mStringIdList = Arrays.asList(R.string.example1_title, R.string.example2_title,
R.string.example3_title, R.string.example4_title, R.string.example5_title);
private final List<Class<?>> mActivityClsList = Arrays.<Class<?>>asList(
org.kaerdan.mvp_navigation.example1_activities.ArticleListActivity.class, | FragmentsArticleListActivity.class, ViewPagerActivity.class, InjectArticleListActivity.class, |
NikitaKozlov/MVP-Navigation | app/src/main/java/org/kaerdan/mvp_navigation/MainPresenter.java | // Path: app/src/main/java/org/kaerdan/mvp_navigation/example2_fragments/FragmentsArticleListActivity.java
// public class FragmentsArticleListActivity extends AppCompatActivity implements ArticleListContract.NavigatorProvider {
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_single);
// if (savedInstanceState == null) {
// getSupportFragmentManager().beginTransaction()
// .add(R.id.main_content, new ArticleListFragment(), null)
// .commit();
// }
// }
//
// @NonNull
// @Override
// public ArticleListContract.Navigator getNavigator(final ArticleListContract.Presenter presenter) {
// return new FragmentsArticleListNavigator(this);
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example3_viewpager/ViewPagerActivity.java
// public class ViewPagerActivity extends AppCompatActivity implements ArticleListContract.NavigatorProvider,
// FavoriteListContract.NavigatorProvider {
//
// private ViewPager mViewPager;
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_view_pager);
//
// mViewPager = (ViewPager) findViewById(R.id.container);
// mViewPager.setAdapter(new ViewPagerAdapter(getSupportFragmentManager()));
// ((TabLayout) findViewById(R.id.tabs)).setupWithViewPager(mViewPager);
// }
//
// @NonNull
// @Override
// public ArticleListContract.Navigator getNavigator(final ArticleListContract.Presenter presenter) {
// return new ViewPagerArticleListNavigator(this, mViewPager);
// }
//
// @NonNull
// @Override
// public FavoriteListContract.Navigator getNavigator(final FavoriteListContract.Presenter presenter) {
// return new ViewPagerFavoriteListNavigator(this);
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example4_injection/InjectArticleListActivity.java
// public class InjectArticleListActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_single_fragment);
// if (savedInstanceState == null) {
// getSupportFragmentManager().beginTransaction()
// .add(R.id.content_frame, new InjectArticleListFragment(), null)
// .commit();
// }
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example5_retainpresenter/RetainPresenterArticleListActivity.java
// public class RetainPresenterArticleListActivity extends PresenterActivity
// implements RetainPresenterArticleListContract.NavigatorProvider {
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_single_fragment);
// if (savedInstanceState == null) {
// getSupportFragmentManager().beginTransaction()
// .add(R.id.content_frame, new RetainPresenterArticleListFragment(), null)
// .commit();
// }
// }
//
// @NonNull
// @Override
// public RetainPresenterArticleListContract.Navigator getNavigator(
// final RetainPresenterArticleListContract.Presenter presenter) {
// return new RetainPresenterActivityNavigator(this);
// }
// }
| import android.support.annotation.NonNull;
import java.util.Arrays;
import java.util.List;
import org.kaerdan.mvp_navigation.example2_fragments.FragmentsArticleListActivity;
import org.kaerdan.mvp_navigation.example3_viewpager.ViewPagerActivity;
import org.kaerdan.mvp_navigation.example4_injection.InjectArticleListActivity;
import org.kaerdan.mvp_navigation.example5_retainpresenter.RetainPresenterArticleListActivity; | package org.kaerdan.mvp_navigation;
public class MainPresenter implements MainContract.Presenter {
private final List<Integer> mStringIdList = Arrays.asList(R.string.example1_title, R.string.example2_title,
R.string.example3_title, R.string.example4_title, R.string.example5_title);
private final List<Class<?>> mActivityClsList = Arrays.<Class<?>>asList(
org.kaerdan.mvp_navigation.example1_activities.ArticleListActivity.class,
FragmentsArticleListActivity.class, ViewPagerActivity.class, InjectArticleListActivity.class, | // Path: app/src/main/java/org/kaerdan/mvp_navigation/example2_fragments/FragmentsArticleListActivity.java
// public class FragmentsArticleListActivity extends AppCompatActivity implements ArticleListContract.NavigatorProvider {
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_single);
// if (savedInstanceState == null) {
// getSupportFragmentManager().beginTransaction()
// .add(R.id.main_content, new ArticleListFragment(), null)
// .commit();
// }
// }
//
// @NonNull
// @Override
// public ArticleListContract.Navigator getNavigator(final ArticleListContract.Presenter presenter) {
// return new FragmentsArticleListNavigator(this);
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example3_viewpager/ViewPagerActivity.java
// public class ViewPagerActivity extends AppCompatActivity implements ArticleListContract.NavigatorProvider,
// FavoriteListContract.NavigatorProvider {
//
// private ViewPager mViewPager;
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_view_pager);
//
// mViewPager = (ViewPager) findViewById(R.id.container);
// mViewPager.setAdapter(new ViewPagerAdapter(getSupportFragmentManager()));
// ((TabLayout) findViewById(R.id.tabs)).setupWithViewPager(mViewPager);
// }
//
// @NonNull
// @Override
// public ArticleListContract.Navigator getNavigator(final ArticleListContract.Presenter presenter) {
// return new ViewPagerArticleListNavigator(this, mViewPager);
// }
//
// @NonNull
// @Override
// public FavoriteListContract.Navigator getNavigator(final FavoriteListContract.Presenter presenter) {
// return new ViewPagerFavoriteListNavigator(this);
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example4_injection/InjectArticleListActivity.java
// public class InjectArticleListActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_single_fragment);
// if (savedInstanceState == null) {
// getSupportFragmentManager().beginTransaction()
// .add(R.id.content_frame, new InjectArticleListFragment(), null)
// .commit();
// }
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example5_retainpresenter/RetainPresenterArticleListActivity.java
// public class RetainPresenterArticleListActivity extends PresenterActivity
// implements RetainPresenterArticleListContract.NavigatorProvider {
//
// @Override
// protected void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_single_fragment);
// if (savedInstanceState == null) {
// getSupportFragmentManager().beginTransaction()
// .add(R.id.content_frame, new RetainPresenterArticleListFragment(), null)
// .commit();
// }
// }
//
// @NonNull
// @Override
// public RetainPresenterArticleListContract.Navigator getNavigator(
// final RetainPresenterArticleListContract.Presenter presenter) {
// return new RetainPresenterActivityNavigator(this);
// }
// }
// Path: app/src/main/java/org/kaerdan/mvp_navigation/MainPresenter.java
import android.support.annotation.NonNull;
import java.util.Arrays;
import java.util.List;
import org.kaerdan.mvp_navigation.example2_fragments.FragmentsArticleListActivity;
import org.kaerdan.mvp_navigation.example3_viewpager.ViewPagerActivity;
import org.kaerdan.mvp_navigation.example4_injection.InjectArticleListActivity;
import org.kaerdan.mvp_navigation.example5_retainpresenter.RetainPresenterArticleListActivity;
package org.kaerdan.mvp_navigation;
public class MainPresenter implements MainContract.Presenter {
private final List<Integer> mStringIdList = Arrays.asList(R.string.example1_title, R.string.example2_title,
R.string.example3_title, R.string.example4_title, R.string.example5_title);
private final List<Class<?>> mActivityClsList = Arrays.<Class<?>>asList(
org.kaerdan.mvp_navigation.example1_activities.ArticleListActivity.class,
FragmentsArticleListActivity.class, ViewPagerActivity.class, InjectArticleListActivity.class, | RetainPresenterArticleListActivity.class); |
NikitaKozlov/MVP-Navigation | app/src/main/java/org/kaerdan/mvp_navigation/example1_activities/ArticleActivity.java | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/article/ArticleFragment.java
// public class ArticleFragment extends Fragment implements ArticleContract.View {
//
// private static final String ARTICLE_ID_TAG = "Article id";
//
// public static ArticleFragment newInstance(final int id) {
// Bundle args = new Bundle();
// args.putInt(ARTICLE_ID_TAG, id);
//
// ArticleFragment fragment = new ArticleFragment();
// fragment.setArguments(args);
// return fragment;
// }
//
// private ArticleContract.Presenter mPresenter;
// private TextView mArticleTextView;
//
// public ArticleFragment() {
// // Required empty public constructor
// }
//
// @Override
// public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
// final Bundle savedInstanceState) {
//
// // Inflate the layout for this fragment
// mPresenter = new ArticlePresenter(getArguments().getInt(ARTICLE_ID_TAG));
//
// View v = inflater.inflate(R.layout.fragment_article, container, false);
// mArticleTextView = (TextView) v.findViewById(R.id.article_body);
// return v;
// }
//
// @Override
// public void onStart() {
// super.onStart();
// mPresenter.onAttachView(this);
// }
//
// @Override
// public void onStop() {
// super.onStop();
// mPresenter.onDetachView();
// }
//
// @Override
// public void displayArticle(@NonNull final Article article) {
// mArticleTextView.setText(article.getBody());
// }
// }
| import org.kaerdan.mvp_navigation.R;
import org.kaerdan.mvp_navigation.core.ui.article.ArticleFragment;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.MenuItem; | package org.kaerdan.mvp_navigation.example1_activities;
public class ArticleActivity extends AppCompatActivity {
private static final String ARTICLE_ID_TAG = "Article id";
public static Intent createIntent(final Context context, final int id) {
Intent intent = new Intent(context, ArticleActivity.class);
intent.putExtra(ARTICLE_ID_TAG, id);
return intent;
}
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_single_fragment);
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.content_frame, | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/article/ArticleFragment.java
// public class ArticleFragment extends Fragment implements ArticleContract.View {
//
// private static final String ARTICLE_ID_TAG = "Article id";
//
// public static ArticleFragment newInstance(final int id) {
// Bundle args = new Bundle();
// args.putInt(ARTICLE_ID_TAG, id);
//
// ArticleFragment fragment = new ArticleFragment();
// fragment.setArguments(args);
// return fragment;
// }
//
// private ArticleContract.Presenter mPresenter;
// private TextView mArticleTextView;
//
// public ArticleFragment() {
// // Required empty public constructor
// }
//
// @Override
// public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
// final Bundle savedInstanceState) {
//
// // Inflate the layout for this fragment
// mPresenter = new ArticlePresenter(getArguments().getInt(ARTICLE_ID_TAG));
//
// View v = inflater.inflate(R.layout.fragment_article, container, false);
// mArticleTextView = (TextView) v.findViewById(R.id.article_body);
// return v;
// }
//
// @Override
// public void onStart() {
// super.onStart();
// mPresenter.onAttachView(this);
// }
//
// @Override
// public void onStop() {
// super.onStop();
// mPresenter.onDetachView();
// }
//
// @Override
// public void displayArticle(@NonNull final Article article) {
// mArticleTextView.setText(article.getBody());
// }
// }
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example1_activities/ArticleActivity.java
import org.kaerdan.mvp_navigation.R;
import org.kaerdan.mvp_navigation.core.ui.article.ArticleFragment;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.MenuItem;
package org.kaerdan.mvp_navigation.example1_activities;
public class ArticleActivity extends AppCompatActivity {
private static final String ARTICLE_ID_TAG = "Article id";
public static Intent createIntent(final Context context, final int id) {
Intent intent = new Intent(context, ArticleActivity.class);
intent.putExtra(ARTICLE_ID_TAG, id);
return intent;
}
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_single_fragment);
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.content_frame, | ArticleFragment.newInstance(getIntent().getIntExtra(ARTICLE_ID_TAG, 0)), null).commit(); |
NikitaKozlov/MVP-Navigation | app/src/main/java/org/kaerdan/mvp_navigation/example2_fragments/FragmentsArticleListActivity.java | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/article_list/ArticleListContract.java
// public interface ArticleListContract {
// interface Presenter extends org.kaerdan.mvp_navigation.core.Presenter<View> {
// void setNavigator(@NonNull Navigator navigator);
//
// void onFavoriteArticleClick();
// }
//
// interface View extends org.kaerdan.mvp_navigation.core.Presenter.View {
// void displayArticles(@NonNull List<Article> articles, @NonNull OnArticleClickListener onArticleClickListener);
// }
//
// interface Navigator {
// void openArticle(int id);
//
// void openFavoriteArticles();
// }
//
// interface NavigatorProvider {
//
// @NonNull
// Navigator getNavigator(ArticleListContract.Presenter presenter);
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/article_list/ArticleListFragment.java
// public class ArticleListFragment extends Fragment implements ArticleListContract.View {
//
// private ArticleListContract.Presenter mPresenter;
//
// private RecyclerView mRecyclerView;
//
// public ArticleListFragment() {
// // Required empty public constructor
// }
//
// @Override
// public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
// final Bundle savedInstanceState) {
// mPresenter = createPresenter();
//
// // Inflate the layout for this fragment
// View view = inflater.inflate(R.layout.fragment_article_list, container, false);
// mRecyclerView = (RecyclerView) view.findViewById(R.id.article_list);
// mRecyclerView.setLayoutManager(new LinearLayoutManager(container.getContext(), LinearLayoutManager.VERTICAL,
// false));
//
// view.findViewById(R.id.favorite_articles).setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(final View v) {
// mPresenter.onFavoriteArticleClick();
// }
// });
//
// return view;
// }
//
// @NonNull
// protected ArticleListContract.Presenter createPresenter() {
// ArticleListContract.Presenter presenter = new ArticleListPresenter();
// presenter.setNavigator(getNavigator(presenter));
// return presenter;
// }
//
// @NonNull
// protected ArticleListContract.Navigator getNavigator(final ArticleListContract.Presenter presenter) {
// Fragment parentFragment = getParentFragment();
// if (parentFragment != null && parentFragment instanceof ArticleListContract.NavigatorProvider) {
// return ((ArticleListContract.NavigatorProvider) parentFragment).getNavigator(presenter);
// } else {
// Activity activity = getActivity();
// if (activity instanceof ArticleListContract.NavigatorProvider) {
// return ((ArticleListContract.NavigatorProvider) activity).getNavigator(presenter);
// }
// }
//
// throw new IllegalStateException("Activity or parent Fragment must implement "
// + "ArticleListContract.NavigatorProvider");
// }
//
// @Override
// public void onStart() {
// super.onStart();
// mPresenter.onAttachView(this);
// }
//
// @Override
// public void onStop() {
// super.onStop();
// mPresenter.onDetachView();
// }
//
// @Override
// public void displayArticles(@NonNull final List<Article> articles,
// @NonNull final OnArticleClickListener onArticleClickListener) {
// mRecyclerView.setAdapter(new ArticleListAdapter(articles, onArticleClickListener));
// }
// }
| import org.kaerdan.mvp_navigation.R;
import org.kaerdan.mvp_navigation.core.ui.article_list.ArticleListContract;
import org.kaerdan.mvp_navigation.core.ui.article_list.ArticleListFragment;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity; | package org.kaerdan.mvp_navigation.example2_fragments;
public class FragmentsArticleListActivity extends AppCompatActivity implements ArticleListContract.NavigatorProvider {
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_single);
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction() | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/article_list/ArticleListContract.java
// public interface ArticleListContract {
// interface Presenter extends org.kaerdan.mvp_navigation.core.Presenter<View> {
// void setNavigator(@NonNull Navigator navigator);
//
// void onFavoriteArticleClick();
// }
//
// interface View extends org.kaerdan.mvp_navigation.core.Presenter.View {
// void displayArticles(@NonNull List<Article> articles, @NonNull OnArticleClickListener onArticleClickListener);
// }
//
// interface Navigator {
// void openArticle(int id);
//
// void openFavoriteArticles();
// }
//
// interface NavigatorProvider {
//
// @NonNull
// Navigator getNavigator(ArticleListContract.Presenter presenter);
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/article_list/ArticleListFragment.java
// public class ArticleListFragment extends Fragment implements ArticleListContract.View {
//
// private ArticleListContract.Presenter mPresenter;
//
// private RecyclerView mRecyclerView;
//
// public ArticleListFragment() {
// // Required empty public constructor
// }
//
// @Override
// public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
// final Bundle savedInstanceState) {
// mPresenter = createPresenter();
//
// // Inflate the layout for this fragment
// View view = inflater.inflate(R.layout.fragment_article_list, container, false);
// mRecyclerView = (RecyclerView) view.findViewById(R.id.article_list);
// mRecyclerView.setLayoutManager(new LinearLayoutManager(container.getContext(), LinearLayoutManager.VERTICAL,
// false));
//
// view.findViewById(R.id.favorite_articles).setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(final View v) {
// mPresenter.onFavoriteArticleClick();
// }
// });
//
// return view;
// }
//
// @NonNull
// protected ArticleListContract.Presenter createPresenter() {
// ArticleListContract.Presenter presenter = new ArticleListPresenter();
// presenter.setNavigator(getNavigator(presenter));
// return presenter;
// }
//
// @NonNull
// protected ArticleListContract.Navigator getNavigator(final ArticleListContract.Presenter presenter) {
// Fragment parentFragment = getParentFragment();
// if (parentFragment != null && parentFragment instanceof ArticleListContract.NavigatorProvider) {
// return ((ArticleListContract.NavigatorProvider) parentFragment).getNavigator(presenter);
// } else {
// Activity activity = getActivity();
// if (activity instanceof ArticleListContract.NavigatorProvider) {
// return ((ArticleListContract.NavigatorProvider) activity).getNavigator(presenter);
// }
// }
//
// throw new IllegalStateException("Activity or parent Fragment must implement "
// + "ArticleListContract.NavigatorProvider");
// }
//
// @Override
// public void onStart() {
// super.onStart();
// mPresenter.onAttachView(this);
// }
//
// @Override
// public void onStop() {
// super.onStop();
// mPresenter.onDetachView();
// }
//
// @Override
// public void displayArticles(@NonNull final List<Article> articles,
// @NonNull final OnArticleClickListener onArticleClickListener) {
// mRecyclerView.setAdapter(new ArticleListAdapter(articles, onArticleClickListener));
// }
// }
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example2_fragments/FragmentsArticleListActivity.java
import org.kaerdan.mvp_navigation.R;
import org.kaerdan.mvp_navigation.core.ui.article_list.ArticleListContract;
import org.kaerdan.mvp_navigation.core.ui.article_list.ArticleListFragment;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
package org.kaerdan.mvp_navigation.example2_fragments;
public class FragmentsArticleListActivity extends AppCompatActivity implements ArticleListContract.NavigatorProvider {
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_single);
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction() | .add(R.id.main_content, new ArticleListFragment(), null) |
NikitaKozlov/MVP-Navigation | app/src/main/java/org/kaerdan/mvp_navigation/example2_fragments/FragmentsFavoriteListNavigator.java | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/article/ArticleFragment.java
// public class ArticleFragment extends Fragment implements ArticleContract.View {
//
// private static final String ARTICLE_ID_TAG = "Article id";
//
// public static ArticleFragment newInstance(final int id) {
// Bundle args = new Bundle();
// args.putInt(ARTICLE_ID_TAG, id);
//
// ArticleFragment fragment = new ArticleFragment();
// fragment.setArguments(args);
// return fragment;
// }
//
// private ArticleContract.Presenter mPresenter;
// private TextView mArticleTextView;
//
// public ArticleFragment() {
// // Required empty public constructor
// }
//
// @Override
// public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
// final Bundle savedInstanceState) {
//
// // Inflate the layout for this fragment
// mPresenter = new ArticlePresenter(getArguments().getInt(ARTICLE_ID_TAG));
//
// View v = inflater.inflate(R.layout.fragment_article, container, false);
// mArticleTextView = (TextView) v.findViewById(R.id.article_body);
// return v;
// }
//
// @Override
// public void onStart() {
// super.onStart();
// mPresenter.onAttachView(this);
// }
//
// @Override
// public void onStop() {
// super.onStop();
// mPresenter.onDetachView();
// }
//
// @Override
// public void displayArticle(@NonNull final Article article) {
// mArticleTextView.setText(article.getBody());
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/favorite_list/FavoriteListContract.java
// public interface FavoriteListContract {
// interface Presenter extends org.kaerdan.mvp_navigation.core.Presenter<View> {
// void setNavigator(@NonNull Navigator navigator);
// }
//
// interface View extends org.kaerdan.mvp_navigation.core.Presenter.View {
// void displayArticles(@NonNull List<Article> articles, @NonNull OnArticleClickListener onArticleClickListener);
// }
//
// interface Navigator {
// void openArticle(int id);
// }
//
// interface NavigatorProvider {
//
// @NonNull
// Navigator getNavigator(FavoriteListContract.Presenter presenter);
// }
// }
| import org.kaerdan.mvp_navigation.R;
import org.kaerdan.mvp_navigation.core.ui.article.ArticleFragment;
import org.kaerdan.mvp_navigation.core.ui.favorite_list.FavoriteListContract;
import android.support.v7.app.AppCompatActivity; | package org.kaerdan.mvp_navigation.example2_fragments;
public class FragmentsFavoriteListNavigator implements FavoriteListContract.Navigator {
private final AppCompatActivity mActivity;
public FragmentsFavoriteListNavigator(final AppCompatActivity activity) {
this.mActivity = activity;
}
@Override
public void openArticle(final int id) {
mActivity.getSupportFragmentManager()
.beginTransaction() | // Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/article/ArticleFragment.java
// public class ArticleFragment extends Fragment implements ArticleContract.View {
//
// private static final String ARTICLE_ID_TAG = "Article id";
//
// public static ArticleFragment newInstance(final int id) {
// Bundle args = new Bundle();
// args.putInt(ARTICLE_ID_TAG, id);
//
// ArticleFragment fragment = new ArticleFragment();
// fragment.setArguments(args);
// return fragment;
// }
//
// private ArticleContract.Presenter mPresenter;
// private TextView mArticleTextView;
//
// public ArticleFragment() {
// // Required empty public constructor
// }
//
// @Override
// public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
// final Bundle savedInstanceState) {
//
// // Inflate the layout for this fragment
// mPresenter = new ArticlePresenter(getArguments().getInt(ARTICLE_ID_TAG));
//
// View v = inflater.inflate(R.layout.fragment_article, container, false);
// mArticleTextView = (TextView) v.findViewById(R.id.article_body);
// return v;
// }
//
// @Override
// public void onStart() {
// super.onStart();
// mPresenter.onAttachView(this);
// }
//
// @Override
// public void onStop() {
// super.onStop();
// mPresenter.onDetachView();
// }
//
// @Override
// public void displayArticle(@NonNull final Article article) {
// mArticleTextView.setText(article.getBody());
// }
// }
//
// Path: app/src/main/java/org/kaerdan/mvp_navigation/core/ui/favorite_list/FavoriteListContract.java
// public interface FavoriteListContract {
// interface Presenter extends org.kaerdan.mvp_navigation.core.Presenter<View> {
// void setNavigator(@NonNull Navigator navigator);
// }
//
// interface View extends org.kaerdan.mvp_navigation.core.Presenter.View {
// void displayArticles(@NonNull List<Article> articles, @NonNull OnArticleClickListener onArticleClickListener);
// }
//
// interface Navigator {
// void openArticle(int id);
// }
//
// interface NavigatorProvider {
//
// @NonNull
// Navigator getNavigator(FavoriteListContract.Presenter presenter);
// }
// }
// Path: app/src/main/java/org/kaerdan/mvp_navigation/example2_fragments/FragmentsFavoriteListNavigator.java
import org.kaerdan.mvp_navigation.R;
import org.kaerdan.mvp_navigation.core.ui.article.ArticleFragment;
import org.kaerdan.mvp_navigation.core.ui.favorite_list.FavoriteListContract;
import android.support.v7.app.AppCompatActivity;
package org.kaerdan.mvp_navigation.example2_fragments;
public class FragmentsFavoriteListNavigator implements FavoriteListContract.Navigator {
private final AppCompatActivity mActivity;
public FragmentsFavoriteListNavigator(final AppCompatActivity activity) {
this.mActivity = activity;
}
@Override
public void openArticle(final int id) {
mActivity.getSupportFragmentManager()
.beginTransaction() | .replace(R.id.secondary_content, ArticleFragment.newInstance(id), null) |
rapid7/nexpose_java_api | src/main/java/org/rapid7/nexpose/api/LogoutRequest.java | // Path: src/main/java/org/rapid7/nexpose/api/APISession.java
// public enum APISupportedVersion
// {
// V1_0("1.0"), V1_1("1.1"), V1_2("1.2");
// private String m_version;
//
// APISupportedVersion(String value)
// {
// m_version = value;
// }
// String getVersion()
// {
// return m_version;
// }
// }
| import org.rapid7.nexpose.api.APISession.APISupportedVersion; | /**
* Copyright (C) 2012, Rapid7 LLC, Boston, MA, USA.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.rapid7.nexpose.api;
/**
* Encapsulates the LogoutRequest NeXpose API request.
*
* @author Leonardo Varela
*/
public class LogoutRequest extends TemplateAPIRequest
{
/**
* Creates a new LogoutRequest NeXpose API request.
*
* @param sessionId the session to be used if different from the one on the
* current APISession. useful when testing edge cases and testing in
* general.
* @param syncId the syncId to identify the request/response pair.
*/
public LogoutRequest(String sessionId, String syncId)
{
super(sessionId, syncId); | // Path: src/main/java/org/rapid7/nexpose/api/APISession.java
// public enum APISupportedVersion
// {
// V1_0("1.0"), V1_1("1.1"), V1_2("1.2");
// private String m_version;
//
// APISupportedVersion(String value)
// {
// m_version = value;
// }
// String getVersion()
// {
// return m_version;
// }
// }
// Path: src/main/java/org/rapid7/nexpose/api/LogoutRequest.java
import org.rapid7.nexpose.api.APISession.APISupportedVersion;
/**
* Copyright (C) 2012, Rapid7 LLC, Boston, MA, USA.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.rapid7.nexpose.api;
/**
* Encapsulates the LogoutRequest NeXpose API request.
*
* @author Leonardo Varela
*/
public class LogoutRequest extends TemplateAPIRequest
{
/**
* Creates a new LogoutRequest NeXpose API request.
*
* @param sessionId the session to be used if different from the one on the
* current APISession. useful when testing edge cases and testing in
* general.
* @param syncId the syncId to identify the request/response pair.
*/
public LogoutRequest(String sessionId, String syncId)
{
super(sessionId, syncId); | m_firstSupportedVersion = APISupportedVersion.V1_0; |
rapid7/nexpose_java_api | src/main/java/org/rapid7/nexpose/api/ScanStatisticsRequest.java | // Path: src/main/java/org/rapid7/nexpose/api/APISession.java
// public enum APISupportedVersion
// {
// V1_0("1.0"), V1_1("1.1"), V1_2("1.2");
// private String m_version;
//
// APISupportedVersion(String value)
// {
// m_version = value;
// }
// String getVersion()
// {
// return m_version;
// }
// }
| import org.rapid7.nexpose.api.APISession.APISupportedVersion; | /**
* Copyright (C) 2012, Rapid7 LLC, Boston, MA, USA.
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.rapid7.nexpose.api;
/**
* Represents the ScanStatisticsRequest NeXpose API request.
*
* @author Leonardo Varela
*/
public class ScanStatisticsRequest extends TemplateAPIRequest
{
/////////////////////////////////////////////////////////////////////////
// Public methods
/////////////////////////////////////////////////////////////////////////
/**
* Creates a new ScanStatisticsRequest NeXpose API Request. Sets the first API
* supported version to 1.0 and the last supported version to 1.1.
*
* NOTE: All parameters are strings or generators, since we want to be able
* to test edge cases and simulate incorrect usage of the tool for robustness
*
* @param sessionId the session to be used if different from the current
* acquired one (You acquire one when you authenticate correctly with
* the login method in the {@link APISession} class). This is a
* String of 40 characters.
* @param syncId the synchronization id to identify the response associated
* with the response in asynchronous environments. It can be any
* string. This field is optional.
* @param scanId the positive integer that represents the scan id of the
* scan to be queried.
*/
public ScanStatisticsRequest(String sessionId, String syncId, String scanId)
{
super(sessionId, syncId);
set("scanId", scanId); | // Path: src/main/java/org/rapid7/nexpose/api/APISession.java
// public enum APISupportedVersion
// {
// V1_0("1.0"), V1_1("1.1"), V1_2("1.2");
// private String m_version;
//
// APISupportedVersion(String value)
// {
// m_version = value;
// }
// String getVersion()
// {
// return m_version;
// }
// }
// Path: src/main/java/org/rapid7/nexpose/api/ScanStatisticsRequest.java
import org.rapid7.nexpose.api.APISession.APISupportedVersion;
/**
* Copyright (C) 2012, Rapid7 LLC, Boston, MA, USA.
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.rapid7.nexpose.api;
/**
* Represents the ScanStatisticsRequest NeXpose API request.
*
* @author Leonardo Varela
*/
public class ScanStatisticsRequest extends TemplateAPIRequest
{
/////////////////////////////////////////////////////////////////////////
// Public methods
/////////////////////////////////////////////////////////////////////////
/**
* Creates a new ScanStatisticsRequest NeXpose API Request. Sets the first API
* supported version to 1.0 and the last supported version to 1.1.
*
* NOTE: All parameters are strings or generators, since we want to be able
* to test edge cases and simulate incorrect usage of the tool for robustness
*
* @param sessionId the session to be used if different from the current
* acquired one (You acquire one when you authenticate correctly with
* the login method in the {@link APISession} class). This is a
* String of 40 characters.
* @param syncId the synchronization id to identify the response associated
* with the response in asynchronous environments. It can be any
* string. This field is optional.
* @param scanId the positive integer that represents the scan id of the
* scan to be queried.
*/
public ScanStatisticsRequest(String sessionId, String syncId, String scanId)
{
super(sessionId, syncId);
set("scanId", scanId); | m_firstSupportedVersion = APISupportedVersion.V1_0; |
rapid7/nexpose_java_api | src/main/java/org/rapid7/nexpose/api/VulnerabilityExceptionRejectRequest.java | // Path: src/main/java/org/rapid7/nexpose/api/APISession.java
// public enum APISupportedVersion
// {
// V1_0("1.0"), V1_1("1.1"), V1_2("1.2");
// private String m_version;
//
// APISupportedVersion(String value)
// {
// m_version = value;
// }
// String getVersion()
// {
// return m_version;
// }
// }
| import org.rapid7.nexpose.api.APISession.APISupportedVersion; | /**
* Copyright (C) 2012, Rapid7 LLC, Boston, MA, USA.
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.rapid7.nexpose.api;
/**
* Encapsulates the {@link VulnerabilityExceptionRejectRequest} Nexpose API request.
*
* @author Murali Rongali
*/
public class VulnerabilityExceptionRejectRequest extends TemplateAPIRequest
{
/////////////////////////////////////////////////////////////////////////
// Public methods
/////////////////////////////////////////////////////////////////////////
/**
* Constructs a {@link VulnerabilityExceptionRejectRequest} with its associated API version
* information.
*
* @param sessionId the session to submit the request with. May not be {@code null} nor empty and must
* be a 40 character hex {@link String}.
* @param syncId the sync id to identify the response. May be {@code null}.
* @param exceptionId the id of the Vulnerability exception.
* @param comment the comment for the vulnerabilty exception.
*/
public VulnerabilityExceptionRejectRequest(String sessionId, String syncId, String exceptionId, String comment)
{
super(sessionId, syncId);
set("exceptionId", exceptionId);
set("comment", comment); | // Path: src/main/java/org/rapid7/nexpose/api/APISession.java
// public enum APISupportedVersion
// {
// V1_0("1.0"), V1_1("1.1"), V1_2("1.2");
// private String m_version;
//
// APISupportedVersion(String value)
// {
// m_version = value;
// }
// String getVersion()
// {
// return m_version;
// }
// }
// Path: src/main/java/org/rapid7/nexpose/api/VulnerabilityExceptionRejectRequest.java
import org.rapid7.nexpose.api.APISession.APISupportedVersion;
/**
* Copyright (C) 2012, Rapid7 LLC, Boston, MA, USA.
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.rapid7.nexpose.api;
/**
* Encapsulates the {@link VulnerabilityExceptionRejectRequest} Nexpose API request.
*
* @author Murali Rongali
*/
public class VulnerabilityExceptionRejectRequest extends TemplateAPIRequest
{
/////////////////////////////////////////////////////////////////////////
// Public methods
/////////////////////////////////////////////////////////////////////////
/**
* Constructs a {@link VulnerabilityExceptionRejectRequest} with its associated API version
* information.
*
* @param sessionId the session to submit the request with. May not be {@code null} nor empty and must
* be a 40 character hex {@link String}.
* @param syncId the sync id to identify the response. May be {@code null}.
* @param exceptionId the id of the Vulnerability exception.
* @param comment the comment for the vulnerabilty exception.
*/
public VulnerabilityExceptionRejectRequest(String sessionId, String syncId, String exceptionId, String comment)
{
super(sessionId, syncId);
set("exceptionId", exceptionId);
set("comment", comment); | m_firstSupportedVersion = APISupportedVersion.V1_2; |
rapid7/nexpose_java_api | src/main/java/org/rapid7/nexpose/api/DiscoveryConnectionCreateRequest.java | // Path: src/main/java/org/rapid7/nexpose/api/APISession.java
// public enum APISupportedVersion
// {
// V1_0("1.0"), V1_1("1.1"), V1_2("1.2");
// private String m_version;
//
// APISupportedVersion(String value)
// {
// m_version = value;
// }
// String getVersion()
// {
// return m_version;
// }
// }
| import org.rapid7.nexpose.api.APISession.APISupportedVersion; | /**
* Copyright (C) 2012, Rapid7 LLC, Boston, MA, USA.
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.rapid7.nexpose.api;
/**
* Encapsulates the DiscoveryConnectionCreate Nexpose API request.
*
* @author Murali Rongali
*/
public class DiscoveryConnectionCreateRequest extends TemplateAPIRequest
{
/////////////////////////////////////////////////////////////////////////
// Public methods
/////////////////////////////////////////////////////////////////////////
/**
* Constructs a {@link DiscoveryConnectionCreateRequest} with its associated API version
* information.
*
* @param sessionId the session to submit the request with. May not be {@code null} nor empty and must
* be a 40 character hex {@link String}.
* @param syncId the sync id to identify the response. May be {@code null}.
* @param userName the String that represents the login name to connect to the target device.
* @param protocol the String that represents the protocol to connect to the target device.
* @param port the String that represents the port to connect to the target device.
* @param address the String that represents the address of the target device.
* @param name the String that represents the name of the discovery connection.
* @param password the String that represents the password to connect to the target device.
*/
public DiscoveryConnectionCreateRequest(
String sessionId,
String syncId,
String userName,
String protocol,
String port,
String address,
String name,
String password)
{
super(sessionId, syncId);
set("userName", userName);
set("protocol", protocol);
set("port", port);
set("address", address);
set("name", name);
set("password", password); | // Path: src/main/java/org/rapid7/nexpose/api/APISession.java
// public enum APISupportedVersion
// {
// V1_0("1.0"), V1_1("1.1"), V1_2("1.2");
// private String m_version;
//
// APISupportedVersion(String value)
// {
// m_version = value;
// }
// String getVersion()
// {
// return m_version;
// }
// }
// Path: src/main/java/org/rapid7/nexpose/api/DiscoveryConnectionCreateRequest.java
import org.rapid7.nexpose.api.APISession.APISupportedVersion;
/**
* Copyright (C) 2012, Rapid7 LLC, Boston, MA, USA.
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.rapid7.nexpose.api;
/**
* Encapsulates the DiscoveryConnectionCreate Nexpose API request.
*
* @author Murali Rongali
*/
public class DiscoveryConnectionCreateRequest extends TemplateAPIRequest
{
/////////////////////////////////////////////////////////////////////////
// Public methods
/////////////////////////////////////////////////////////////////////////
/**
* Constructs a {@link DiscoveryConnectionCreateRequest} with its associated API version
* information.
*
* @param sessionId the session to submit the request with. May not be {@code null} nor empty and must
* be a 40 character hex {@link String}.
* @param syncId the sync id to identify the response. May be {@code null}.
* @param userName the String that represents the login name to connect to the target device.
* @param protocol the String that represents the protocol to connect to the target device.
* @param port the String that represents the port to connect to the target device.
* @param address the String that represents the address of the target device.
* @param name the String that represents the name of the discovery connection.
* @param password the String that represents the password to connect to the target device.
*/
public DiscoveryConnectionCreateRequest(
String sessionId,
String syncId,
String userName,
String protocol,
String port,
String address,
String name,
String password)
{
super(sessionId, syncId);
set("userName", userName);
set("protocol", protocol);
set("port", port);
set("address", address);
set("name", name);
set("password", password); | m_firstSupportedVersion = APISupportedVersion.V1_2; |
rapid7/nexpose_java_api | src/main/java/org/rapid7/nexpose/api/TicketDeleteRequest.java | // Path: src/main/java/org/rapid7/nexpose/api/APISession.java
// public enum APISupportedVersion
// {
// V1_0("1.0"), V1_1("1.1"), V1_2("1.2");
// private String m_version;
//
// APISupportedVersion(String value)
// {
// m_version = value;
// }
// String getVersion()
// {
// return m_version;
// }
// }
//
// Path: src/main/java/org/rapid7/nexpose/api/generators/IContentGenerator.java
// public interface IContentGenerator
// {
// /**
// * Knows how to generate content for a request.
// * @return the generated content
// */
// String toString();
// /**
// * Sets the contents of the generator that come as a parameter
// */
// void setContents(Element contents);
// }
| import org.rapid7.nexpose.api.APISession.APISupportedVersion;
import org.rapid7.nexpose.api.generators.IContentGenerator; | /**
* Copyright (C) 2012, Rapid7 LLC, Boston, MA, USA.
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.rapid7.nexpose.api;
/**
* Encapsulates the TicketDeleteRequest NeXpose API request.
*
* @author Murali Rongali
*/
public class TicketDeleteRequest extends TemplateAPIRequest
{
/////////////////////////////////////////////////////////////////////////
// Public methods
/////////////////////////////////////////////////////////////////////////
/**
* Constructs a ticket delete request with its associated API version
* information.
*
* @param sessionId the session to submit the request with. May not be {@code null} nor empty and must
* be a 40 character hex {@link String}.
* @param syncId the sync id to identify the response. May be {@code null}.
* @param ticketsGenerator the content generator instance. May be {@code null}.
*/ | // Path: src/main/java/org/rapid7/nexpose/api/APISession.java
// public enum APISupportedVersion
// {
// V1_0("1.0"), V1_1("1.1"), V1_2("1.2");
// private String m_version;
//
// APISupportedVersion(String value)
// {
// m_version = value;
// }
// String getVersion()
// {
// return m_version;
// }
// }
//
// Path: src/main/java/org/rapid7/nexpose/api/generators/IContentGenerator.java
// public interface IContentGenerator
// {
// /**
// * Knows how to generate content for a request.
// * @return the generated content
// */
// String toString();
// /**
// * Sets the contents of the generator that come as a parameter
// */
// void setContents(Element contents);
// }
// Path: src/main/java/org/rapid7/nexpose/api/TicketDeleteRequest.java
import org.rapid7.nexpose.api.APISession.APISupportedVersion;
import org.rapid7.nexpose.api.generators.IContentGenerator;
/**
* Copyright (C) 2012, Rapid7 LLC, Boston, MA, USA.
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.rapid7.nexpose.api;
/**
* Encapsulates the TicketDeleteRequest NeXpose API request.
*
* @author Murali Rongali
*/
public class TicketDeleteRequest extends TemplateAPIRequest
{
/////////////////////////////////////////////////////////////////////////
// Public methods
/////////////////////////////////////////////////////////////////////////
/**
* Constructs a ticket delete request with its associated API version
* information.
*
* @param sessionId the session to submit the request with. May not be {@code null} nor empty and must
* be a 40 character hex {@link String}.
* @param syncId the sync id to identify the response. May be {@code null}.
* @param ticketsGenerator the content generator instance. May be {@code null}.
*/ | public TicketDeleteRequest(String sessionId, String syncId, IContentGenerator ticketsGenerator) |
rapid7/nexpose_java_api | src/main/java/org/rapid7/nexpose/api/TicketDeleteRequest.java | // Path: src/main/java/org/rapid7/nexpose/api/APISession.java
// public enum APISupportedVersion
// {
// V1_0("1.0"), V1_1("1.1"), V1_2("1.2");
// private String m_version;
//
// APISupportedVersion(String value)
// {
// m_version = value;
// }
// String getVersion()
// {
// return m_version;
// }
// }
//
// Path: src/main/java/org/rapid7/nexpose/api/generators/IContentGenerator.java
// public interface IContentGenerator
// {
// /**
// * Knows how to generate content for a request.
// * @return the generated content
// */
// String toString();
// /**
// * Sets the contents of the generator that come as a parameter
// */
// void setContents(Element contents);
// }
| import org.rapid7.nexpose.api.APISession.APISupportedVersion;
import org.rapid7.nexpose.api.generators.IContentGenerator; | /**
* Copyright (C) 2012, Rapid7 LLC, Boston, MA, USA.
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.rapid7.nexpose.api;
/**
* Encapsulates the TicketDeleteRequest NeXpose API request.
*
* @author Murali Rongali
*/
public class TicketDeleteRequest extends TemplateAPIRequest
{
/////////////////////////////////////////////////////////////////////////
// Public methods
/////////////////////////////////////////////////////////////////////////
/**
* Constructs a ticket delete request with its associated API version
* information.
*
* @param sessionId the session to submit the request with. May not be {@code null} nor empty and must
* be a 40 character hex {@link String}.
* @param syncId the sync id to identify the response. May be {@code null}.
* @param ticketsGenerator the content generator instance. May be {@code null}.
*/
public TicketDeleteRequest(String sessionId, String syncId, IContentGenerator ticketsGenerator)
{
super(sessionId, syncId);
set("ticketsGenerator", ticketsGenerator); | // Path: src/main/java/org/rapid7/nexpose/api/APISession.java
// public enum APISupportedVersion
// {
// V1_0("1.0"), V1_1("1.1"), V1_2("1.2");
// private String m_version;
//
// APISupportedVersion(String value)
// {
// m_version = value;
// }
// String getVersion()
// {
// return m_version;
// }
// }
//
// Path: src/main/java/org/rapid7/nexpose/api/generators/IContentGenerator.java
// public interface IContentGenerator
// {
// /**
// * Knows how to generate content for a request.
// * @return the generated content
// */
// String toString();
// /**
// * Sets the contents of the generator that come as a parameter
// */
// void setContents(Element contents);
// }
// Path: src/main/java/org/rapid7/nexpose/api/TicketDeleteRequest.java
import org.rapid7.nexpose.api.APISession.APISupportedVersion;
import org.rapid7.nexpose.api.generators.IContentGenerator;
/**
* Copyright (C) 2012, Rapid7 LLC, Boston, MA, USA.
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.rapid7.nexpose.api;
/**
* Encapsulates the TicketDeleteRequest NeXpose API request.
*
* @author Murali Rongali
*/
public class TicketDeleteRequest extends TemplateAPIRequest
{
/////////////////////////////////////////////////////////////////////////
// Public methods
/////////////////////////////////////////////////////////////////////////
/**
* Constructs a ticket delete request with its associated API version
* information.
*
* @param sessionId the session to submit the request with. May not be {@code null} nor empty and must
* be a 40 character hex {@link String}.
* @param syncId the sync id to identify the response. May be {@code null}.
* @param ticketsGenerator the content generator instance. May be {@code null}.
*/
public TicketDeleteRequest(String sessionId, String syncId, IContentGenerator ticketsGenerator)
{
super(sessionId, syncId);
set("ticketsGenerator", ticketsGenerator); | m_firstSupportedVersion = APISupportedVersion.V1_2; |
rapid7/nexpose_java_api | src/main/java/org/rapid7/nexpose/api/EngineSaveRequest.java | // Path: src/main/java/org/rapid7/nexpose/api/APISession.java
// public enum APISupportedVersion
// {
// V1_0("1.0"), V1_1("1.1"), V1_2("1.2");
// private String m_version;
//
// APISupportedVersion(String value)
// {
// m_version = value;
// }
// String getVersion()
// {
// return m_version;
// }
// }
//
// Path: src/main/java/org/rapid7/nexpose/api/generators/IContentGenerator.java
// public interface IContentGenerator
// {
// /**
// * Knows how to generate content for a request.
// * @return the generated content
// */
// String toString();
// /**
// * Sets the contents of the generator that come as a parameter
// */
// void setContents(Element contents);
// }
| import org.rapid7.nexpose.api.APISession.APISupportedVersion;
import org.rapid7.nexpose.api.generators.IContentGenerator; | /**
* Copyright (C) 2012, Rapid7 LLC, Boston, MA, USA.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.rapid7.nexpose.api;
/**
* Represents the EngineSaveRequest NeXpose API request.
*
* @author Leonardo Varela
*/
public class EngineSaveRequest extends TemplateAPIRequest
{
/**
* Creates a new EngineSaveRequest NeXpose API request.
*
* @param sessionId the session to be used if different from the one on the
* current APISession. useful when testing edge cases and testing in
* general.
* @param syncId the syncId to identify the request/response pair.
* @param engineConfigId the id of the engine configuration
* @param engineConfigName the name of the engine configuration.
* @param engineConfigAddress the address of the engine configuration
* @param engineConfigPort the port of the engine configuration.
* @param engineConfigPriority the priority of the engine configuration
* @param sitesGenerator the {@link IContentGenerator} of the sites within
* the engine save request.
*/
public EngineSaveRequest(
String sessionId,
String syncId,
String engineConfigId,
String engineConfigName,
String engineConfigAddress,
String engineConfigPort,
String engineConfigPriority,
String engineConfigScope, | // Path: src/main/java/org/rapid7/nexpose/api/APISession.java
// public enum APISupportedVersion
// {
// V1_0("1.0"), V1_1("1.1"), V1_2("1.2");
// private String m_version;
//
// APISupportedVersion(String value)
// {
// m_version = value;
// }
// String getVersion()
// {
// return m_version;
// }
// }
//
// Path: src/main/java/org/rapid7/nexpose/api/generators/IContentGenerator.java
// public interface IContentGenerator
// {
// /**
// * Knows how to generate content for a request.
// * @return the generated content
// */
// String toString();
// /**
// * Sets the contents of the generator that come as a parameter
// */
// void setContents(Element contents);
// }
// Path: src/main/java/org/rapid7/nexpose/api/EngineSaveRequest.java
import org.rapid7.nexpose.api.APISession.APISupportedVersion;
import org.rapid7.nexpose.api.generators.IContentGenerator;
/**
* Copyright (C) 2012, Rapid7 LLC, Boston, MA, USA.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.rapid7.nexpose.api;
/**
* Represents the EngineSaveRequest NeXpose API request.
*
* @author Leonardo Varela
*/
public class EngineSaveRequest extends TemplateAPIRequest
{
/**
* Creates a new EngineSaveRequest NeXpose API request.
*
* @param sessionId the session to be used if different from the one on the
* current APISession. useful when testing edge cases and testing in
* general.
* @param syncId the syncId to identify the request/response pair.
* @param engineConfigId the id of the engine configuration
* @param engineConfigName the name of the engine configuration.
* @param engineConfigAddress the address of the engine configuration
* @param engineConfigPort the port of the engine configuration.
* @param engineConfigPriority the priority of the engine configuration
* @param sitesGenerator the {@link IContentGenerator} of the sites within
* the engine save request.
*/
public EngineSaveRequest(
String sessionId,
String syncId,
String engineConfigId,
String engineConfigName,
String engineConfigAddress,
String engineConfigPort,
String engineConfigPriority,
String engineConfigScope, | IContentGenerator sitesGenerator) |
rapid7/nexpose_java_api | src/main/java/org/rapid7/nexpose/api/EngineSaveRequest.java | // Path: src/main/java/org/rapid7/nexpose/api/APISession.java
// public enum APISupportedVersion
// {
// V1_0("1.0"), V1_1("1.1"), V1_2("1.2");
// private String m_version;
//
// APISupportedVersion(String value)
// {
// m_version = value;
// }
// String getVersion()
// {
// return m_version;
// }
// }
//
// Path: src/main/java/org/rapid7/nexpose/api/generators/IContentGenerator.java
// public interface IContentGenerator
// {
// /**
// * Knows how to generate content for a request.
// * @return the generated content
// */
// String toString();
// /**
// * Sets the contents of the generator that come as a parameter
// */
// void setContents(Element contents);
// }
| import org.rapid7.nexpose.api.APISession.APISupportedVersion;
import org.rapid7.nexpose.api.generators.IContentGenerator; | /**
* Copyright (C) 2012, Rapid7 LLC, Boston, MA, USA.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.rapid7.nexpose.api;
/**
* Represents the EngineSaveRequest NeXpose API request.
*
* @author Leonardo Varela
*/
public class EngineSaveRequest extends TemplateAPIRequest
{
/**
* Creates a new EngineSaveRequest NeXpose API request.
*
* @param sessionId the session to be used if different from the one on the
* current APISession. useful when testing edge cases and testing in
* general.
* @param syncId the syncId to identify the request/response pair.
* @param engineConfigId the id of the engine configuration
* @param engineConfigName the name of the engine configuration.
* @param engineConfigAddress the address of the engine configuration
* @param engineConfigPort the port of the engine configuration.
* @param engineConfigPriority the priority of the engine configuration
* @param sitesGenerator the {@link IContentGenerator} of the sites within
* the engine save request.
*/
public EngineSaveRequest(
String sessionId,
String syncId,
String engineConfigId,
String engineConfigName,
String engineConfigAddress,
String engineConfigPort,
String engineConfigPriority,
String engineConfigScope,
IContentGenerator sitesGenerator)
{
super(sessionId, syncId);
set("engineConfigId", engineConfigId);
set("engineConfigName", engineConfigName);
set("engineConfigAddress", engineConfigAddress);
set("engineConfigPort", engineConfigPort);
set("engineConfigPriority", engineConfigPriority);
set("engineConfigScope", engineConfigScope);
set("sitesGenerator", sitesGenerator); | // Path: src/main/java/org/rapid7/nexpose/api/APISession.java
// public enum APISupportedVersion
// {
// V1_0("1.0"), V1_1("1.1"), V1_2("1.2");
// private String m_version;
//
// APISupportedVersion(String value)
// {
// m_version = value;
// }
// String getVersion()
// {
// return m_version;
// }
// }
//
// Path: src/main/java/org/rapid7/nexpose/api/generators/IContentGenerator.java
// public interface IContentGenerator
// {
// /**
// * Knows how to generate content for a request.
// * @return the generated content
// */
// String toString();
// /**
// * Sets the contents of the generator that come as a parameter
// */
// void setContents(Element contents);
// }
// Path: src/main/java/org/rapid7/nexpose/api/EngineSaveRequest.java
import org.rapid7.nexpose.api.APISession.APISupportedVersion;
import org.rapid7.nexpose.api.generators.IContentGenerator;
/**
* Copyright (C) 2012, Rapid7 LLC, Boston, MA, USA.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.rapid7.nexpose.api;
/**
* Represents the EngineSaveRequest NeXpose API request.
*
* @author Leonardo Varela
*/
public class EngineSaveRequest extends TemplateAPIRequest
{
/**
* Creates a new EngineSaveRequest NeXpose API request.
*
* @param sessionId the session to be used if different from the one on the
* current APISession. useful when testing edge cases and testing in
* general.
* @param syncId the syncId to identify the request/response pair.
* @param engineConfigId the id of the engine configuration
* @param engineConfigName the name of the engine configuration.
* @param engineConfigAddress the address of the engine configuration
* @param engineConfigPort the port of the engine configuration.
* @param engineConfigPriority the priority of the engine configuration
* @param sitesGenerator the {@link IContentGenerator} of the sites within
* the engine save request.
*/
public EngineSaveRequest(
String sessionId,
String syncId,
String engineConfigId,
String engineConfigName,
String engineConfigAddress,
String engineConfigPort,
String engineConfigPriority,
String engineConfigScope,
IContentGenerator sitesGenerator)
{
super(sessionId, syncId);
set("engineConfigId", engineConfigId);
set("engineConfigName", engineConfigName);
set("engineConfigAddress", engineConfigAddress);
set("engineConfigPort", engineConfigPort);
set("engineConfigPriority", engineConfigPriority);
set("engineConfigScope", engineConfigScope);
set("sitesGenerator", sitesGenerator); | m_firstSupportedVersion = APISupportedVersion.V1_2; |
rapid7/nexpose_java_api | src/main/java/org/rapid7/nexpose/api/SiteDeviceListingRequest.java | // Path: src/main/java/org/rapid7/nexpose/api/APISession.java
// public enum APISupportedVersion
// {
// V1_0("1.0"), V1_1("1.1"), V1_2("1.2");
// private String m_version;
//
// APISupportedVersion(String value)
// {
// m_version = value;
// }
// String getVersion()
// {
// return m_version;
// }
// }
| import org.rapid7.nexpose.api.APISession.APISupportedVersion; | /**
* Copyright (C) 2012, Rapid7 LLC, Boston, MA, USA.
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.rapid7.nexpose.api;
/**
* Encapsulates the SiteListingRequest NeXpose API request.
*
* @author Leonardo Varela
*/
public class SiteDeviceListingRequest extends TemplateAPIRequest
{
/**
* Creates a new SiteListingRequest NeXpose API Request. Sets the first API
* supported version to 1.0 and the last supported version to 1.1.
*
* NOTE: All parameters are strings or generators, since we want to be able
* to test edge cases and simulate incorrect usage of the tool for robustness
*
* @param sessionId the session to be used if different from the current
* acquired one (You acquire one when you authenticate correctly with
* the login method in the {@link APISession} class). This is a
* String of 40 characters.
* @param syncId the synchronization id to identify the response associated
* with the response in asynchronous environments. It can be any
* string. This field is optional.
* @param siteId a positive integer that represents the id of the site to
* delete.
*/
public SiteDeviceListingRequest(String sessionId, String syncId, String siteId)
{
super(sessionId, syncId);
set("siteId", siteId); | // Path: src/main/java/org/rapid7/nexpose/api/APISession.java
// public enum APISupportedVersion
// {
// V1_0("1.0"), V1_1("1.1"), V1_2("1.2");
// private String m_version;
//
// APISupportedVersion(String value)
// {
// m_version = value;
// }
// String getVersion()
// {
// return m_version;
// }
// }
// Path: src/main/java/org/rapid7/nexpose/api/SiteDeviceListingRequest.java
import org.rapid7.nexpose.api.APISession.APISupportedVersion;
/**
* Copyright (C) 2012, Rapid7 LLC, Boston, MA, USA.
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.rapid7.nexpose.api;
/**
* Encapsulates the SiteListingRequest NeXpose API request.
*
* @author Leonardo Varela
*/
public class SiteDeviceListingRequest extends TemplateAPIRequest
{
/**
* Creates a new SiteListingRequest NeXpose API Request. Sets the first API
* supported version to 1.0 and the last supported version to 1.1.
*
* NOTE: All parameters are strings or generators, since we want to be able
* to test edge cases and simulate incorrect usage of the tool for robustness
*
* @param sessionId the session to be used if different from the current
* acquired one (You acquire one when you authenticate correctly with
* the login method in the {@link APISession} class). This is a
* String of 40 characters.
* @param syncId the synchronization id to identify the response associated
* with the response in asynchronous environments. It can be any
* string. This field is optional.
* @param siteId a positive integer that represents the id of the site to
* delete.
*/
public SiteDeviceListingRequest(String sessionId, String syncId, String siteId)
{
super(sessionId, syncId);
set("siteId", siteId); | m_firstSupportedVersion = APISupportedVersion.V1_0; |
rapid7/nexpose_java_api | src/main/java/org/rapid7/nexpose/api/VulnerabilityExceptionCreateRequest.java | // Path: src/main/java/org/rapid7/nexpose/api/APISession.java
// public enum APISupportedVersion
// {
// V1_0("1.0"), V1_1("1.1"), V1_2("1.2");
// private String m_version;
//
// APISupportedVersion(String value)
// {
// m_version = value;
// }
// String getVersion()
// {
// return m_version;
// }
// }
| import org.rapid7.nexpose.api.APISession.APISupportedVersion; | /**
* Copyright (C) 2012, Rapid7 LLC, Boston, MA, USA.
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.rapid7.nexpose.api;
/**
* Encapsulates the {@link VulnerabilityExceptionCreateRequest} Nexpose API request.
*
* @author Murali Rongali
*/
public class VulnerabilityExceptionCreateRequest extends TemplateAPIRequest
{
/////////////////////////////////////////////////////////////////////////
// Public methods
/////////////////////////////////////////////////////////////////////////
/**
* Constructs a {@link VulnerabilityExceptionCreateRequest} with its associated API version
* information.
*
* @param sessionId the session to submit the request with. May not be {@code null} nor empty and must
* be a 40 character hex {@link String}.
* @param syncId the sync id to identify the response. May be {@code null}.
* @param vuldId the id of the Vulnerability.
* @param reason the reason to create vulnaerabilty exception. must be set to either "False Positive",
* "Compensating Control," "Acceptable Use," "Acceptable Risk," or "Other".
* @param scope the scope of the Vulnerability exception.
* @param comment the comment for the vulnerabilty exception.
*/
public VulnerabilityExceptionCreateRequest(String sessionId, String syncId, String vulnId, String reason, String scope, String comment)
{
super(sessionId, syncId);
set("vulnId", vulnId);
set("reason", reason);
set("scope", scope);
set("comment", comment); | // Path: src/main/java/org/rapid7/nexpose/api/APISession.java
// public enum APISupportedVersion
// {
// V1_0("1.0"), V1_1("1.1"), V1_2("1.2");
// private String m_version;
//
// APISupportedVersion(String value)
// {
// m_version = value;
// }
// String getVersion()
// {
// return m_version;
// }
// }
// Path: src/main/java/org/rapid7/nexpose/api/VulnerabilityExceptionCreateRequest.java
import org.rapid7.nexpose.api.APISession.APISupportedVersion;
/**
* Copyright (C) 2012, Rapid7 LLC, Boston, MA, USA.
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.rapid7.nexpose.api;
/**
* Encapsulates the {@link VulnerabilityExceptionCreateRequest} Nexpose API request.
*
* @author Murali Rongali
*/
public class VulnerabilityExceptionCreateRequest extends TemplateAPIRequest
{
/////////////////////////////////////////////////////////////////////////
// Public methods
/////////////////////////////////////////////////////////////////////////
/**
* Constructs a {@link VulnerabilityExceptionCreateRequest} with its associated API version
* information.
*
* @param sessionId the session to submit the request with. May not be {@code null} nor empty and must
* be a 40 character hex {@link String}.
* @param syncId the sync id to identify the response. May be {@code null}.
* @param vuldId the id of the Vulnerability.
* @param reason the reason to create vulnaerabilty exception. must be set to either "False Positive",
* "Compensating Control," "Acceptable Use," "Acceptable Risk," or "Other".
* @param scope the scope of the Vulnerability exception.
* @param comment the comment for the vulnerabilty exception.
*/
public VulnerabilityExceptionCreateRequest(String sessionId, String syncId, String vulnId, String reason, String scope, String comment)
{
super(sessionId, syncId);
set("vulnId", vulnId);
set("reason", reason);
set("scope", scope);
set("comment", comment); | m_firstSupportedVersion = APISupportedVersion.V1_2; |
rapid7/nexpose_java_api | src/main/java/org/rapid7/nexpose/api/SiteScanHistoryRequest.java | // Path: src/main/java/org/rapid7/nexpose/api/APISession.java
// public enum APISupportedVersion
// {
// V1_0("1.0"), V1_1("1.1"), V1_2("1.2");
// private String m_version;
//
// APISupportedVersion(String value)
// {
// m_version = value;
// }
// String getVersion()
// {
// return m_version;
// }
// }
| import org.rapid7.nexpose.api.APISession.APISupportedVersion; | /**
* Copyright (C) 2012, Rapid7 LLC, Boston, MA, USA.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.rapid7.nexpose.api;
/**
* Encapsulates the SiteScanHistoryRequest NeXpose API request.
*
* @author Murali Rongali
*/
public class SiteScanHistoryRequest extends TemplateAPIRequest
{
/**
* Creates a new SiteScanHistoryRequest NeXpose API request.
*
* @param sessionID the session to be used if different from the one on the
* current APISession. useful when testing edge cases and testing in
* general.
* @param syncID the syncId to identify the request/response pair.
* @param siteID the id of the site.
*/
public SiteScanHistoryRequest(String sessionID, String syncID, String siteID)
{
super(sessionID, syncID);
set("siteId", siteID); | // Path: src/main/java/org/rapid7/nexpose/api/APISession.java
// public enum APISupportedVersion
// {
// V1_0("1.0"), V1_1("1.1"), V1_2("1.2");
// private String m_version;
//
// APISupportedVersion(String value)
// {
// m_version = value;
// }
// String getVersion()
// {
// return m_version;
// }
// }
// Path: src/main/java/org/rapid7/nexpose/api/SiteScanHistoryRequest.java
import org.rapid7.nexpose.api.APISession.APISupportedVersion;
/**
* Copyright (C) 2012, Rapid7 LLC, Boston, MA, USA.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.rapid7.nexpose.api;
/**
* Encapsulates the SiteScanHistoryRequest NeXpose API request.
*
* @author Murali Rongali
*/
public class SiteScanHistoryRequest extends TemplateAPIRequest
{
/**
* Creates a new SiteScanHistoryRequest NeXpose API request.
*
* @param sessionID the session to be used if different from the one on the
* current APISession. useful when testing edge cases and testing in
* general.
* @param syncID the syncId to identify the request/response pair.
* @param siteID the id of the site.
*/
public SiteScanHistoryRequest(String sessionID, String syncID, String siteID)
{
super(sessionID, syncID);
set("siteId", siteID); | m_firstSupportedVersion = APISupportedVersion.V1_0; |
rapid7/nexpose_java_api | src/main/java/org/rapid7/nexpose/api/MultiTenantUserCreateRequest.java | // Path: src/main/java/org/rapid7/nexpose/api/APISession.java
// public enum APISupportedVersion
// {
// V1_0("1.0"), V1_1("1.1"), V1_2("1.2");
// private String m_version;
//
// APISupportedVersion(String value)
// {
// m_version = value;
// }
// String getVersion()
// {
// return m_version;
// }
// }
//
// Path: src/main/java/org/rapid7/nexpose/api/generators/IContentGenerator.java
// public interface IContentGenerator
// {
// /**
// * Knows how to generate content for a request.
// * @return the generated content
// */
// String toString();
// /**
// * Sets the contents of the generator that come as a parameter
// */
// void setContents(Element contents);
// }
| import org.rapid7.nexpose.api.APISession.APISupportedVersion;
import org.rapid7.nexpose.api.generators.IContentGenerator; | /**
* Copyright (C) 2012, Rapid7 LLC, Boston, MA, USA.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.rapid7.nexpose.api;
/**
* Represents the MultiTenantUserCreateRequest NeXpose API request.
*
* @author Leonardo Varela
*/
public class MultiTenantUserCreateRequest extends TemplateAPIRequest
{
/////////////////////////////////////////////////////////////////////////
// Public methods
/////////////////////////////////////////////////////////////////////////
/**
* Creates a new MultiTenantUserCreateRequest NeXpose API Request. Sets the first API supported version to 1.2 and
* the last supported version to 1.2.
*
* NOTE: All parameters are strings or generators, since we want to be able to test edge cases and simulate incorrect
* usage of the tool for robustness
*
* @param sessionId the session to be used if different from the currently acquired one. This is a String of 40
* characters.
* @param syncId The String that uniquely identifies the response associated with the request sent. This field is
* optional.
* @param fullName The full name of the Multi Tenant User.
* @param authsrcid The authentication source used by the Multi Tenant User.
* @param email The email of the Multi Tenant User.
* @param password The password of the Multi Tenant User.
* @param enabled whether the Multi Tenant User is enabled or not.
* @param userName the user name or diplay name of the Multi Tenant User.
* @param superuser the flag that tells whether a Multi Tenant User is a super user or not.
* @param siloAccessGenerator the generator of the silos accesses.
*/
public MultiTenantUserCreateRequest(
String sessionId,
String syncId,
String fullName,
String authsrcid,
String email,
String password,
String enabled,
String userName,
String superuser, | // Path: src/main/java/org/rapid7/nexpose/api/APISession.java
// public enum APISupportedVersion
// {
// V1_0("1.0"), V1_1("1.1"), V1_2("1.2");
// private String m_version;
//
// APISupportedVersion(String value)
// {
// m_version = value;
// }
// String getVersion()
// {
// return m_version;
// }
// }
//
// Path: src/main/java/org/rapid7/nexpose/api/generators/IContentGenerator.java
// public interface IContentGenerator
// {
// /**
// * Knows how to generate content for a request.
// * @return the generated content
// */
// String toString();
// /**
// * Sets the contents of the generator that come as a parameter
// */
// void setContents(Element contents);
// }
// Path: src/main/java/org/rapid7/nexpose/api/MultiTenantUserCreateRequest.java
import org.rapid7.nexpose.api.APISession.APISupportedVersion;
import org.rapid7.nexpose.api.generators.IContentGenerator;
/**
* Copyright (C) 2012, Rapid7 LLC, Boston, MA, USA.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.rapid7.nexpose.api;
/**
* Represents the MultiTenantUserCreateRequest NeXpose API request.
*
* @author Leonardo Varela
*/
public class MultiTenantUserCreateRequest extends TemplateAPIRequest
{
/////////////////////////////////////////////////////////////////////////
// Public methods
/////////////////////////////////////////////////////////////////////////
/**
* Creates a new MultiTenantUserCreateRequest NeXpose API Request. Sets the first API supported version to 1.2 and
* the last supported version to 1.2.
*
* NOTE: All parameters are strings or generators, since we want to be able to test edge cases and simulate incorrect
* usage of the tool for robustness
*
* @param sessionId the session to be used if different from the currently acquired one. This is a String of 40
* characters.
* @param syncId The String that uniquely identifies the response associated with the request sent. This field is
* optional.
* @param fullName The full name of the Multi Tenant User.
* @param authsrcid The authentication source used by the Multi Tenant User.
* @param email The email of the Multi Tenant User.
* @param password The password of the Multi Tenant User.
* @param enabled whether the Multi Tenant User is enabled or not.
* @param userName the user name or diplay name of the Multi Tenant User.
* @param superuser the flag that tells whether a Multi Tenant User is a super user or not.
* @param siloAccessGenerator the generator of the silos accesses.
*/
public MultiTenantUserCreateRequest(
String sessionId,
String syncId,
String fullName,
String authsrcid,
String email,
String password,
String enabled,
String userName,
String superuser, | IContentGenerator siloAccessGenerator) |
rapid7/nexpose_java_api | src/main/java/org/rapid7/nexpose/api/MultiTenantUserCreateRequest.java | // Path: src/main/java/org/rapid7/nexpose/api/APISession.java
// public enum APISupportedVersion
// {
// V1_0("1.0"), V1_1("1.1"), V1_2("1.2");
// private String m_version;
//
// APISupportedVersion(String value)
// {
// m_version = value;
// }
// String getVersion()
// {
// return m_version;
// }
// }
//
// Path: src/main/java/org/rapid7/nexpose/api/generators/IContentGenerator.java
// public interface IContentGenerator
// {
// /**
// * Knows how to generate content for a request.
// * @return the generated content
// */
// String toString();
// /**
// * Sets the contents of the generator that come as a parameter
// */
// void setContents(Element contents);
// }
| import org.rapid7.nexpose.api.APISession.APISupportedVersion;
import org.rapid7.nexpose.api.generators.IContentGenerator; | /**
* Copyright (C) 2012, Rapid7 LLC, Boston, MA, USA.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.rapid7.nexpose.api;
/**
* Represents the MultiTenantUserCreateRequest NeXpose API request.
*
* @author Leonardo Varela
*/
public class MultiTenantUserCreateRequest extends TemplateAPIRequest
{
/////////////////////////////////////////////////////////////////////////
// Public methods
/////////////////////////////////////////////////////////////////////////
/**
* Creates a new MultiTenantUserCreateRequest NeXpose API Request. Sets the first API supported version to 1.2 and
* the last supported version to 1.2.
*
* NOTE: All parameters are strings or generators, since we want to be able to test edge cases and simulate incorrect
* usage of the tool for robustness
*
* @param sessionId the session to be used if different from the currently acquired one. This is a String of 40
* characters.
* @param syncId The String that uniquely identifies the response associated with the request sent. This field is
* optional.
* @param fullName The full name of the Multi Tenant User.
* @param authsrcid The authentication source used by the Multi Tenant User.
* @param email The email of the Multi Tenant User.
* @param password The password of the Multi Tenant User.
* @param enabled whether the Multi Tenant User is enabled or not.
* @param userName the user name or diplay name of the Multi Tenant User.
* @param superuser the flag that tells whether a Multi Tenant User is a super user or not.
* @param siloAccessGenerator the generator of the silos accesses.
*/
public MultiTenantUserCreateRequest(
String sessionId,
String syncId,
String fullName,
String authsrcid,
String email,
String password,
String enabled,
String userName,
String superuser,
IContentGenerator siloAccessGenerator)
{
super(sessionId, syncId);
set("authSrcId", authsrcid);
set("email", email);
set("password", password);
set("enabled", enabled);
set("full-name", fullName);
set("user-name", userName);
set("superuser", superuser);
set("siloAccessGenerator", siloAccessGenerator); | // Path: src/main/java/org/rapid7/nexpose/api/APISession.java
// public enum APISupportedVersion
// {
// V1_0("1.0"), V1_1("1.1"), V1_2("1.2");
// private String m_version;
//
// APISupportedVersion(String value)
// {
// m_version = value;
// }
// String getVersion()
// {
// return m_version;
// }
// }
//
// Path: src/main/java/org/rapid7/nexpose/api/generators/IContentGenerator.java
// public interface IContentGenerator
// {
// /**
// * Knows how to generate content for a request.
// * @return the generated content
// */
// String toString();
// /**
// * Sets the contents of the generator that come as a parameter
// */
// void setContents(Element contents);
// }
// Path: src/main/java/org/rapid7/nexpose/api/MultiTenantUserCreateRequest.java
import org.rapid7.nexpose.api.APISession.APISupportedVersion;
import org.rapid7.nexpose.api.generators.IContentGenerator;
/**
* Copyright (C) 2012, Rapid7 LLC, Boston, MA, USA.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.rapid7.nexpose.api;
/**
* Represents the MultiTenantUserCreateRequest NeXpose API request.
*
* @author Leonardo Varela
*/
public class MultiTenantUserCreateRequest extends TemplateAPIRequest
{
/////////////////////////////////////////////////////////////////////////
// Public methods
/////////////////////////////////////////////////////////////////////////
/**
* Creates a new MultiTenantUserCreateRequest NeXpose API Request. Sets the first API supported version to 1.2 and
* the last supported version to 1.2.
*
* NOTE: All parameters are strings or generators, since we want to be able to test edge cases and simulate incorrect
* usage of the tool for robustness
*
* @param sessionId the session to be used if different from the currently acquired one. This is a String of 40
* characters.
* @param syncId The String that uniquely identifies the response associated with the request sent. This field is
* optional.
* @param fullName The full name of the Multi Tenant User.
* @param authsrcid The authentication source used by the Multi Tenant User.
* @param email The email of the Multi Tenant User.
* @param password The password of the Multi Tenant User.
* @param enabled whether the Multi Tenant User is enabled or not.
* @param userName the user name or diplay name of the Multi Tenant User.
* @param superuser the flag that tells whether a Multi Tenant User is a super user or not.
* @param siloAccessGenerator the generator of the silos accesses.
*/
public MultiTenantUserCreateRequest(
String sessionId,
String syncId,
String fullName,
String authsrcid,
String email,
String password,
String enabled,
String userName,
String superuser,
IContentGenerator siloAccessGenerator)
{
super(sessionId, syncId);
set("authSrcId", authsrcid);
set("email", email);
set("password", password);
set("enabled", enabled);
set("full-name", fullName);
set("user-name", userName);
set("superuser", superuser);
set("siloAccessGenerator", siloAccessGenerator); | m_firstSupportedVersion = APISupportedVersion.V1_2; |
rapid7/nexpose_java_api | src/main/java/org/rapid7/nexpose/api/DiscoveryConnectionUpdateRequest.java | // Path: src/main/java/org/rapid7/nexpose/api/APISession.java
// public enum APISupportedVersion
// {
// V1_0("1.0"), V1_1("1.1"), V1_2("1.2");
// private String m_version;
//
// APISupportedVersion(String value)
// {
// m_version = value;
// }
// String getVersion()
// {
// return m_version;
// }
// }
| import org.rapid7.nexpose.api.APISession.APISupportedVersion; | /**
* Copyright (C) 2012, Rapid7 LLC, Boston, MA, USA.
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.rapid7.nexpose.api;
/**
* Encapsulates the {@link DiscoveryConnectionUpdateRequest} Nexpose API request.
*
* @author Murali Rongali
*/
public class DiscoveryConnectionUpdateRequest extends TemplateAPIRequest
{
/////////////////////////////////////////////////////////////////////////
// Public methods
/////////////////////////////////////////////////////////////////////////
/**
* Constructs a {@link DiscoveryConnectionUpdateRequest} with its associated API version information.
*
* @param sessionId the session to submit the request with. May not be {@code null} nor empty and must
* be a 40 character hex {@link String}.
* @param syncId the sync id to identify the response. May be {@code null}.
* @param userName the String that represents the login name to connect to the target device.
* @param protocol the String that represents the protocol to connect to the target device.
* @param port the String that represents the port to connect to the target device.
* @param address the String that represents the address of the target device.
* @param name the String that represents the name of the discovery connection.
* @param password the String that represents the password to connect to the target device.
* @param connectionID the id of the DiscoveryConnection.
*/
public DiscoveryConnectionUpdateRequest(
String sessionId,
String syncId,
String userName,
String protocol,
String port,
String address,
String name,
String password,
String connectionID)
{
super(sessionId, syncId);
set("userName", userName);
set("protocol", protocol);
set("port", port);
set("address", address);
set("name", name);
set("password", password);
set("connectionID", connectionID); | // Path: src/main/java/org/rapid7/nexpose/api/APISession.java
// public enum APISupportedVersion
// {
// V1_0("1.0"), V1_1("1.1"), V1_2("1.2");
// private String m_version;
//
// APISupportedVersion(String value)
// {
// m_version = value;
// }
// String getVersion()
// {
// return m_version;
// }
// }
// Path: src/main/java/org/rapid7/nexpose/api/DiscoveryConnectionUpdateRequest.java
import org.rapid7.nexpose.api.APISession.APISupportedVersion;
/**
* Copyright (C) 2012, Rapid7 LLC, Boston, MA, USA.
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.rapid7.nexpose.api;
/**
* Encapsulates the {@link DiscoveryConnectionUpdateRequest} Nexpose API request.
*
* @author Murali Rongali
*/
public class DiscoveryConnectionUpdateRequest extends TemplateAPIRequest
{
/////////////////////////////////////////////////////////////////////////
// Public methods
/////////////////////////////////////////////////////////////////////////
/**
* Constructs a {@link DiscoveryConnectionUpdateRequest} with its associated API version information.
*
* @param sessionId the session to submit the request with. May not be {@code null} nor empty and must
* be a 40 character hex {@link String}.
* @param syncId the sync id to identify the response. May be {@code null}.
* @param userName the String that represents the login name to connect to the target device.
* @param protocol the String that represents the protocol to connect to the target device.
* @param port the String that represents the port to connect to the target device.
* @param address the String that represents the address of the target device.
* @param name the String that represents the name of the discovery connection.
* @param password the String that represents the password to connect to the target device.
* @param connectionID the id of the DiscoveryConnection.
*/
public DiscoveryConnectionUpdateRequest(
String sessionId,
String syncId,
String userName,
String protocol,
String port,
String address,
String name,
String password,
String connectionID)
{
super(sessionId, syncId);
set("userName", userName);
set("protocol", protocol);
set("port", port);
set("address", address);
set("name", name);
set("password", password);
set("connectionID", connectionID); | m_firstSupportedVersion = APISupportedVersion.V1_2; |
rapid7/nexpose_java_api | src/main/java/org/rapid7/nexpose/api/SystemInformationRequest.java | // Path: src/main/java/org/rapid7/nexpose/api/APISession.java
// public enum APISupportedVersion
// {
// V1_0("1.0"), V1_1("1.1"), V1_2("1.2");
// private String m_version;
//
// APISupportedVersion(String value)
// {
// m_version = value;
// }
// String getVersion()
// {
// return m_version;
// }
// }
| import org.rapid7.nexpose.api.APISession.APISupportedVersion; | /**
* Copyright (C) 2012, Rapid7 LLC, Boston, MA, USA.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.rapid7.nexpose.api;
/**
* Encapsulates the SystemInformationRequest NeXpose API request.
*
* @author Murali Rongali
*/
public class SystemInformationRequest extends TemplateAPIRequest
{
/**
* Creates a new SystemInformationRequest NeXpose API request.
*
* @param sessionId the session to be used if different from the one on the
* current APISession. useful when testing edge cases and testing in
* general.
* @param syncId the syncId to identify the request/response pair.
*/
public SystemInformationRequest(String sessionID, String syncID)
{
super(sessionID, syncID); | // Path: src/main/java/org/rapid7/nexpose/api/APISession.java
// public enum APISupportedVersion
// {
// V1_0("1.0"), V1_1("1.1"), V1_2("1.2");
// private String m_version;
//
// APISupportedVersion(String value)
// {
// m_version = value;
// }
// String getVersion()
// {
// return m_version;
// }
// }
// Path: src/main/java/org/rapid7/nexpose/api/SystemInformationRequest.java
import org.rapid7.nexpose.api.APISession.APISupportedVersion;
/**
* Copyright (C) 2012, Rapid7 LLC, Boston, MA, USA.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.rapid7.nexpose.api;
/**
* Encapsulates the SystemInformationRequest NeXpose API request.
*
* @author Murali Rongali
*/
public class SystemInformationRequest extends TemplateAPIRequest
{
/**
* Creates a new SystemInformationRequest NeXpose API request.
*
* @param sessionId the session to be used if different from the one on the
* current APISession. useful when testing edge cases and testing in
* general.
* @param syncId the syncId to identify the request/response pair.
*/
public SystemInformationRequest(String sessionID, String syncID)
{
super(sessionID, syncID); | m_firstSupportedVersion = APISupportedVersion.V1_0; |
rapid7/nexpose_java_api | src/main/java/org/rapid7/nexpose/api/AssetGroupListingRequest.java | // Path: src/main/java/org/rapid7/nexpose/api/APISession.java
// public enum APISupportedVersion
// {
// V1_0("1.0"), V1_1("1.1"), V1_2("1.2");
// private String m_version;
//
// APISupportedVersion(String value)
// {
// m_version = value;
// }
// String getVersion()
// {
// return m_version;
// }
// }
| import org.rapid7.nexpose.api.APISession.APISupportedVersion; | /**
* Copyright (C) 2012, Rapid7 LLC, Boston, MA, USA.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.rapid7.nexpose.api;
/**
* Encapsulates the AssetGroupListingRequest NeXpose API request.
*
* @author Leonardo Varela
*/
public class AssetGroupListingRequest extends TemplateAPIRequest
{
/////////////////////////////////////////////////////////////////////////
// Public methods
/////////////////////////////////////////////////////////////////////////
/**
* Creates a new AssetGroupListingRequest NeXpose API request.
*
* @param sessionId the session to be used if different from the one on the
* current APISession. useful when testing edge cases and testing in
* general.
* @param syncId the syncId to identify the request/response pair.
*/
public AssetGroupListingRequest(String sessionId, String syncId)
{
super(sessionId, syncId); | // Path: src/main/java/org/rapid7/nexpose/api/APISession.java
// public enum APISupportedVersion
// {
// V1_0("1.0"), V1_1("1.1"), V1_2("1.2");
// private String m_version;
//
// APISupportedVersion(String value)
// {
// m_version = value;
// }
// String getVersion()
// {
// return m_version;
// }
// }
// Path: src/main/java/org/rapid7/nexpose/api/AssetGroupListingRequest.java
import org.rapid7.nexpose.api.APISession.APISupportedVersion;
/**
* Copyright (C) 2012, Rapid7 LLC, Boston, MA, USA.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.rapid7.nexpose.api;
/**
* Encapsulates the AssetGroupListingRequest NeXpose API request.
*
* @author Leonardo Varela
*/
public class AssetGroupListingRequest extends TemplateAPIRequest
{
/////////////////////////////////////////////////////////////////////////
// Public methods
/////////////////////////////////////////////////////////////////////////
/**
* Creates a new AssetGroupListingRequest NeXpose API request.
*
* @param sessionId the session to be used if different from the one on the
* current APISession. useful when testing edge cases and testing in
* general.
* @param syncId the syncId to identify the request/response pair.
*/
public AssetGroupListingRequest(String sessionId, String syncId)
{
super(sessionId, syncId); | m_firstSupportedVersion = APISupportedVersion.V1_0; |
rapid7/nexpose_java_api | src/main/java/org/rapid7/nexpose/api/domain/UserSummary.java | // Path: src/main/java/org/rapid7/nexpose/api/APIException.java
// @SuppressWarnings("serial")
// public class APIException extends Exception
// {
// /////////////////////////////////////////////////////////////////////////
// // Public methods
// /////////////////////////////////////////////////////////////////////////
//
// /**
// * Constructs a new {@link APIException} with the given error message.
// *
// * @param msg the message to create the {@link Exception} with.
// */
// public APIException(String msg)
// {
// super(msg);
// }
//
// /**
// * Constructs a new {@link APIException} with the given error message and root
// * cause.
// *
// * @param msg the message to create the exception with.
// * @param cause the cause of the {@link Exception}
// */
// public APIException(String msg, Throwable cause)
// {
// super(msg, cause);
// }
// }
| import org.rapid7.nexpose.api.APIException;
import org.rapid7.nexpose.api.BaseElement;
import org.w3c.dom.Element; | * @return the m_locked attribute which represents the fact that the user is locked or not.
*/
public boolean isLocked()
{
return m_locked;
}
/**
* Retrieves the site count of the user.
* @return the m_siteCount attribute which represents the count of sites associated with the user.
*/
public int getSiteCount()
{
return m_siteCount;
}
/**
* Retrieves the group count of the user.
* @return the m_groupCount attribute which represents the count of groups associated with the user.
*/
public int getGroupCount()
{
return m_groupCount;
}
/**
* Creates a summary out of an element SiteSummary
*
* @throws APIException When there is a problem parsing the element's attributes.
*/ | // Path: src/main/java/org/rapid7/nexpose/api/APIException.java
// @SuppressWarnings("serial")
// public class APIException extends Exception
// {
// /////////////////////////////////////////////////////////////////////////
// // Public methods
// /////////////////////////////////////////////////////////////////////////
//
// /**
// * Constructs a new {@link APIException} with the given error message.
// *
// * @param msg the message to create the {@link Exception} with.
// */
// public APIException(String msg)
// {
// super(msg);
// }
//
// /**
// * Constructs a new {@link APIException} with the given error message and root
// * cause.
// *
// * @param msg the message to create the exception with.
// * @param cause the cause of the {@link Exception}
// */
// public APIException(String msg, Throwable cause)
// {
// super(msg, cause);
// }
// }
// Path: src/main/java/org/rapid7/nexpose/api/domain/UserSummary.java
import org.rapid7.nexpose.api.APIException;
import org.rapid7.nexpose.api.BaseElement;
import org.w3c.dom.Element;
* @return the m_locked attribute which represents the fact that the user is locked or not.
*/
public boolean isLocked()
{
return m_locked;
}
/**
* Retrieves the site count of the user.
* @return the m_siteCount attribute which represents the count of sites associated with the user.
*/
public int getSiteCount()
{
return m_siteCount;
}
/**
* Retrieves the group count of the user.
* @return the m_groupCount attribute which represents the count of groups associated with the user.
*/
public int getGroupCount()
{
return m_groupCount;
}
/**
* Creates a summary out of an element SiteSummary
*
* @throws APIException When there is a problem parsing the element's attributes.
*/ | public UserSummary(Element siteSummaryElement) throws APIException |
rapid7/nexpose_java_api | src/main/java/org/rapid7/nexpose/api/SiloProfileListingRequest.java | // Path: src/main/java/org/rapid7/nexpose/api/APISession.java
// public enum APISupportedVersion
// {
// V1_0("1.0"), V1_1("1.1"), V1_2("1.2");
// private String m_version;
//
// APISupportedVersion(String value)
// {
// m_version = value;
// }
// String getVersion()
// {
// return m_version;
// }
// }
| import org.rapid7.nexpose.api.APISession.APISupportedVersion; | /**
* Copyright (C) 2012, Rapid7 LLC, Boston, MA, USA.
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.rapid7.nexpose.api;
/**
* The Silo profile listing request template.
*
* @author Christopher Lee.
*
*/
public class SiloProfileListingRequest extends TemplateAPIRequest
{
/**
* Constructs the profile config request.
*
* @param sessionID The session ID.
* @param syncID The sync ID.
*/
public SiloProfileListingRequest(String sessionID, String syncID)
{
super(sessionID, syncID); | // Path: src/main/java/org/rapid7/nexpose/api/APISession.java
// public enum APISupportedVersion
// {
// V1_0("1.0"), V1_1("1.1"), V1_2("1.2");
// private String m_version;
//
// APISupportedVersion(String value)
// {
// m_version = value;
// }
// String getVersion()
// {
// return m_version;
// }
// }
// Path: src/main/java/org/rapid7/nexpose/api/SiloProfileListingRequest.java
import org.rapid7.nexpose.api.APISession.APISupportedVersion;
/**
* Copyright (C) 2012, Rapid7 LLC, Boston, MA, USA.
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.rapid7.nexpose.api;
/**
* The Silo profile listing request template.
*
* @author Christopher Lee.
*
*/
public class SiloProfileListingRequest extends TemplateAPIRequest
{
/**
* Constructs the profile config request.
*
* @param sessionID The session ID.
* @param syncID The sync ID.
*/
public SiloProfileListingRequest(String sessionID, String syncID)
{
super(sessionID, syncID); | m_firstSupportedVersion = APISupportedVersion.V1_2; |
rapid7/nexpose_java_api | src/main/java/org/rapid7/nexpose/api/VulnerabilityExceptionUpdateCommentRequest.java | // Path: src/main/java/org/rapid7/nexpose/api/APISession.java
// public enum APISupportedVersion
// {
// V1_0("1.0"), V1_1("1.1"), V1_2("1.2");
// private String m_version;
//
// APISupportedVersion(String value)
// {
// m_version = value;
// }
// String getVersion()
// {
// return m_version;
// }
// }
| import org.rapid7.nexpose.api.APISession.APISupportedVersion; | /**
* Copyright (C) 2012, Rapid7 LLC, Boston, MA, USA.
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.rapid7.nexpose.api;
/**
* Encapsulates the {@link VulnerabilityExceptionUpdateCommentRequest} Nexpose API request.
*
* @author Murali Rongali
*/
public class VulnerabilityExceptionUpdateCommentRequest extends TemplateAPIRequest
{
/////////////////////////////////////////////////////////////////////////
// Public methods
/////////////////////////////////////////////////////////////////////////
/**
* Constructs a {@link VulnerabilityExceptionUpdateCommentRequest} with its associated API version
* information.
*
* @param sessionId the session to submit the request with. May not be {@code null} nor empty and must
* be a 40 character hex {@link String}.
* @param syncId the sync id to identify the response. May be {@code null}.
* @param exceptionId the id of the Vulnerability exception.
* @param reviewerComment the reviewer comment for the vulnerabilty exception.
* @param submitterComment the submitter comment for the vulnerabilty exception.
*/
public VulnerabilityExceptionUpdateCommentRequest(String sessionId, String syncId, String exceptionId, String reviewerComment, String submitterComment)
{
super(sessionId, syncId);
set("exceptionId", exceptionId);
set("reviewerComment", reviewerComment);
set("submitterComment", submitterComment); | // Path: src/main/java/org/rapid7/nexpose/api/APISession.java
// public enum APISupportedVersion
// {
// V1_0("1.0"), V1_1("1.1"), V1_2("1.2");
// private String m_version;
//
// APISupportedVersion(String value)
// {
// m_version = value;
// }
// String getVersion()
// {
// return m_version;
// }
// }
// Path: src/main/java/org/rapid7/nexpose/api/VulnerabilityExceptionUpdateCommentRequest.java
import org.rapid7.nexpose.api.APISession.APISupportedVersion;
/**
* Copyright (C) 2012, Rapid7 LLC, Boston, MA, USA.
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.rapid7.nexpose.api;
/**
* Encapsulates the {@link VulnerabilityExceptionUpdateCommentRequest} Nexpose API request.
*
* @author Murali Rongali
*/
public class VulnerabilityExceptionUpdateCommentRequest extends TemplateAPIRequest
{
/////////////////////////////////////////////////////////////////////////
// Public methods
/////////////////////////////////////////////////////////////////////////
/**
* Constructs a {@link VulnerabilityExceptionUpdateCommentRequest} with its associated API version
* information.
*
* @param sessionId the session to submit the request with. May not be {@code null} nor empty and must
* be a 40 character hex {@link String}.
* @param syncId the sync id to identify the response. May be {@code null}.
* @param exceptionId the id of the Vulnerability exception.
* @param reviewerComment the reviewer comment for the vulnerabilty exception.
* @param submitterComment the submitter comment for the vulnerabilty exception.
*/
public VulnerabilityExceptionUpdateCommentRequest(String sessionId, String syncId, String exceptionId, String reviewerComment, String submitterComment)
{
super(sessionId, syncId);
set("exceptionId", exceptionId);
set("reviewerComment", reviewerComment);
set("submitterComment", submitterComment); | m_firstSupportedVersion = APISupportedVersion.V1_2; |
rapid7/nexpose_java_api | src/main/java/org/rapid7/nexpose/api/ReportTemplateConfigRequest.java | // Path: src/main/java/org/rapid7/nexpose/api/APISession.java
// public enum APISupportedVersion
// {
// V1_0("1.0"), V1_1("1.1"), V1_2("1.2");
// private String m_version;
//
// APISupportedVersion(String value)
// {
// m_version = value;
// }
// String getVersion()
// {
// return m_version;
// }
// }
| import org.rapid7.nexpose.api.APISession.APISupportedVersion; | /**
* Copyright (C) 2012, Rapid7 LLC, Boston, MA, USA.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.rapid7.nexpose.api;
/**
* Encapsulates the ReportTemplateConfigRequest NeXpose API request.
*
* @author Murali Rongali
*/
public class ReportTemplateConfigRequest extends TemplateAPIRequest
{
/////////////////////////////////////////////////////////////////////////
// Public methods
/////////////////////////////////////////////////////////////////////////
/**
* Creates a new ReportTemplateConfigRequest NeXpose API request.
*
* @param sessionId the session to be used if different from the one on the
* current APISession. useful when testing edge cases and testing in
* general.
* @param syncId the syncId to identify the request/response pair.
* @param reportTemplateId the id of the report template to read.
*/
public ReportTemplateConfigRequest(String sessionId, String syncId, String reportTemplateId)
{
super(sessionId, syncId);
set("reportTemplateId", reportTemplateId); | // Path: src/main/java/org/rapid7/nexpose/api/APISession.java
// public enum APISupportedVersion
// {
// V1_0("1.0"), V1_1("1.1"), V1_2("1.2");
// private String m_version;
//
// APISupportedVersion(String value)
// {
// m_version = value;
// }
// String getVersion()
// {
// return m_version;
// }
// }
// Path: src/main/java/org/rapid7/nexpose/api/ReportTemplateConfigRequest.java
import org.rapid7.nexpose.api.APISession.APISupportedVersion;
/**
* Copyright (C) 2012, Rapid7 LLC, Boston, MA, USA.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.rapid7.nexpose.api;
/**
* Encapsulates the ReportTemplateConfigRequest NeXpose API request.
*
* @author Murali Rongali
*/
public class ReportTemplateConfigRequest extends TemplateAPIRequest
{
/////////////////////////////////////////////////////////////////////////
// Public methods
/////////////////////////////////////////////////////////////////////////
/**
* Creates a new ReportTemplateConfigRequest NeXpose API request.
*
* @param sessionId the session to be used if different from the one on the
* current APISession. useful when testing edge cases and testing in
* general.
* @param syncId the syncId to identify the request/response pair.
* @param reportTemplateId the id of the report template to read.
*/
public ReportTemplateConfigRequest(String sessionId, String syncId, String reportTemplateId)
{
super(sessionId, syncId);
set("reportTemplateId", reportTemplateId); | m_firstSupportedVersion = APISupportedVersion.V1_0; |
rapid7/nexpose_java_api | src/main/java/org/rapid7/nexpose/api/domain/SiloConfigStorage.java | // Path: src/main/java/org/rapid7/nexpose/api/generators/IContentGenerator.java
// public interface IContentGenerator
// {
// /**
// * Knows how to generate content for a request.
// * @return the generated content
// */
// String toString();
// /**
// * Sets the contents of the generator that come as a parameter
// */
// void setContents(Element contents);
// }
| import org.rapid7.nexpose.api.generators.IContentGenerator; | public void setPassword(String password)
{
m_password = password;
}
/**
* Retrieves the storage's URL.
*
* @return The value of the storage's URL.
*/
public String getURL()
{
return m_url;
}
/**
* Sets the storage's URL.
*
* @param url The value of the storage's URL to set.
*/
public void setURL(String url)
{
m_url = url;
}
/**
* Retrieves the storage's properties generator.
*
* @return The storage's properties Generator.
*/ | // Path: src/main/java/org/rapid7/nexpose/api/generators/IContentGenerator.java
// public interface IContentGenerator
// {
// /**
// * Knows how to generate content for a request.
// * @return the generated content
// */
// String toString();
// /**
// * Sets the contents of the generator that come as a parameter
// */
// void setContents(Element contents);
// }
// Path: src/main/java/org/rapid7/nexpose/api/domain/SiloConfigStorage.java
import org.rapid7.nexpose.api.generators.IContentGenerator;
public void setPassword(String password)
{
m_password = password;
}
/**
* Retrieves the storage's URL.
*
* @return The value of the storage's URL.
*/
public String getURL()
{
return m_url;
}
/**
* Sets the storage's URL.
*
* @param url The value of the storage's URL to set.
*/
public void setURL(String url)
{
m_url = url;
}
/**
* Retrieves the storage's properties generator.
*
* @return The storage's properties Generator.
*/ | public IContentGenerator getPropertiesGenerator() |
rapid7/nexpose_java_api | src/main/java/org/rapid7/nexpose/api/MultiTenantExternalUserCreateRequest.java | // Path: src/main/java/org/rapid7/nexpose/api/APISession.java
// public enum APISupportedVersion
// {
// V1_0("1.0"), V1_1("1.1"), V1_2("1.2");
// private String m_version;
//
// APISupportedVersion(String value)
// {
// m_version = value;
// }
// String getVersion()
// {
// return m_version;
// }
// }
//
// Path: src/main/java/org/rapid7/nexpose/api/generators/IContentGenerator.java
// public interface IContentGenerator
// {
// /**
// * Knows how to generate content for a request.
// * @return the generated content
// */
// String toString();
// /**
// * Sets the contents of the generator that come as a parameter
// */
// void setContents(Element contents);
// }
| import org.rapid7.nexpose.api.APISession.APISupportedVersion;
import org.rapid7.nexpose.api.generators.IContentGenerator; | /**
* Copyright (C) 2012, Rapid7 LLC, Boston, MA, USA.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.rapid7.nexpose.api;
/**
* Represents the MultiTenantUserCreateRequest NeXpose API request for user's that are authenticated by an external resource.
* The request leaves out the password field since this causes a server side failure.
*
* @author Leonardo Varela
*/
public class MultiTenantExternalUserCreateRequest extends TemplateAPIRequest
{
/////////////////////////////////////////////////////////////////////////
// Public methods
/////////////////////////////////////////////////////////////////////////
/**
* Creates a new MultiTenantUserCreateRequest NeXpose API Request. Sets the first API supported version to 1.2 and
* the last supported version to 1.2.
*
* NOTE: All parameters are strings or generators, since we want to be able to test edge cases and simulate incorrect
* usage of the tool for robustness
*
* @param sessionId the session to be used if different from the currently acquired one. This is a String of 40
* characters.
* @param syncId The String that uniquely identifies the response associated with the request sent. This field is
* optional.
* @param fullName The full name of the Multi Tenant User.
* @param authsrcid The authentication source used by the Multi Tenant User.
* @param email The email of the Multi Tenant User.
* @param enabled whether the Multi Tenant User is enabled or not.
* @param userName the user name or diplay name of the Multi Tenant User.
* @param superuser the flag that tells whether a Multi Tenant User is a super user or not.
* @param siloAccessGenerator the generator of the silos accesses.
*/
public MultiTenantExternalUserCreateRequest(
String sessionId,
String syncId,
String fullName,
String authsrcid,
String email,
String enabled,
String userName,
String superuser, | // Path: src/main/java/org/rapid7/nexpose/api/APISession.java
// public enum APISupportedVersion
// {
// V1_0("1.0"), V1_1("1.1"), V1_2("1.2");
// private String m_version;
//
// APISupportedVersion(String value)
// {
// m_version = value;
// }
// String getVersion()
// {
// return m_version;
// }
// }
//
// Path: src/main/java/org/rapid7/nexpose/api/generators/IContentGenerator.java
// public interface IContentGenerator
// {
// /**
// * Knows how to generate content for a request.
// * @return the generated content
// */
// String toString();
// /**
// * Sets the contents of the generator that come as a parameter
// */
// void setContents(Element contents);
// }
// Path: src/main/java/org/rapid7/nexpose/api/MultiTenantExternalUserCreateRequest.java
import org.rapid7.nexpose.api.APISession.APISupportedVersion;
import org.rapid7.nexpose.api.generators.IContentGenerator;
/**
* Copyright (C) 2012, Rapid7 LLC, Boston, MA, USA.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.rapid7.nexpose.api;
/**
* Represents the MultiTenantUserCreateRequest NeXpose API request for user's that are authenticated by an external resource.
* The request leaves out the password field since this causes a server side failure.
*
* @author Leonardo Varela
*/
public class MultiTenantExternalUserCreateRequest extends TemplateAPIRequest
{
/////////////////////////////////////////////////////////////////////////
// Public methods
/////////////////////////////////////////////////////////////////////////
/**
* Creates a new MultiTenantUserCreateRequest NeXpose API Request. Sets the first API supported version to 1.2 and
* the last supported version to 1.2.
*
* NOTE: All parameters are strings or generators, since we want to be able to test edge cases and simulate incorrect
* usage of the tool for robustness
*
* @param sessionId the session to be used if different from the currently acquired one. This is a String of 40
* characters.
* @param syncId The String that uniquely identifies the response associated with the request sent. This field is
* optional.
* @param fullName The full name of the Multi Tenant User.
* @param authsrcid The authentication source used by the Multi Tenant User.
* @param email The email of the Multi Tenant User.
* @param enabled whether the Multi Tenant User is enabled or not.
* @param userName the user name or diplay name of the Multi Tenant User.
* @param superuser the flag that tells whether a Multi Tenant User is a super user or not.
* @param siloAccessGenerator the generator of the silos accesses.
*/
public MultiTenantExternalUserCreateRequest(
String sessionId,
String syncId,
String fullName,
String authsrcid,
String email,
String enabled,
String userName,
String superuser, | IContentGenerator siloAccessGenerator) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.