id
stringlengths 36
36
| text
stringlengths 1
1.25M
|
---|---|
de01ed71-89ca-475f-b56b-529cda0c3c03 | ConceptDataType(String displayName) {
this.displayName = displayName;
} |
fb69c15f-0b23-4884-9886-fd393b9f1533 | @Override
public String toString() { return displayName; } |
cca68a6e-b6d3-4435-a149-a1af81dace48 | public static OpenMRSDataProperties getInstance() throws IOException {
if (instance == null) instance = new OpenMRSDataProperties();
String propertyFile = System.getenv("OPENMRS_PROP_FILE");
if (propertyFile == null) throw new IllegalArgumentException("Environment variable OPENMRS_PROP_FILE missing.");
FileInputStream propFile = new FileInputStream(propertyFile);
properties = new Properties(System.getProperties());
properties.load(propFile);
return instance;
} |
7d76a15c-b964-4dc9-bed2-47a6134d9ba3 | public String getOpenMRSUrl() {
throw new RuntimeException("Not used right now");
} |
75ea28bf-b7b5-45d7-8f33-a1c68372218b | public String getOpenMRSUser() {
return "admin";
} |
7e0b8457-54d7-45f6-aa67-0552b508aa22 | public String getOpenMRSPassword() {
return properties.getProperty("openmrs.password");
} |
696b4324-3e29-4c9f-962c-db77bbcafcef | public void migrate(Connection connection) throws Exception {
deleteTask(connection, "Update Concept Index");
deleteTask(connection, "Auto Close Visits Task");
updateGlobalProperty(connection, "scheduler.username", OpenMRSDataProperties.getInstance().getOpenMRSUser());
updateGlobalProperty(connection, "scheduler.password", OpenMRSDataProperties.getInstance().getOpenMRSPassword());
} |
d1b72f9c-e124-4ff5-8984-59e676e0a334 | private void updateGlobalProperty(Connection connection, String propertyName, String propertyValue) throws SQLException {
try (PreparedStatement preparedStatement = connection.prepareStatement(UpdateSchedulerLogin)) {
preparedStatement.setString(1, propertyValue);
preparedStatement.setString(2, propertyName);
preparedStatement.executeUpdate();
}
} |
3092654b-d876-4aa4-a43b-70807d4425ee | private void deleteTask(Connection connection, String taskName) throws SQLException {
try (PreparedStatement preparedStatement = connection.prepareStatement(DeleteScheduledTasks)) {
preparedStatement.setString(1, taskName);
preparedStatement.executeUpdate();
}
} |
e32fcc2b-0d52-4afc-8a55-f79384da3bc1 | public void migrate(Connection connection) throws Exception {
HttpRequest http = new HttpRequest(OpenMRSDataProperties.getInstance());
http.post("/concept", ConceptJson.createConcept("CHIEF COMPLAINT", ConceptDataType.Text, ConceptClass.Symptom));
http.post("/concept", ConceptJson.createConcept("REGISTRATION FEES", ConceptDataType.Numeric, ConceptClass.Misc));
http.post("/concept", ConceptJson.createConcept("HEIGHT", ConceptDataType.Numeric, ConceptClass.Test));
http.post("/concept", ConceptJson.createConcept("WEIGHT", ConceptDataType.Numeric, ConceptClass.Test));
http.post("/concept", ConceptJson.createConcept("BMI", ConceptDataType.Numeric, ConceptClass.Test));
http.post("/concept", ConceptJson.createConcept("REGISTRATION_CONCEPTS", ConceptDataType.NA, ConceptClass.ConvSet ,
new ArrayList<>(Arrays.asList("CHIEF COMPLAINT", "REGISTRATION FEES", "HEIGHT", "WEIGHT", "BMI"))));
} |
5c7ab465-d9d7-475f-ac5a-c16832dc879a | RoomReservation(String name_, LocalDateTimeInterval period_) {
name = name_;
period = period_;
} |
0ad6f83c-3f23-4e8f-921a-039f45391d16 | public static void main(String[] args) {
System.out.println("I'm a reservation!");
} |
86f806fe-5a9e-49ff-a880-dc8489829c23 | public static void main(String[] args) {
System.out.print("I'm a room!\n");
LocalDateTime now = new LocalDateTime();
//System.out.println(now);
System.out.println(now.toString("hh:mm:SS MM/dd/YYYY"));
System.out.println(new Point(5,5));
Room a = new Room("Magic");
a.add_reservation(5);
} |
09870244-00c2-4fde-b83b-7b09b3894dd2 | public Room(String name_) {
name = name_;
location = new Point(0,0);
reservations = new TreeSet<Integer>();
} |
0f53d2aa-4cce-4429-8c7b-1a501dc22af3 | public Room(String name_, Point p_) {
name = name_;
location = p_;
reservations = new TreeSet<Integer>();
} |
4f922c5d-1695-4ca4-8b72-af296dfca7da | public String get_name() {
return name;
} |
032caab4-0d5d-45f9-8fc2-4304342a4ee4 | public Point get_location() {
return location;
} |
691268f9-8d81-42e6-87ae-fd6d9f4122df | public void add_reservation(int x) {
reservations.add(x);
System.out.println(x + " was added");
} |
9cff0344-881c-4aaf-9fb4-089784d669d2 | public void add_reservation(LocalDateTime start, LocalDateTime end) {
System.out.println("Do nothing for now");
} |
f8a542c9-12c1-4337-8761-e3bb763bfd66 | public String toString() {
StringBuilder result = new StringBuilder();
result.append(name + " Location: (" + location.x + ", " + location.y + ")");
result.append(System.getProperty("line.separator"));
if (!reservations.isEmpty()) {
for (int i: reservations) {
result.append(i + " ");
}
result.append(System.getProperty("line.separator"));
}
return result.toString();
} |
8d57e611-caa0-4b30-a745-3df3f90afa8c | public abstract void execute(); |
9cd53c17-0329-4c8c-9ebf-b62dea325cef | public Reservation(String name_, Interval interval_) {
name = name_;
description = "";
interval = interval_;
} |
aa8d0b9c-128e-467c-92e6-35e1c0432db5 | public Reservation(String name_, Interval interval_, String description_) {
name = name_;
description = description_;
interval = interval_;
} |
2f58cd1a-2c97-4100-b84a-2742d835b2f8 | public static void main(String[] args) {
//year, month, day of month, hour, minute of hour
DateTime start = new DateTime(2004, 12, 25, 5, 18);
DateTime end = new DateTime(2005, 1, 1, 6, 17);
//Interval i = new Interval(DateTime.parse(start.toString(), fmt), end);
Reservation r = new Reservation("David Li", new Interval(start, end));
//System.out.println("i: " + i);
System.out.println(r);
Reservation PR = new Reservation("Bianca Ng", new Interval(start, end), "For a PR meeting!");
System.out.println(PR);
} |
f799977d-df0c-4ccb-a7ff-f704102d1203 | public String toString() {
StringBuilder result = new StringBuilder();
DateTimeFormatter fmt = DateTimeFormat.forPattern("HH:mm MM/dd");
//result.append(System.getProperty("line.separator"));
result.append(name + ": " + fmt.print(interval.getStart()) + " - " + fmt.print(interval.getEnd()));
result.append(System.getProperty("line.separator"));
if (description.equals("")) {
result.append(" None");
} else { //a description was specified
result.append(" " + description);
}
return result.toString();
} |
9309cd7b-116c-42ac-b829-8fbb0401366d | public RoomScheduler() {
// TODO Auto-generated constructor stub
} |
d3841e37-1ed5-4d43-aade-76b42268b0b8 | public RoomScheduler(int numRooms) {
Rooms = new TreeMap<String, Integer>();
System.out.println("RoomScheduler with " + numRooms + " rooms created");
for (int i = 0; i < numRooms; ++i) {
Rooms.put("Room #" + i, i);
}
} |
bd33f202-433f-4126-a5aa-95448bd9117b | public static void main(String[] args) {
//args[0] = # of rooms
int num_rooms = 5;
if (args.length == 1) {
num_rooms = Integer.parseInt(args[0]);
}
RoomScheduler rs = new RoomScheduler(5);
if (args.length == 1) {
num_rooms = Integer.parseInt(args[0]);
System.out.println("Num_rooms: " + num_rooms);
}
String[] names = {"April's", "Bahamas", "Charley's", "David's", "Eugene's"};
rooms = new TreeMap<String, Room>();
for (int i = 0; i < num_rooms; ++i) {
rooms.put(names[i], new Room(names[i]));
//rooms.put("room " + i, new Room("room " + i));
//Rooms.put("Room #" + i, i);
}
DateTime now = new DateTime();
System.out.println("Welcome to Meeting Scheduler!");
//pointers to functions ? NOT POSSIBLE
Scanner cin = new Scanner(System.in);
while (true) {
System.out.print("Enter command: ");
String line = cin.next();
//show, reserve any room, reserve specific room, removed reservation
if (line.equals("quit")) {
break;
} else if (line.equals("show")) {
for (Entry<String, Room> entry: rooms.entrySet()) {
String key = entry.getKey();
Room r = entry.getValue();
System.out.println(key + " => " + r.toString());
}
} else if (line.equals("add_room")) {
//add <room_name> <loc_x> <loc_y>
String room_name = cin.next();
String loc_x = cin.next();
String loc_y = cin.next();
try {
rooms.put(room_name, new Room(room_name, new Point(Integer.parseInt(loc_x), Integer.parseInt(loc_y))));
} catch(NumberFormatException nfe) {
System.out.println("Value must be an integer!");
}
} else if (line.equals("add_reservation")) {
//<room_name> <integer>
//find room by Name, throw exception if doesnt exist
String name = cin.next();
if (!rooms.containsKey(name)) {
continue;
}
String val = cin.next();
try {
int n = Integer.parseInt(val);
rooms.get(name).add_reservation(n);
} catch(NumberFormatException nfe) {
System.out.println("Value must be an integer!");
}
//add an integer
//throw exception if not possible
} else {
System.out.println("Unrecognized command!");
}
//Rooms.put(line, 5);
//System.out.println(line);
}
return;
} |
b4b6e2c2-fd02-4073-b6c3-761c0b83758e | public Directory(String name){
this.name = name;
} |
ac93d2bb-3a75-473e-ab6c-93d9cd4d8f82 | @Override
public String getName() {
return name;
} |
8aa1d6f1-24d3-4b0e-a434-bb04251e753f | @Override
public int getSize() {
int size = 0;
Iterator it = directory.iterator();
while(it.hasNext()){
Entry entry = (Entry)it.next();
size += entry.getSize();
}
return size;
} |
51ffc4e5-8d43-4f8b-bc71-bc0e074529bc | public Entry add(Entry entry){
directory.add(entry);
return this;
} |
7caf3bfe-4cf4-4859-97a2-f4310f46e51f | @Override
protected void printList(String prefix) {
System.out.println(prefix + "/" + this);
Iterator it = directory.iterator();
while(it.hasNext()){
Entry entry = (Entry)it.next();
entry.printList(prefix + "/" + name);
}
} |
782e4368-bad3-4dee-b652-e24f2fe32889 | public File(String name, int size){
this.name = name;
this.size = size;
} |
0471abf5-2e93-45b3-894f-1f931aad9d53 | @Override
public String getName() {
return name;
} |
114e560c-adf4-48f5-9d88-dead1972b10d | @Override
public int getSize() {
return size;
} |
9210b555-469f-421d-8e35-30a4ac4d9eef | @Override
protected void printList(String prefix) {
System.out.println(prefix + "/" + this);
} |
e417bc8d-c530-4ac0-a359-7a58d5c771ea | public abstract String getName(); |
d87de9bd-5499-4e7c-97ba-690cd356e145 | public abstract int getSize(); |
d500c55e-6d7d-45b5-a315-f26cb136c93f | public Entry add(Entry entry) throws FileTreatmentException {
throw new FileTreatmentException();
} |
ee3df6db-f588-4596-a568-10801d819bb9 | public void printList(){
printList("");
} |
86dae415-89c3-4a1b-b227-d740e49f38be | protected abstract void printList(String prefix); |
fc9fc179-c793-44a8-9216-60a7ccdfd978 | public String toString(){
return getName() + "(" + getSize() + ")";
} |
47d5dfe9-fb2a-4e88-8ddc-355f3076540c | public static void main(String[] args) {
System.out.println("Making root entries...");
Directory rootdir = new Directory("root");
Directory bindir = new Directory("bin");
Directory tmpdir = new Directory("tmp");
Directory usrdir = new Directory("usr");
rootdir.add(bindir);
rootdir.add(tmpdir);
rootdir.add(usrdir);
bindir.add(new File("vi", 10000));
bindir.add(new File("latex", 20000));
rootdir.printList();
System.out.println("");
System.out.println("Making user entries...");
Directory yuki = new Directory("yuki");
Directory hanako = new Directory("hanako");
Directory tomura = new Directory("tomura");
usrdir.add(yuki);
usrdir.add(hanako);
usrdir.add(tomura);
yuki.add(new File("diary.html", 100));
yuki.add(new File("Composite.java", 200));
hanako.add(new File("memo.tex", 300));
tomura.add(new File("game.doc", 400));
tomura.add(new File("junk.mail", 500));
rootdir.printList();
// I dont know why but I dont have to write "try&catch" for some reason.
// The textbook says I need to do tho...
} |
ede5b2a5-1e88-48e3-845e-85ad4821b76a | public FileTreatmentException(){
} |
41491e2e-7bcf-40f1-86d2-a2b7e19c8c52 | public FileTreatmentException(String msg){
super(msg);
} |
2f863cc2-6538-4327-83d2-af09692aa621 | public StringDisplay (String str) { // 引数で表示文字列を指定
this.str = str;
} |
ca719ae5-07bb-416a-b3df-9ee8fe7fb943 | @Override
public int getColumns() { // 文字数
return str.getBytes().length;
} |
f1384511-809c-461c-9cdb-3fbba930ae1e | @Override
public int getRows() { // 行数は1
return 1;
} |
9203224e-9f01-4de0-a213-d41dae1e9821 | @Override
public String getRowText(int row) { // rowが0のときのみ返す
if (row == 0) {
return str;
}else{
return null;
}
} |
21f1c470-bb74-4930-b95e-b0aa337627aa | public abstract int getColumns(); // 横の文字を得る |
24fe60fa-57e2-43fa-88d6-8fbbc80e1c57 | public abstract int getRows(); // 縦の行数を得る |
c37a6b5f-778a-451d-8cfd-a8e228090f3b | public abstract String getRowText(int row); // row番目の文字列を得る |
22b065a4-d654-419b-b00c-90ac4588aa18 | public final void show(){
for (int i = 0; i < getRows(); i++) {
System.out.println(getRowText(i));
}
} |
92411157-e576-46bb-b3c8-8890ee786e42 | protected Border (Display display) { // インスタンス生成時に「中身」を引数で指定
this.display = display;
} |
89048627-81f0-4d38-95fc-a7154d1d178b | protected SideBorder(Display display, char ch) { // コンストラクタでDisplayと飾り文字を指定
super(display);
this.borderChar = ch;
} |
c4133480-1dac-4adb-b1af-e9ead4b61f4b | @Override
public int getColumns() { // 文字数は中身の両側に飾り文字分を加えたもの
return 1 + display.getColumns() + 1;
} |
a74e1429-94c0-4994-bfc4-92cd262d9b08 | @Override
public int getRows() { // 行数は中身の行数に同じ
return display.getRows();
} |
dd1ae556-3ac6-44ee-98aa-8df2ba7cb705 | @Override
public String getRowText(int row) { // 指定行の内容は、中身の指定行の両側に飾り文字をつけたもの
return borderChar + display.getRowText(row) + borderChar;
} |
d58f4769-7e3b-45f3-869a-af82f1174e80 | public static void main(String[] args) {
Display b1 = new StringDisplay("Hello, world!");
Display b2 = new SideBorder(b1, '#');
Display b3 = new FullBorder(b2);
b1.show();
b2.show();
b3.show();Display b4 = new SideBorder(new FullBorder(new FullBorder(new SideBorder(new FullBorder(new StringDisplay("こんにちは。")),'*'))), '/');
b4.show();
} |
1e655035-2ea1-4910-bbc8-4a5560e42c5a | protected FullBorder(Display display) {
super(display);
} |
98222e80-1f3d-4836-92a8-62856483df64 | @Override
public int getColumns() { // 文字数は中身の両側に飾り文字分を足したもの
return 1 + display.getColumns() + 1;
} |
9ca76f4c-f8ca-4aa4-8f6e-7385413836bd | @Override
public int getRows() { // 行数は中身の行数に上下の飾りも自分を加えたもの
return 1 + display.getRows() + 1;
} |
1b7fa69f-c65b-4e81-a13b-692e7d86b7dc | @Override
public String getRowText(int row) { // 指定した行の内容
if (row == 0) { // 枠の上端
return "+" + makeLine('-', display.getColumns()) + "+";
} else if (row == display.getRows() + 1) { // 枠の下端
return "+" + makeLine('-', display.getColumns()) + "+";
} else { // それ以外
return "|" + display.getRowText(row - 1) + "|";
}
} |
f20fa129-ae60-4567-8212-055b4b4ef665 | private String makeLine (char ch, int count) { // 文字chをcount個連結させた文字列を作る
StringBuffer sb = new StringBuffer();
for (int i = 0; i < count; i++) {
sb.append(ch);
}
return sb.toString();
} |
9de20ce2-30d5-4a29-8e63-eb34cb119211 | public Type getType() {
return type;
} |
f942f980-4201-4081-9d90-eb08cd361a52 | public void setType(Type type) {
this.type = type;
} |
c29ff15d-4bd6-421a-a389-6ab111e74156 | public boolean isAppears() {
return appears;
} |
6282e2d8-31e6-4e8d-b66f-9b5ad9b8c394 | public void setAppears(boolean appears) {
this.appears = appears;
} |
460405cc-d55f-4f72-94e8-88369acb0fee | public int getFrequency() {
return frequency;
} |
1e6cfb65-5ec9-4e5f-b197-7cad8318ae12 | public void setFrequency(int frequency) {
this.frequency = frequency;
} |
abf6f5c5-8dfa-460c-a5fd-15aed3fd6a60 | public Date getLastSeen() {
return lastSeen;
} |
706f532e-a378-490b-bf26-39db034913c2 | public void setLastSeen(Date lastSeen) {
this.lastSeen = lastSeen;
} |
1c5c0ad8-3ac8-4693-b70a-fef0f49ca2fe | public String getValue() {
return value;
} |
c2a84d92-a667-4261-b654-fa3d6903799c | public void setValue(String value) {
this.value = value;
} |
0f616aa9-4a4f-4de9-947e-2ae47d8a2ae7 | @Override
public String toString() {
return "Answer{" +
"appears=" + appears +
", type=" + type +
", value=" + value +
", lastSeen=" + lastSeen +
", frequency=" + frequency +
'}';
} |
05b52559-2b6e-45da-aded-36b0112de92a | public Answer query(Type type, String value) throws IOException, SAXException {
return request(type.asQueryString(value)).get(0);
} |
58408d6f-8d18-45a4-ac68-44ec3a9455b0 | public Answer ip(String value) throws IOException, SAXException {
return query(Type.IP, value);
} |
4c7078cb-cf30-4385-bd8d-9c819cd8f12b | public Answer email(String value) throws IOException, SAXException {
return query(Type.EMAIL, value);
} |
3bb72311-e7ff-4772-8bb9-5ae0cc9ff9c6 | public Answer username(String value) throws IOException, SAXException {
return query(Type.USERNAME, value);
} |
e193d959-3cda-487e-a487-f0aad35579a0 | public Builder build() {
return new Builder(this);
} |
35b8649c-aa00-4d49-89d6-3566ba0a656e | List<Answer> request(String query) throws SAXException, IOException {
try {
URL url = new URL(String.format("http://www.stopforumspam.com/api?%s&f=xmlcdata", query));
List<Answer> answers = new ArrayList<Answer>();
Document dom = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(url.openStream());
for (Node child = dom.getDocumentElement().getFirstChild(); child!=null; child=child.getNextSibling()) {
if (child instanceof Element) {
Element e = (Element) child;
String name = e.getTagName();
if (name.equals("success")) {
if (!getTextValue(e).equals("1"))
throw new IOException("Request failed");
}
if (name.equals("ip") || name.equals("username") || name.equals("email")) {
answers.add(parseAnswer(e));
}
}
}
return answers;
} catch (ParserConfigurationException e) {
throw new Error(e);
}
} |
82d9c702-8f74-4f48-9986-6a9b14808399 | private Answer parseAnswer(Element parent) {
Answer a = new Answer();
a.setType(Type.valueOf(parent.getTagName().toUpperCase(Locale.ENGLISH)));
for (Node child=parent.getFirstChild(); child!=null; child=child.getNextSibling()) {
if (child instanceof Element) {
Element e = (Element) child;
String name = e.getTagName();
String v = getTextValue(e);
if (name.equals("value")) {
a.setValue(v);
}
if (name.equals("lastseen")) {
try {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
a.setLastSeen(format.parse(v));
} catch (ParseException e1) {
throw new IllegalArgumentException("Unexpected date format: "+ v);
}
}
if (name.equals("frequency")) {
a.setFrequency(Integer.parseInt(v));
}
if (name.equals("appears")) {
a.setAppears(!v.equals("0"));
}
}
}
return a;
} |
37032ac0-8300-4a64-9141-13d8d140831c | private String getTextValue(Element e) {
StringBuilder buf = new StringBuilder();
for (Node child=e.getFirstChild(); child!=null; child=child.getNextSibling()) {
if (child instanceof CharacterData) {
CharacterData cd = (CharacterData) child;
buf.append(cd.getData());
}
}
return buf.toString();
} |
f2521699-88e0-4bf6-ad77-1e05027099b9 | String lowerName() {
return name().toLowerCase(Locale.ENGLISH);
} |
ecae65aa-f281-4750-8c1f-36fa3351689e | String asQueryString(String value) {
return lowerName()+"[]="+value;
} |
0da92e23-981f-4ba5-a5d1-e15f86fa45a3 | Builder(StopForumSpam parent) {
this.parent = parent;
} |
d7153ef8-8c28-4bef-ab3b-2e229e4c6dd7 | public Builder ip(String value) {
return add(Type.IP,value);
} |
1ebe9b1d-e8b6-479c-aa74-9434ca7e34bc | public Builder email(String value) {
return add(Type.EMAIL,value);
} |
8e12503f-a95c-463f-bd20-dd25ddf92304 | public Builder username(String value) {
return add(Type.USERNAME,value);
} |
50264b99-2c3b-4573-b3fe-93ad627eb842 | public Builder add(Type type, String value) {
types.add(type);
values.add(value);
return this;
} |
fe831ed8-63d3-4475-98b7-258999890373 | public List<Answer> query() throws IOException, SAXException {
StringBuilder buf = new StringBuilder();
for (int i=0; i<types.size(); i++) {
if (buf.length()>0) buf.append('&');
buf.append(types.get(i).asQueryString(values.get(i)));
}
return parent.request(buf.toString());
} |
0afbd305-7bcf-489f-bf64-4147c8d51484 | public void testApp() throws IOException, SAXException {
StopForumSpam sfs = new StopForumSpam();
List<Answer> a = sfs.build().ip("199.15.234.84").username("kohsuke").query();
System.out.println(a);
System.out.println(sfs.ip("199.15.234.84"));
} |
0626f5ac-a28b-460b-9d56-cc3ca15ac039 | public static boolean IsPrime(int n)
{
double upper = Math.sqrt(n);
if (upper < 2)
return false;
for (int i = 2; i <= upper; i++)
if (n % i == 0)
return false;
return true;
} |
d1ff7a16-4943-4718-b65c-de2da8a78bdc | public static String Primes(int n)
{
String result = "";
for (int i = 0; i <= n; i++)
if (IsPrime(i))
result += i + " ";
return result;
} |
bd6ed46d-0f7f-4a81-8b40-8a857d752030 | public static void main(String[] args) {
int n = Integer.parseInt(JOptionPane.showInputDialog
("Enter number n")
);
JOptionPane.showMessageDialog(null, Primes(n));
} |
0c64bda1-9a3e-43a8-b4ac-052a1e0f1d00 | native static double spotf5(String name); |
7c765b39-70ef-4d6d-88be-6ba4f06076b6 | public static void main(final String[] args) {
if (args.length < 1 || args[0].equals("-h") || args[0].equals("--help")) {
System.out.println("HIYA! Welcome to AutoSteg, which is basically a wrapper that allows you to pass directories as argument to the F5 algo.");
System.out.println("Format is: java AutoSteg directory_name e [-e msg_name.txt] [-p password] [-q quality_factor]");
}
else{
String inputDirectory = args[0]; //get directory name
String outputDirectory = inputDirectory+"/stego_output"; //it appears that the folder stego_ouput must exist OR THE PROGRAM GETS MAD
File folder = new File(inputDirectory);
File[] allFiles = folder.listFiles(); //get all files in directory. please don't break this by giving a directory with non-pic files. thank you.
String[] newArgs = new String[args.length+1];
//there's probably a better way to copy arguments, eh. Java.
for (int i = 0; i<args.length-1; i++){
newArgs[i] = args[i+1];
}
for (File file: allFiles) {
String filename = String.format("%s", file); //get filename with path and everything
String picNameWithJpg = filename.substring(filename.lastIndexOf("/")); //get only the pic name with jpg extensions
String picName = picNameWithJpg.substring(0, picNameWithJpg.lastIndexOf(".")); //get only the pic name with jpg extensions
String outputFilename = String.format("%s%sSTEGO.jpg", outputDirectory, picName);
//System.out.printf("here are your strings FILENAME: %s\n PICNAME: %s\n Picname: %s\n OUTPUT: %s\n", filename, picNameWithJpg, picName, outputFilename); //just for debugging
newArgs[args.length-1] = filename; //input file parameter
newArgs[args.length] = outputFilename; //output file parameter
//System.out.println(Arrays.toString(newArgs)); //just for debugging
//again, probably a more efficient way to do this without constantly copying arrays
if (newArgs[0].equals("e")) {
Embed.main(Arrays.copyOfRange(newArgs, 1, newArgs.length));
double beta = spotf5(newArgs[args.length]);
if(beta > 0.25){
System.out.println("\t\tWE SEE THE STEGO.");
System.out.printf("\t\tWE DETECTED: %f\n", beta);
}
else{
System.out.println("\t\tNO STEGO HERE. MOVING ALONG.");
}
try{
String resultsFileOutputDirectory = outputDirectory + ".csv";
FileWriter fstream = new FileWriter(resultsFileOutputDirectory, true);
BufferedWriter out = new BufferedWriter(fstream);
String output = String.format("%s, %s, %f\n", picName, beta>0.25?"detected":"not detected", beta);
out.write(output);
out.close();
}
catch (Exception e)
{
System.err.println("Error: " + e.getMessage());
}
}
//hmm, would anyone want the extraction process?
if (newArgs[0].equals("x")) {
Extract.main(Arrays.copyOfRange(newArgs, 1, newArgs.length));
}
} //end of for loop for each file in directory
} //end of reading arguments
} //end of main |
5f632f3e-077f-4720-96d4-f1759abab866 | public Permutation(final int size, final F5Random random) {
int i, randomIndex, tmp;
this.shuffled = new int[size];
// To create the shuffled sequence, we initialise an array
// with the integers 0 ... (size-1).
for (i = 0; i < size; i++) {
// initialise with �size� integers
this.shuffled[i] = i;
}
int maxRandom = size; // set number of entries to shuffle
for (i = 0; i < size; i++) { // shuffle entries
randomIndex = random.getNextValue(maxRandom--);
tmp = this.shuffled[randomIndex];
this.shuffled[randomIndex] = this.shuffled[maxRandom];
this.shuffled[maxRandom] = tmp;
}
} |
365518c6-fd95-4333-99eb-dce48ad021b4 | public int getShuffled(final int i) {
return this.shuffled[i];
} |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.