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
|
---|---|---|---|---|---|---|
Nilhcem/devoxxfr-2016
|
app/src/test/java/com/nilhcem/devoxxfr/data/app/DataProviderCacheTest.java
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Session.java
// @Value
// public class Session implements Parcelable {
//
// public static final Parcelable.Creator<Session> CREATOR = new Parcelable.Creator<Session>() {
// public Session createFromParcel(Parcel source) {
// return new Session(source);
// }
//
// public Session[] newArray(int size) {
// return new Session[size];
// }
// };
//
// int id;
// String room;
// List<Speaker> speakers;
// String title;
// String description;
// LocalDateTime fromTime;
// LocalDateTime toTime;
//
// public Session(int id, String room, List<Speaker> speakers, String title, String description, LocalDateTime fromTime, LocalDateTime toTime) {
// this.id = id;
// this.room = room;
// this.speakers = speakers;
// this.title = title;
// this.description = description;
// this.fromTime = fromTime;
// this.toTime = toTime;
// }
//
// protected Session(Parcel in) {
// id = in.readInt();
// room = in.readString();
// speakers = in.createTypedArrayList(Speaker.CREATOR);
// title = in.readString();
// description = in.readString();
// fromTime = (LocalDateTime) in.readSerializable();
// toTime = (LocalDateTime) in.readSerializable();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(room);
// dest.writeTypedList(speakers);
// dest.writeString(title);
// dest.writeString(description);
// dest.writeSerializable(fromTime);
// dest.writeSerializable(toTime);
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Speaker.java
// @Value
// public class Speaker implements Parcelable {
//
// public static final Parcelable.Creator<Speaker> CREATOR = new Parcelable.Creator<Speaker>() {
// public Speaker createFromParcel(Parcel source) {
// return new Speaker(source);
// }
//
// public Speaker[] newArray(int size) {
// return new Speaker[size];
// }
// };
//
// int id;
// String name;
// String title;
// String bio;
// String website;
// String twitter;
// String github;
// String photo;
//
// public Speaker(int id, String name, String title, String bio, String website, String twitter, String github, String photo) {
// this.id = id;
// this.name = name;
// this.title = title;
// this.bio = bio;
// this.website = website;
// this.twitter = twitter;
// this.github = github;
// this.photo = photo;
// }
//
// protected Speaker(Parcel in) {
// id = in.readInt();
// name = in.readString();
// title = in.readString();
// bio = in.readString();
// website = in.readString();
// twitter = in.readString();
// github = in.readString();
// photo = in.readString();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(name);
// dest.writeString(title);
// dest.writeString(bio);
// dest.writeString(website);
// dest.writeString(twitter);
// dest.writeString(github);
// dest.writeString(photo);
// }
// }
|
import android.os.Build;
import com.nilhcem.devoxxfr.BuildConfig;
import com.nilhcem.devoxxfr.data.app.model.Session;
import com.nilhcem.devoxxfr.data.app.model.Speaker;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricGradleTestRunner;
import org.robolectric.annotation.Config;
import org.threeten.bp.LocalDateTime;
import java.util.Arrays;
import java.util.List;
import static com.google.common.truth.Truth.assertThat;
|
package com.nilhcem.devoxxfr.data.app;
@RunWith(RobolectricGradleTestRunner.class)
@Config(constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP)
public class DataProviderCacheTest {
private final DataProviderCache cache = new DataProviderCache();
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Session.java
// @Value
// public class Session implements Parcelable {
//
// public static final Parcelable.Creator<Session> CREATOR = new Parcelable.Creator<Session>() {
// public Session createFromParcel(Parcel source) {
// return new Session(source);
// }
//
// public Session[] newArray(int size) {
// return new Session[size];
// }
// };
//
// int id;
// String room;
// List<Speaker> speakers;
// String title;
// String description;
// LocalDateTime fromTime;
// LocalDateTime toTime;
//
// public Session(int id, String room, List<Speaker> speakers, String title, String description, LocalDateTime fromTime, LocalDateTime toTime) {
// this.id = id;
// this.room = room;
// this.speakers = speakers;
// this.title = title;
// this.description = description;
// this.fromTime = fromTime;
// this.toTime = toTime;
// }
//
// protected Session(Parcel in) {
// id = in.readInt();
// room = in.readString();
// speakers = in.createTypedArrayList(Speaker.CREATOR);
// title = in.readString();
// description = in.readString();
// fromTime = (LocalDateTime) in.readSerializable();
// toTime = (LocalDateTime) in.readSerializable();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(room);
// dest.writeTypedList(speakers);
// dest.writeString(title);
// dest.writeString(description);
// dest.writeSerializable(fromTime);
// dest.writeSerializable(toTime);
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Speaker.java
// @Value
// public class Speaker implements Parcelable {
//
// public static final Parcelable.Creator<Speaker> CREATOR = new Parcelable.Creator<Speaker>() {
// public Speaker createFromParcel(Parcel source) {
// return new Speaker(source);
// }
//
// public Speaker[] newArray(int size) {
// return new Speaker[size];
// }
// };
//
// int id;
// String name;
// String title;
// String bio;
// String website;
// String twitter;
// String github;
// String photo;
//
// public Speaker(int id, String name, String title, String bio, String website, String twitter, String github, String photo) {
// this.id = id;
// this.name = name;
// this.title = title;
// this.bio = bio;
// this.website = website;
// this.twitter = twitter;
// this.github = github;
// this.photo = photo;
// }
//
// protected Speaker(Parcel in) {
// id = in.readInt();
// name = in.readString();
// title = in.readString();
// bio = in.readString();
// website = in.readString();
// twitter = in.readString();
// github = in.readString();
// photo = in.readString();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(name);
// dest.writeString(title);
// dest.writeString(bio);
// dest.writeString(website);
// dest.writeString(twitter);
// dest.writeString(github);
// dest.writeString(photo);
// }
// }
// Path: app/src/test/java/com/nilhcem/devoxxfr/data/app/DataProviderCacheTest.java
import android.os.Build;
import com.nilhcem.devoxxfr.BuildConfig;
import com.nilhcem.devoxxfr.data.app.model.Session;
import com.nilhcem.devoxxfr.data.app.model.Speaker;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricGradleTestRunner;
import org.robolectric.annotation.Config;
import org.threeten.bp.LocalDateTime;
import java.util.Arrays;
import java.util.List;
import static com.google.common.truth.Truth.assertThat;
package com.nilhcem.devoxxfr.data.app;
@RunWith(RobolectricGradleTestRunner.class)
@Config(constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP)
public class DataProviderCacheTest {
private final DataProviderCache cache = new DataProviderCache();
|
private final Session session1 = new Session(1, null, null, null, null, null, null);
|
Nilhcem/devoxxfr-2016
|
app/src/test/java/com/nilhcem/devoxxfr/data/app/DataProviderCacheTest.java
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Session.java
// @Value
// public class Session implements Parcelable {
//
// public static final Parcelable.Creator<Session> CREATOR = new Parcelable.Creator<Session>() {
// public Session createFromParcel(Parcel source) {
// return new Session(source);
// }
//
// public Session[] newArray(int size) {
// return new Session[size];
// }
// };
//
// int id;
// String room;
// List<Speaker> speakers;
// String title;
// String description;
// LocalDateTime fromTime;
// LocalDateTime toTime;
//
// public Session(int id, String room, List<Speaker> speakers, String title, String description, LocalDateTime fromTime, LocalDateTime toTime) {
// this.id = id;
// this.room = room;
// this.speakers = speakers;
// this.title = title;
// this.description = description;
// this.fromTime = fromTime;
// this.toTime = toTime;
// }
//
// protected Session(Parcel in) {
// id = in.readInt();
// room = in.readString();
// speakers = in.createTypedArrayList(Speaker.CREATOR);
// title = in.readString();
// description = in.readString();
// fromTime = (LocalDateTime) in.readSerializable();
// toTime = (LocalDateTime) in.readSerializable();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(room);
// dest.writeTypedList(speakers);
// dest.writeString(title);
// dest.writeString(description);
// dest.writeSerializable(fromTime);
// dest.writeSerializable(toTime);
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Speaker.java
// @Value
// public class Speaker implements Parcelable {
//
// public static final Parcelable.Creator<Speaker> CREATOR = new Parcelable.Creator<Speaker>() {
// public Speaker createFromParcel(Parcel source) {
// return new Speaker(source);
// }
//
// public Speaker[] newArray(int size) {
// return new Speaker[size];
// }
// };
//
// int id;
// String name;
// String title;
// String bio;
// String website;
// String twitter;
// String github;
// String photo;
//
// public Speaker(int id, String name, String title, String bio, String website, String twitter, String github, String photo) {
// this.id = id;
// this.name = name;
// this.title = title;
// this.bio = bio;
// this.website = website;
// this.twitter = twitter;
// this.github = github;
// this.photo = photo;
// }
//
// protected Speaker(Parcel in) {
// id = in.readInt();
// name = in.readString();
// title = in.readString();
// bio = in.readString();
// website = in.readString();
// twitter = in.readString();
// github = in.readString();
// photo = in.readString();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(name);
// dest.writeString(title);
// dest.writeString(bio);
// dest.writeString(website);
// dest.writeString(twitter);
// dest.writeString(github);
// dest.writeString(photo);
// }
// }
|
import android.os.Build;
import com.nilhcem.devoxxfr.BuildConfig;
import com.nilhcem.devoxxfr.data.app.model.Session;
import com.nilhcem.devoxxfr.data.app.model.Speaker;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricGradleTestRunner;
import org.robolectric.annotation.Config;
import org.threeten.bp.LocalDateTime;
import java.util.Arrays;
import java.util.List;
import static com.google.common.truth.Truth.assertThat;
|
package com.nilhcem.devoxxfr.data.app;
@RunWith(RobolectricGradleTestRunner.class)
@Config(constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP)
public class DataProviderCacheTest {
private final DataProviderCache cache = new DataProviderCache();
private final Session session1 = new Session(1, null, null, null, null, null, null);
private final Session session2 = new Session(2, null, null, null, null, null, null);
private final List<Session> sessions = Arrays.asList(session1, session2);
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Session.java
// @Value
// public class Session implements Parcelable {
//
// public static final Parcelable.Creator<Session> CREATOR = new Parcelable.Creator<Session>() {
// public Session createFromParcel(Parcel source) {
// return new Session(source);
// }
//
// public Session[] newArray(int size) {
// return new Session[size];
// }
// };
//
// int id;
// String room;
// List<Speaker> speakers;
// String title;
// String description;
// LocalDateTime fromTime;
// LocalDateTime toTime;
//
// public Session(int id, String room, List<Speaker> speakers, String title, String description, LocalDateTime fromTime, LocalDateTime toTime) {
// this.id = id;
// this.room = room;
// this.speakers = speakers;
// this.title = title;
// this.description = description;
// this.fromTime = fromTime;
// this.toTime = toTime;
// }
//
// protected Session(Parcel in) {
// id = in.readInt();
// room = in.readString();
// speakers = in.createTypedArrayList(Speaker.CREATOR);
// title = in.readString();
// description = in.readString();
// fromTime = (LocalDateTime) in.readSerializable();
// toTime = (LocalDateTime) in.readSerializable();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(room);
// dest.writeTypedList(speakers);
// dest.writeString(title);
// dest.writeString(description);
// dest.writeSerializable(fromTime);
// dest.writeSerializable(toTime);
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Speaker.java
// @Value
// public class Speaker implements Parcelable {
//
// public static final Parcelable.Creator<Speaker> CREATOR = new Parcelable.Creator<Speaker>() {
// public Speaker createFromParcel(Parcel source) {
// return new Speaker(source);
// }
//
// public Speaker[] newArray(int size) {
// return new Speaker[size];
// }
// };
//
// int id;
// String name;
// String title;
// String bio;
// String website;
// String twitter;
// String github;
// String photo;
//
// public Speaker(int id, String name, String title, String bio, String website, String twitter, String github, String photo) {
// this.id = id;
// this.name = name;
// this.title = title;
// this.bio = bio;
// this.website = website;
// this.twitter = twitter;
// this.github = github;
// this.photo = photo;
// }
//
// protected Speaker(Parcel in) {
// id = in.readInt();
// name = in.readString();
// title = in.readString();
// bio = in.readString();
// website = in.readString();
// twitter = in.readString();
// github = in.readString();
// photo = in.readString();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(name);
// dest.writeString(title);
// dest.writeString(bio);
// dest.writeString(website);
// dest.writeString(twitter);
// dest.writeString(github);
// dest.writeString(photo);
// }
// }
// Path: app/src/test/java/com/nilhcem/devoxxfr/data/app/DataProviderCacheTest.java
import android.os.Build;
import com.nilhcem.devoxxfr.BuildConfig;
import com.nilhcem.devoxxfr.data.app.model.Session;
import com.nilhcem.devoxxfr.data.app.model.Speaker;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricGradleTestRunner;
import org.robolectric.annotation.Config;
import org.threeten.bp.LocalDateTime;
import java.util.Arrays;
import java.util.List;
import static com.google.common.truth.Truth.assertThat;
package com.nilhcem.devoxxfr.data.app;
@RunWith(RobolectricGradleTestRunner.class)
@Config(constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP)
public class DataProviderCacheTest {
private final DataProviderCache cache = new DataProviderCache();
private final Session session1 = new Session(1, null, null, null, null, null, null);
private final Session session2 = new Session(2, null, null, null, null, null, null);
private final List<Session> sessions = Arrays.asList(session1, session2);
|
private final Speaker speaker1 = new Speaker(1, null, null, null, null, null, null, null);
|
Nilhcem/devoxxfr-2016
|
app/src/main/java/com/nilhcem/devoxxfr/utils/App.java
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Session.java
// @Value
// public class Session implements Parcelable {
//
// public static final Parcelable.Creator<Session> CREATOR = new Parcelable.Creator<Session>() {
// public Session createFromParcel(Parcel source) {
// return new Session(source);
// }
//
// public Session[] newArray(int size) {
// return new Session[size];
// }
// };
//
// int id;
// String room;
// List<Speaker> speakers;
// String title;
// String description;
// LocalDateTime fromTime;
// LocalDateTime toTime;
//
// public Session(int id, String room, List<Speaker> speakers, String title, String description, LocalDateTime fromTime, LocalDateTime toTime) {
// this.id = id;
// this.room = room;
// this.speakers = speakers;
// this.title = title;
// this.description = description;
// this.fromTime = fromTime;
// this.toTime = toTime;
// }
//
// protected Session(Parcel in) {
// id = in.readInt();
// room = in.readString();
// speakers = in.createTypedArrayList(Speaker.CREATOR);
// title = in.readString();
// description = in.readString();
// fromTime = (LocalDateTime) in.readSerializable();
// toTime = (LocalDateTime) in.readSerializable();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(room);
// dest.writeTypedList(speakers);
// dest.writeString(title);
// dest.writeString(description);
// dest.writeSerializable(fromTime);
// dest.writeSerializable(toTime);
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Speaker.java
// @Value
// public class Speaker implements Parcelable {
//
// public static final Parcelable.Creator<Speaker> CREATOR = new Parcelable.Creator<Speaker>() {
// public Speaker createFromParcel(Parcel source) {
// return new Speaker(source);
// }
//
// public Speaker[] newArray(int size) {
// return new Speaker[size];
// }
// };
//
// int id;
// String name;
// String title;
// String bio;
// String website;
// String twitter;
// String github;
// String photo;
//
// public Speaker(int id, String name, String title, String bio, String website, String twitter, String github, String photo) {
// this.id = id;
// this.name = name;
// this.title = title;
// this.bio = bio;
// this.website = website;
// this.twitter = twitter;
// this.github = github;
// this.photo = photo;
// }
//
// protected Speaker(Parcel in) {
// id = in.readInt();
// name = in.readString();
// title = in.readString();
// bio = in.readString();
// website = in.readString();
// twitter = in.readString();
// github = in.readString();
// photo = in.readString();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(name);
// dest.writeString(title);
// dest.writeString(bio);
// dest.writeString(website);
// dest.writeString(twitter);
// dest.writeString(github);
// dest.writeString(photo);
// }
// }
|
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.os.Build;
import android.support.annotation.Nullable;
import com.nilhcem.devoxxfr.BuildConfig;
import com.nilhcem.devoxxfr.data.app.model.Session;
import com.nilhcem.devoxxfr.data.app.model.Speaker;
import java.util.List;
import java.util.Locale;
|
package com.nilhcem.devoxxfr.utils;
public final class App {
private App() {
throw new UnsupportedOperationException();
}
public static boolean isCompatible(int apiLevel) {
return android.os.Build.VERSION.SDK_INT >= apiLevel;
}
public static String getVersion() {
String version = String.format(Locale.US, "%s (#%d)", BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE);
if (BuildConfig.INTERNAL_BUILD) {
version = String.format(Locale.US, "%s — commit %s", version, BuildConfig.GIT_SHA);
}
return version;
}
public static void setExactAlarm(AlarmManager alarmManager, long triggerAtMillis, PendingIntent operation) {
if (isCompatible(Build.VERSION_CODES.KITKAT)) {
alarmManager.setExact(AlarmManager.RTC_WAKEUP, triggerAtMillis, operation);
} else {
alarmManager.set(AlarmManager.RTC_WAKEUP, triggerAtMillis, operation);
}
}
@Nullable
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Session.java
// @Value
// public class Session implements Parcelable {
//
// public static final Parcelable.Creator<Session> CREATOR = new Parcelable.Creator<Session>() {
// public Session createFromParcel(Parcel source) {
// return new Session(source);
// }
//
// public Session[] newArray(int size) {
// return new Session[size];
// }
// };
//
// int id;
// String room;
// List<Speaker> speakers;
// String title;
// String description;
// LocalDateTime fromTime;
// LocalDateTime toTime;
//
// public Session(int id, String room, List<Speaker> speakers, String title, String description, LocalDateTime fromTime, LocalDateTime toTime) {
// this.id = id;
// this.room = room;
// this.speakers = speakers;
// this.title = title;
// this.description = description;
// this.fromTime = fromTime;
// this.toTime = toTime;
// }
//
// protected Session(Parcel in) {
// id = in.readInt();
// room = in.readString();
// speakers = in.createTypedArrayList(Speaker.CREATOR);
// title = in.readString();
// description = in.readString();
// fromTime = (LocalDateTime) in.readSerializable();
// toTime = (LocalDateTime) in.readSerializable();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(room);
// dest.writeTypedList(speakers);
// dest.writeString(title);
// dest.writeString(description);
// dest.writeSerializable(fromTime);
// dest.writeSerializable(toTime);
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Speaker.java
// @Value
// public class Speaker implements Parcelable {
//
// public static final Parcelable.Creator<Speaker> CREATOR = new Parcelable.Creator<Speaker>() {
// public Speaker createFromParcel(Parcel source) {
// return new Speaker(source);
// }
//
// public Speaker[] newArray(int size) {
// return new Speaker[size];
// }
// };
//
// int id;
// String name;
// String title;
// String bio;
// String website;
// String twitter;
// String github;
// String photo;
//
// public Speaker(int id, String name, String title, String bio, String website, String twitter, String github, String photo) {
// this.id = id;
// this.name = name;
// this.title = title;
// this.bio = bio;
// this.website = website;
// this.twitter = twitter;
// this.github = github;
// this.photo = photo;
// }
//
// protected Speaker(Parcel in) {
// id = in.readInt();
// name = in.readString();
// title = in.readString();
// bio = in.readString();
// website = in.readString();
// twitter = in.readString();
// github = in.readString();
// photo = in.readString();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(name);
// dest.writeString(title);
// dest.writeString(bio);
// dest.writeString(website);
// dest.writeString(twitter);
// dest.writeString(github);
// dest.writeString(photo);
// }
// }
// Path: app/src/main/java/com/nilhcem/devoxxfr/utils/App.java
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.os.Build;
import android.support.annotation.Nullable;
import com.nilhcem.devoxxfr.BuildConfig;
import com.nilhcem.devoxxfr.data.app.model.Session;
import com.nilhcem.devoxxfr.data.app.model.Speaker;
import java.util.List;
import java.util.Locale;
package com.nilhcem.devoxxfr.utils;
public final class App {
private App() {
throw new UnsupportedOperationException();
}
public static boolean isCompatible(int apiLevel) {
return android.os.Build.VERSION.SDK_INT >= apiLevel;
}
public static String getVersion() {
String version = String.format(Locale.US, "%s (#%d)", BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE);
if (BuildConfig.INTERNAL_BUILD) {
version = String.format(Locale.US, "%s — commit %s", version, BuildConfig.GIT_SHA);
}
return version;
}
public static void setExactAlarm(AlarmManager alarmManager, long triggerAtMillis, PendingIntent operation) {
if (isCompatible(Build.VERSION_CODES.KITKAT)) {
alarmManager.setExact(AlarmManager.RTC_WAKEUP, triggerAtMillis, operation);
} else {
alarmManager.set(AlarmManager.RTC_WAKEUP, triggerAtMillis, operation);
}
}
@Nullable
|
public static String getPhotoUrl(@Nullable Session session) {
|
Nilhcem/devoxxfr-2016
|
app/src/main/java/com/nilhcem/devoxxfr/utils/App.java
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Session.java
// @Value
// public class Session implements Parcelable {
//
// public static final Parcelable.Creator<Session> CREATOR = new Parcelable.Creator<Session>() {
// public Session createFromParcel(Parcel source) {
// return new Session(source);
// }
//
// public Session[] newArray(int size) {
// return new Session[size];
// }
// };
//
// int id;
// String room;
// List<Speaker> speakers;
// String title;
// String description;
// LocalDateTime fromTime;
// LocalDateTime toTime;
//
// public Session(int id, String room, List<Speaker> speakers, String title, String description, LocalDateTime fromTime, LocalDateTime toTime) {
// this.id = id;
// this.room = room;
// this.speakers = speakers;
// this.title = title;
// this.description = description;
// this.fromTime = fromTime;
// this.toTime = toTime;
// }
//
// protected Session(Parcel in) {
// id = in.readInt();
// room = in.readString();
// speakers = in.createTypedArrayList(Speaker.CREATOR);
// title = in.readString();
// description = in.readString();
// fromTime = (LocalDateTime) in.readSerializable();
// toTime = (LocalDateTime) in.readSerializable();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(room);
// dest.writeTypedList(speakers);
// dest.writeString(title);
// dest.writeString(description);
// dest.writeSerializable(fromTime);
// dest.writeSerializable(toTime);
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Speaker.java
// @Value
// public class Speaker implements Parcelable {
//
// public static final Parcelable.Creator<Speaker> CREATOR = new Parcelable.Creator<Speaker>() {
// public Speaker createFromParcel(Parcel source) {
// return new Speaker(source);
// }
//
// public Speaker[] newArray(int size) {
// return new Speaker[size];
// }
// };
//
// int id;
// String name;
// String title;
// String bio;
// String website;
// String twitter;
// String github;
// String photo;
//
// public Speaker(int id, String name, String title, String bio, String website, String twitter, String github, String photo) {
// this.id = id;
// this.name = name;
// this.title = title;
// this.bio = bio;
// this.website = website;
// this.twitter = twitter;
// this.github = github;
// this.photo = photo;
// }
//
// protected Speaker(Parcel in) {
// id = in.readInt();
// name = in.readString();
// title = in.readString();
// bio = in.readString();
// website = in.readString();
// twitter = in.readString();
// github = in.readString();
// photo = in.readString();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(name);
// dest.writeString(title);
// dest.writeString(bio);
// dest.writeString(website);
// dest.writeString(twitter);
// dest.writeString(github);
// dest.writeString(photo);
// }
// }
|
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.os.Build;
import android.support.annotation.Nullable;
import com.nilhcem.devoxxfr.BuildConfig;
import com.nilhcem.devoxxfr.data.app.model.Session;
import com.nilhcem.devoxxfr.data.app.model.Speaker;
import java.util.List;
import java.util.Locale;
|
package com.nilhcem.devoxxfr.utils;
public final class App {
private App() {
throw new UnsupportedOperationException();
}
public static boolean isCompatible(int apiLevel) {
return android.os.Build.VERSION.SDK_INT >= apiLevel;
}
public static String getVersion() {
String version = String.format(Locale.US, "%s (#%d)", BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE);
if (BuildConfig.INTERNAL_BUILD) {
version = String.format(Locale.US, "%s — commit %s", version, BuildConfig.GIT_SHA);
}
return version;
}
public static void setExactAlarm(AlarmManager alarmManager, long triggerAtMillis, PendingIntent operation) {
if (isCompatible(Build.VERSION_CODES.KITKAT)) {
alarmManager.setExact(AlarmManager.RTC_WAKEUP, triggerAtMillis, operation);
} else {
alarmManager.set(AlarmManager.RTC_WAKEUP, triggerAtMillis, operation);
}
}
@Nullable
public static String getPhotoUrl(@Nullable Session session) {
String photoUrl = null;
if (session != null) {
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Session.java
// @Value
// public class Session implements Parcelable {
//
// public static final Parcelable.Creator<Session> CREATOR = new Parcelable.Creator<Session>() {
// public Session createFromParcel(Parcel source) {
// return new Session(source);
// }
//
// public Session[] newArray(int size) {
// return new Session[size];
// }
// };
//
// int id;
// String room;
// List<Speaker> speakers;
// String title;
// String description;
// LocalDateTime fromTime;
// LocalDateTime toTime;
//
// public Session(int id, String room, List<Speaker> speakers, String title, String description, LocalDateTime fromTime, LocalDateTime toTime) {
// this.id = id;
// this.room = room;
// this.speakers = speakers;
// this.title = title;
// this.description = description;
// this.fromTime = fromTime;
// this.toTime = toTime;
// }
//
// protected Session(Parcel in) {
// id = in.readInt();
// room = in.readString();
// speakers = in.createTypedArrayList(Speaker.CREATOR);
// title = in.readString();
// description = in.readString();
// fromTime = (LocalDateTime) in.readSerializable();
// toTime = (LocalDateTime) in.readSerializable();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(room);
// dest.writeTypedList(speakers);
// dest.writeString(title);
// dest.writeString(description);
// dest.writeSerializable(fromTime);
// dest.writeSerializable(toTime);
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Speaker.java
// @Value
// public class Speaker implements Parcelable {
//
// public static final Parcelable.Creator<Speaker> CREATOR = new Parcelable.Creator<Speaker>() {
// public Speaker createFromParcel(Parcel source) {
// return new Speaker(source);
// }
//
// public Speaker[] newArray(int size) {
// return new Speaker[size];
// }
// };
//
// int id;
// String name;
// String title;
// String bio;
// String website;
// String twitter;
// String github;
// String photo;
//
// public Speaker(int id, String name, String title, String bio, String website, String twitter, String github, String photo) {
// this.id = id;
// this.name = name;
// this.title = title;
// this.bio = bio;
// this.website = website;
// this.twitter = twitter;
// this.github = github;
// this.photo = photo;
// }
//
// protected Speaker(Parcel in) {
// id = in.readInt();
// name = in.readString();
// title = in.readString();
// bio = in.readString();
// website = in.readString();
// twitter = in.readString();
// github = in.readString();
// photo = in.readString();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(name);
// dest.writeString(title);
// dest.writeString(bio);
// dest.writeString(website);
// dest.writeString(twitter);
// dest.writeString(github);
// dest.writeString(photo);
// }
// }
// Path: app/src/main/java/com/nilhcem/devoxxfr/utils/App.java
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.os.Build;
import android.support.annotation.Nullable;
import com.nilhcem.devoxxfr.BuildConfig;
import com.nilhcem.devoxxfr.data.app.model.Session;
import com.nilhcem.devoxxfr.data.app.model.Speaker;
import java.util.List;
import java.util.Locale;
package com.nilhcem.devoxxfr.utils;
public final class App {
private App() {
throw new UnsupportedOperationException();
}
public static boolean isCompatible(int apiLevel) {
return android.os.Build.VERSION.SDK_INT >= apiLevel;
}
public static String getVersion() {
String version = String.format(Locale.US, "%s (#%d)", BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE);
if (BuildConfig.INTERNAL_BUILD) {
version = String.format(Locale.US, "%s — commit %s", version, BuildConfig.GIT_SHA);
}
return version;
}
public static void setExactAlarm(AlarmManager alarmManager, long triggerAtMillis, PendingIntent operation) {
if (isCompatible(Build.VERSION_CODES.KITKAT)) {
alarmManager.setExact(AlarmManager.RTC_WAKEUP, triggerAtMillis, operation);
} else {
alarmManager.set(AlarmManager.RTC_WAKEUP, triggerAtMillis, operation);
}
}
@Nullable
public static String getPhotoUrl(@Nullable Session session) {
String photoUrl = null;
if (session != null) {
|
List<Speaker> speakers = session.getSpeakers();
|
Nilhcem/devoxxfr-2016
|
app/src/internal/java/com/nilhcem/devoxxfr/data/network/ApiEndpoint.java
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/utils/Preconditions.java
// public final class Preconditions {
//
// private Preconditions() {
// throw new UnsupportedOperationException();
// }
//
// /**
// * Ensures the truth of an expression involving one or more parameters to the calling method.
// *
// * @param expression a boolean expression
// * @throws IllegalArgumentException if {@code expression} is false
// */
// public static void checkArgument(boolean expression) {
// if (!expression) {
// throw new IllegalArgumentException();
// }
// }
//
// public static void checkNotOnMainThread() {
// if (BuildConfig.DEBUG) {
// if (isOnMainThread()) {
// throw new IllegalStateException("This method must not be called on the main thread");
// }
// }
// }
//
// private static boolean isOnMainThread() {
// return Thread.currentThread() == Looper.getMainLooper().getThread();
// }
// }
|
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.nilhcem.devoxxfr.BuildConfig;
import com.nilhcem.devoxxfr.utils.Preconditions;
import lombok.ToString;
|
package com.nilhcem.devoxxfr.data.network;
@ToString
public enum ApiEndpoint {
PROD(BuildConfig.API_ENDPOINT),
MOCK(BuildConfig.MOCK_ENDPOINT),
CUSTOM(null);
private static final String PREFS_NAME = "api_endpoint";
private static final String PREFS_KEY_NAME = "name";
private static final String PREFS_KEY_URL = "url";
public String url;
ApiEndpoint(String url) {
this.url = url;
}
public static ApiEndpoint get(Context context) {
SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
String prefsName = prefs.getString(PREFS_KEY_NAME, null);
if (prefsName != null) {
ApiEndpoint endpoint = valueOf(prefsName);
if (endpoint == CUSTOM) {
endpoint.url = prefs.getString(PREFS_KEY_URL, null);
}
return endpoint;
}
return PROD;
}
public static void persist(Context context, @NonNull ApiEndpoint endpoint) {
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/utils/Preconditions.java
// public final class Preconditions {
//
// private Preconditions() {
// throw new UnsupportedOperationException();
// }
//
// /**
// * Ensures the truth of an expression involving one or more parameters to the calling method.
// *
// * @param expression a boolean expression
// * @throws IllegalArgumentException if {@code expression} is false
// */
// public static void checkArgument(boolean expression) {
// if (!expression) {
// throw new IllegalArgumentException();
// }
// }
//
// public static void checkNotOnMainThread() {
// if (BuildConfig.DEBUG) {
// if (isOnMainThread()) {
// throw new IllegalStateException("This method must not be called on the main thread");
// }
// }
// }
//
// private static boolean isOnMainThread() {
// return Thread.currentThread() == Looper.getMainLooper().getThread();
// }
// }
// Path: app/src/internal/java/com/nilhcem/devoxxfr/data/network/ApiEndpoint.java
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.nilhcem.devoxxfr.BuildConfig;
import com.nilhcem.devoxxfr.utils.Preconditions;
import lombok.ToString;
package com.nilhcem.devoxxfr.data.network;
@ToString
public enum ApiEndpoint {
PROD(BuildConfig.API_ENDPOINT),
MOCK(BuildConfig.MOCK_ENDPOINT),
CUSTOM(null);
private static final String PREFS_NAME = "api_endpoint";
private static final String PREFS_KEY_NAME = "name";
private static final String PREFS_KEY_URL = "url";
public String url;
ApiEndpoint(String url) {
this.url = url;
}
public static ApiEndpoint get(Context context) {
SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
String prefsName = prefs.getString(PREFS_KEY_NAME, null);
if (prefsName != null) {
ApiEndpoint endpoint = valueOf(prefsName);
if (endpoint == CUSTOM) {
endpoint.url = prefs.getString(PREFS_KEY_URL, null);
}
return endpoint;
}
return PROD;
}
public static void persist(Context context, @NonNull ApiEndpoint endpoint) {
|
Preconditions.checkArgument(endpoint != CUSTOM);
|
Nilhcem/devoxxfr-2016
|
app/src/main/java/com/nilhcem/devoxxfr/ui/sessions/list/SessionsListAdapter.java
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/SelectedSessionsMemory.java
// @Singleton
// public class SelectedSessionsMemory {
//
// private final Map<LocalDateTime, Integer> selectedSessions = new ConcurrentHashMap<>();
//
// @Inject
// public SelectedSessionsMemory() {
// }
//
// public boolean isSelected(Session session) {
// Integer sessionId = selectedSessions.get(session.getFromTime());
// return sessionId != null && session.getId() == sessionId;
// }
//
// public void setSelectedSessions(Map<LocalDateTime, Integer> selectedSessions) {
// this.selectedSessions.clear();
// this.selectedSessions.putAll(selectedSessions);
// }
//
// public Integer get(LocalDateTime slotTime) {
// return selectedSessions.get(slotTime);
// }
//
// public void toggleSessionState(com.nilhcem.devoxxfr.data.app.model.Session session, boolean insert) {
// selectedSessions.remove(session.getFromTime());
// if (insert) {
// selectedSessions.put(session.getFromTime(), session.getId());
// }
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Session.java
// @Value
// public class Session implements Parcelable {
//
// public static final Parcelable.Creator<Session> CREATOR = new Parcelable.Creator<Session>() {
// public Session createFromParcel(Parcel source) {
// return new Session(source);
// }
//
// public Session[] newArray(int size) {
// return new Session[size];
// }
// };
//
// int id;
// String room;
// List<Speaker> speakers;
// String title;
// String description;
// LocalDateTime fromTime;
// LocalDateTime toTime;
//
// public Session(int id, String room, List<Speaker> speakers, String title, String description, LocalDateTime fromTime, LocalDateTime toTime) {
// this.id = id;
// this.room = room;
// this.speakers = speakers;
// this.title = title;
// this.description = description;
// this.fromTime = fromTime;
// this.toTime = toTime;
// }
//
// protected Session(Parcel in) {
// id = in.readInt();
// room = in.readString();
// speakers = in.createTypedArrayList(Speaker.CREATOR);
// title = in.readString();
// description = in.readString();
// fromTime = (LocalDateTime) in.readSerializable();
// toTime = (LocalDateTime) in.readSerializable();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(room);
// dest.writeTypedList(speakers);
// dest.writeString(title);
// dest.writeString(description);
// dest.writeSerializable(fromTime);
// dest.writeSerializable(toTime);
// }
// }
|
import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;
import com.nilhcem.devoxxfr.data.app.SelectedSessionsMemory;
import com.nilhcem.devoxxfr.data.app.model.Session;
import com.squareup.picasso.Picasso;
import java.util.List;
|
package com.nilhcem.devoxxfr.ui.sessions.list;
public class SessionsListAdapter extends RecyclerView.Adapter<SessionsListEntry> {
private final List<Session> sessions;
private final Picasso picasso;
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/SelectedSessionsMemory.java
// @Singleton
// public class SelectedSessionsMemory {
//
// private final Map<LocalDateTime, Integer> selectedSessions = new ConcurrentHashMap<>();
//
// @Inject
// public SelectedSessionsMemory() {
// }
//
// public boolean isSelected(Session session) {
// Integer sessionId = selectedSessions.get(session.getFromTime());
// return sessionId != null && session.getId() == sessionId;
// }
//
// public void setSelectedSessions(Map<LocalDateTime, Integer> selectedSessions) {
// this.selectedSessions.clear();
// this.selectedSessions.putAll(selectedSessions);
// }
//
// public Integer get(LocalDateTime slotTime) {
// return selectedSessions.get(slotTime);
// }
//
// public void toggleSessionState(com.nilhcem.devoxxfr.data.app.model.Session session, boolean insert) {
// selectedSessions.remove(session.getFromTime());
// if (insert) {
// selectedSessions.put(session.getFromTime(), session.getId());
// }
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Session.java
// @Value
// public class Session implements Parcelable {
//
// public static final Parcelable.Creator<Session> CREATOR = new Parcelable.Creator<Session>() {
// public Session createFromParcel(Parcel source) {
// return new Session(source);
// }
//
// public Session[] newArray(int size) {
// return new Session[size];
// }
// };
//
// int id;
// String room;
// List<Speaker> speakers;
// String title;
// String description;
// LocalDateTime fromTime;
// LocalDateTime toTime;
//
// public Session(int id, String room, List<Speaker> speakers, String title, String description, LocalDateTime fromTime, LocalDateTime toTime) {
// this.id = id;
// this.room = room;
// this.speakers = speakers;
// this.title = title;
// this.description = description;
// this.fromTime = fromTime;
// this.toTime = toTime;
// }
//
// protected Session(Parcel in) {
// id = in.readInt();
// room = in.readString();
// speakers = in.createTypedArrayList(Speaker.CREATOR);
// title = in.readString();
// description = in.readString();
// fromTime = (LocalDateTime) in.readSerializable();
// toTime = (LocalDateTime) in.readSerializable();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(room);
// dest.writeTypedList(speakers);
// dest.writeString(title);
// dest.writeString(description);
// dest.writeSerializable(fromTime);
// dest.writeSerializable(toTime);
// }
// }
// Path: app/src/main/java/com/nilhcem/devoxxfr/ui/sessions/list/SessionsListAdapter.java
import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;
import com.nilhcem.devoxxfr.data.app.SelectedSessionsMemory;
import com.nilhcem.devoxxfr.data.app.model.Session;
import com.squareup.picasso.Picasso;
import java.util.List;
package com.nilhcem.devoxxfr.ui.sessions.list;
public class SessionsListAdapter extends RecyclerView.Adapter<SessionsListEntry> {
private final List<Session> sessions;
private final Picasso picasso;
|
private final SelectedSessionsMemory selectedSessionsMemory;
|
Nilhcem/devoxxfr-2016
|
app/src/main/java/com/nilhcem/devoxxfr/data/database/model/Session.java
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/utils/Database.java
// public class Database {
//
// public static String getString(Cursor cursor, String columnName) {
// return cursor.getString(cursor.getColumnIndexOrThrow(columnName));
// }
//
// public static int getInt(Cursor cursor, String columnName) {
// return cursor.getInt(cursor.getColumnIndexOrThrow(columnName));
// }
//
// private Database() {
// throw new UnsupportedOperationException();
// }
// }
|
import android.content.ContentValues;
import android.database.Cursor;
import com.nilhcem.devoxxfr.utils.Database;
import rx.functions.Func1;
|
package com.nilhcem.devoxxfr.data.database.model;
public class Session {
public static final String TABLE = "sessions";
public static final String ID = "_id";
public static final String START_AT = "start_at";
public static final String DURATION = "duration";
public static final String ROOM_ID = "room_id";
public static final String SPEAKERS_IDS = "speakers_ids";
public static final String TITLE = "title";
public static final String DESCRIPTION = "description";
public final int id;
public final String startAt;
public final int duration;
public final int roomId;
public final String speakersIds;
public final String title;
public final String description;
public Session(int id, String startAt, int duration, int roomId, String speakersIds, String title, String description) {
this.id = id;
this.startAt = startAt;
this.duration = duration;
this.roomId = roomId;
this.speakersIds = speakersIds;
this.title = title;
this.description = description;
}
public static final Func1<Cursor, Session> MAPPER = cursor -> {
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/utils/Database.java
// public class Database {
//
// public static String getString(Cursor cursor, String columnName) {
// return cursor.getString(cursor.getColumnIndexOrThrow(columnName));
// }
//
// public static int getInt(Cursor cursor, String columnName) {
// return cursor.getInt(cursor.getColumnIndexOrThrow(columnName));
// }
//
// private Database() {
// throw new UnsupportedOperationException();
// }
// }
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/database/model/Session.java
import android.content.ContentValues;
import android.database.Cursor;
import com.nilhcem.devoxxfr.utils.Database;
import rx.functions.Func1;
package com.nilhcem.devoxxfr.data.database.model;
public class Session {
public static final String TABLE = "sessions";
public static final String ID = "_id";
public static final String START_AT = "start_at";
public static final String DURATION = "duration";
public static final String ROOM_ID = "room_id";
public static final String SPEAKERS_IDS = "speakers_ids";
public static final String TITLE = "title";
public static final String DESCRIPTION = "description";
public final int id;
public final String startAt;
public final int duration;
public final int roomId;
public final String speakersIds;
public final String title;
public final String description;
public Session(int id, String startAt, int duration, int roomId, String speakersIds, String title, String description) {
this.id = id;
this.startAt = startAt;
this.duration = duration;
this.roomId = roomId;
this.speakersIds = speakersIds;
this.title = title;
this.description = description;
}
public static final Func1<Cursor, Session> MAPPER = cursor -> {
|
int id = Database.getInt(cursor, ID);
|
Nilhcem/devoxxfr-2016
|
app/src/test/java/com/nilhcem/devoxxfr/data/app/SelectedSessionsMemoryTest.java
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Session.java
// @Value
// public class Session implements Parcelable {
//
// public static final Parcelable.Creator<Session> CREATOR = new Parcelable.Creator<Session>() {
// public Session createFromParcel(Parcel source) {
// return new Session(source);
// }
//
// public Session[] newArray(int size) {
// return new Session[size];
// }
// };
//
// int id;
// String room;
// List<Speaker> speakers;
// String title;
// String description;
// LocalDateTime fromTime;
// LocalDateTime toTime;
//
// public Session(int id, String room, List<Speaker> speakers, String title, String description, LocalDateTime fromTime, LocalDateTime toTime) {
// this.id = id;
// this.room = room;
// this.speakers = speakers;
// this.title = title;
// this.description = description;
// this.fromTime = fromTime;
// this.toTime = toTime;
// }
//
// protected Session(Parcel in) {
// id = in.readInt();
// room = in.readString();
// speakers = in.createTypedArrayList(Speaker.CREATOR);
// title = in.readString();
// description = in.readString();
// fromTime = (LocalDateTime) in.readSerializable();
// toTime = (LocalDateTime) in.readSerializable();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(room);
// dest.writeTypedList(speakers);
// dest.writeString(title);
// dest.writeString(description);
// dest.writeSerializable(fromTime);
// dest.writeSerializable(toTime);
// }
// }
|
import android.os.Build;
import com.nilhcem.devoxxfr.BuildConfig;
import com.nilhcem.devoxxfr.data.app.model.Session;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricGradleTestRunner;
import org.robolectric.annotation.Config;
import org.threeten.bp.LocalDateTime;
import java.util.HashMap;
import java.util.Map;
import static com.google.common.truth.Truth.assertThat;
|
package com.nilhcem.devoxxfr.data.app;
@RunWith(RobolectricGradleTestRunner.class)
@Config(constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP)
public class SelectedSessionsMemoryTest {
private final SelectedSessionsMemory memory = new SelectedSessionsMemory();
@Test
public void should_set_selected_sessions() {
// Given
LocalDateTime now = LocalDateTime.now();
Map<LocalDateTime, Integer> map = new HashMap<>();
map.put(now, 1);
// When
assertThat(memory.get(now)).isNull();
memory.setSelectedSessions(map);
// Then
assertThat(memory.get(now)).isEqualTo(1);
}
@Test
public void should_remove_previous_session_when_adding_a_new_one_for_the_same_slot_time() {
// Given
LocalDateTime now = LocalDateTime.now();
Map<LocalDateTime, Integer> map = new HashMap<>();
map.put(now, 1);
memory.setSelectedSessions(map);
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Session.java
// @Value
// public class Session implements Parcelable {
//
// public static final Parcelable.Creator<Session> CREATOR = new Parcelable.Creator<Session>() {
// public Session createFromParcel(Parcel source) {
// return new Session(source);
// }
//
// public Session[] newArray(int size) {
// return new Session[size];
// }
// };
//
// int id;
// String room;
// List<Speaker> speakers;
// String title;
// String description;
// LocalDateTime fromTime;
// LocalDateTime toTime;
//
// public Session(int id, String room, List<Speaker> speakers, String title, String description, LocalDateTime fromTime, LocalDateTime toTime) {
// this.id = id;
// this.room = room;
// this.speakers = speakers;
// this.title = title;
// this.description = description;
// this.fromTime = fromTime;
// this.toTime = toTime;
// }
//
// protected Session(Parcel in) {
// id = in.readInt();
// room = in.readString();
// speakers = in.createTypedArrayList(Speaker.CREATOR);
// title = in.readString();
// description = in.readString();
// fromTime = (LocalDateTime) in.readSerializable();
// toTime = (LocalDateTime) in.readSerializable();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(room);
// dest.writeTypedList(speakers);
// dest.writeString(title);
// dest.writeString(description);
// dest.writeSerializable(fromTime);
// dest.writeSerializable(toTime);
// }
// }
// Path: app/src/test/java/com/nilhcem/devoxxfr/data/app/SelectedSessionsMemoryTest.java
import android.os.Build;
import com.nilhcem.devoxxfr.BuildConfig;
import com.nilhcem.devoxxfr.data.app.model.Session;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricGradleTestRunner;
import org.robolectric.annotation.Config;
import org.threeten.bp.LocalDateTime;
import java.util.HashMap;
import java.util.Map;
import static com.google.common.truth.Truth.assertThat;
package com.nilhcem.devoxxfr.data.app;
@RunWith(RobolectricGradleTestRunner.class)
@Config(constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP)
public class SelectedSessionsMemoryTest {
private final SelectedSessionsMemory memory = new SelectedSessionsMemory();
@Test
public void should_set_selected_sessions() {
// Given
LocalDateTime now = LocalDateTime.now();
Map<LocalDateTime, Integer> map = new HashMap<>();
map.put(now, 1);
// When
assertThat(memory.get(now)).isNull();
memory.setSelectedSessions(map);
// Then
assertThat(memory.get(now)).isEqualTo(1);
}
@Test
public void should_remove_previous_session_when_adding_a_new_one_for_the_same_slot_time() {
// Given
LocalDateTime now = LocalDateTime.now();
Map<LocalDateTime, Integer> map = new HashMap<>();
map.put(now, 1);
memory.setSelectedSessions(map);
|
Session toAdd = new Session(3, null, null, null, null, now, now.plusMinutes(30));
|
Nilhcem/devoxxfr-2016
|
app/src/internal/java/com/nilhcem/devoxxfr/InternalDevoxxApp.java
|
// Path: app/src/production/java/com/nilhcem/devoxxfr/core/dagger/AppComponent.java
// @Singleton
// @Component(modules = {AppModule.class, ApiModule.class, DataModule.class, DatabaseModule.class})
// public interface AppComponent extends AppGraph {
//
// /**
// * An initializer that creates the production graph from an application.
// */
// final class Initializer {
//
// private Initializer() {
// throw new UnsupportedOperationException();
// }
//
// public static AppComponent init(DevoxxApp app) {
// return DaggerAppComponent.builder()
// .appModule(new AppModule(app))
// .apiModule(new ApiModule())
// .dataModule(new DataModule())
// .databaseModule(new DatabaseModule())
// .build();
// }
// }
// }
//
// Path: app/src/internal/java/com/nilhcem/devoxxfr/debug/lifecycle/ActivityProvider.java
// @Singleton
// public class ActivityProvider implements Application.ActivityLifecycleCallbacks {
//
// private Activity currentActivity;
//
// @Inject
// public ActivityProvider() {
// }
//
// public void init(Application app) {
// app.registerActivityLifecycleCallbacks(this);
// }
//
// public Activity getCurrentActivity() {
// return currentActivity;
// }
//
// @Override
// public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
// }
//
// @Override
// public void onActivityStarted(Activity activity) {
// }
//
// @Override
// public void onActivityResumed(Activity activity) {
// this.currentActivity = activity;
// }
//
// @Override
// public void onActivityPaused(Activity activity) {
// currentActivity = null;
// }
//
// @Override
// public void onActivityStopped(Activity activity) {
// }
//
// @Override
// public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
// }
//
// @Override
// public void onActivityDestroyed(Activity activity) {
// }
// }
//
// Path: app/src/internal/java/com/nilhcem/devoxxfr/debug/stetho/StethoInitializer.java
// public class StethoInitializer implements DumperPluginsProvider {
//
// private final Context context;
// private final AppDumperPlugin appDumper;
// private final ActivityProvider activityProvider;
//
// @Inject
// public StethoInitializer(Application application, AppDumperPlugin appDumper, ActivityProvider activityProvider) {
// this.context = application;
// this.appDumper = appDumper;
// this.activityProvider = activityProvider;
// }
//
// public void init() {
// Timber.plant(new StethoTree());
// Stetho.initialize(
// Stetho.newInitializerBuilder(context)
// .enableDumpapp(this)
// .enableWebKitInspector(createWebkitModulesProvider())
// .build());
// }
//
// @Override
// public Iterable<DumperPlugin> get() {
// List<DumperPlugin> plugins = new ArrayList<>();
// for (DumperPlugin plugin : Stetho.defaultDumperPluginsProvider(context).get()) {
// plugins.add(plugin);
// }
// plugins.add(appDumper);
// return plugins;
// }
//
// private InspectorModulesProvider createWebkitModulesProvider() {
// return () -> new Stetho.DefaultInspectorModulesBuilder(context).runtimeRepl(
// new JsRuntimeReplFactoryBuilder(context)
// .addFunction("activity", new BaseFunction() {
// @Override
// public Object call(org.mozilla.javascript.Context cx, Scriptable scope, Scriptable thisObj, Object[] args) {
// return activityProvider.getCurrentActivity();
// }
// }).build()
// ).finish();
// }
// }
|
import android.os.Build;
import com.frogermcs.androiddevmetrics.AndroidDevMetrics;
import com.nilhcem.devoxxfr.core.dagger.AppComponent;
import com.nilhcem.devoxxfr.debug.lifecycle.ActivityProvider;
import com.nilhcem.devoxxfr.debug.stetho.StethoInitializer;
import javax.inject.Inject;
import jp.wasabeef.takt.Takt;
|
package com.nilhcem.devoxxfr;
public class InternalDevoxxApp extends DevoxxApp {
/**
* Change it manually when you want to display the FPS.
* Useful to test the frame rate.
*/
private static final boolean DISPLAY_FPS = false;
/**
* Change it manually when you want to enable AndroidDevMetrics
*/
private static final boolean ENABLE_ANDROID_DEV_METRICS = false;
|
// Path: app/src/production/java/com/nilhcem/devoxxfr/core/dagger/AppComponent.java
// @Singleton
// @Component(modules = {AppModule.class, ApiModule.class, DataModule.class, DatabaseModule.class})
// public interface AppComponent extends AppGraph {
//
// /**
// * An initializer that creates the production graph from an application.
// */
// final class Initializer {
//
// private Initializer() {
// throw new UnsupportedOperationException();
// }
//
// public static AppComponent init(DevoxxApp app) {
// return DaggerAppComponent.builder()
// .appModule(new AppModule(app))
// .apiModule(new ApiModule())
// .dataModule(new DataModule())
// .databaseModule(new DatabaseModule())
// .build();
// }
// }
// }
//
// Path: app/src/internal/java/com/nilhcem/devoxxfr/debug/lifecycle/ActivityProvider.java
// @Singleton
// public class ActivityProvider implements Application.ActivityLifecycleCallbacks {
//
// private Activity currentActivity;
//
// @Inject
// public ActivityProvider() {
// }
//
// public void init(Application app) {
// app.registerActivityLifecycleCallbacks(this);
// }
//
// public Activity getCurrentActivity() {
// return currentActivity;
// }
//
// @Override
// public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
// }
//
// @Override
// public void onActivityStarted(Activity activity) {
// }
//
// @Override
// public void onActivityResumed(Activity activity) {
// this.currentActivity = activity;
// }
//
// @Override
// public void onActivityPaused(Activity activity) {
// currentActivity = null;
// }
//
// @Override
// public void onActivityStopped(Activity activity) {
// }
//
// @Override
// public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
// }
//
// @Override
// public void onActivityDestroyed(Activity activity) {
// }
// }
//
// Path: app/src/internal/java/com/nilhcem/devoxxfr/debug/stetho/StethoInitializer.java
// public class StethoInitializer implements DumperPluginsProvider {
//
// private final Context context;
// private final AppDumperPlugin appDumper;
// private final ActivityProvider activityProvider;
//
// @Inject
// public StethoInitializer(Application application, AppDumperPlugin appDumper, ActivityProvider activityProvider) {
// this.context = application;
// this.appDumper = appDumper;
// this.activityProvider = activityProvider;
// }
//
// public void init() {
// Timber.plant(new StethoTree());
// Stetho.initialize(
// Stetho.newInitializerBuilder(context)
// .enableDumpapp(this)
// .enableWebKitInspector(createWebkitModulesProvider())
// .build());
// }
//
// @Override
// public Iterable<DumperPlugin> get() {
// List<DumperPlugin> plugins = new ArrayList<>();
// for (DumperPlugin plugin : Stetho.defaultDumperPluginsProvider(context).get()) {
// plugins.add(plugin);
// }
// plugins.add(appDumper);
// return plugins;
// }
//
// private InspectorModulesProvider createWebkitModulesProvider() {
// return () -> new Stetho.DefaultInspectorModulesBuilder(context).runtimeRepl(
// new JsRuntimeReplFactoryBuilder(context)
// .addFunction("activity", new BaseFunction() {
// @Override
// public Object call(org.mozilla.javascript.Context cx, Scriptable scope, Scriptable thisObj, Object[] args) {
// return activityProvider.getCurrentActivity();
// }
// }).build()
// ).finish();
// }
// }
// Path: app/src/internal/java/com/nilhcem/devoxxfr/InternalDevoxxApp.java
import android.os.Build;
import com.frogermcs.androiddevmetrics.AndroidDevMetrics;
import com.nilhcem.devoxxfr.core.dagger.AppComponent;
import com.nilhcem.devoxxfr.debug.lifecycle.ActivityProvider;
import com.nilhcem.devoxxfr.debug.stetho.StethoInitializer;
import javax.inject.Inject;
import jp.wasabeef.takt.Takt;
package com.nilhcem.devoxxfr;
public class InternalDevoxxApp extends DevoxxApp {
/**
* Change it manually when you want to display the FPS.
* Useful to test the frame rate.
*/
private static final boolean DISPLAY_FPS = false;
/**
* Change it manually when you want to enable AndroidDevMetrics
*/
private static final boolean ENABLE_ANDROID_DEV_METRICS = false;
|
@Inject StethoInitializer stetho;
|
Nilhcem/devoxxfr-2016
|
app/src/internal/java/com/nilhcem/devoxxfr/InternalDevoxxApp.java
|
// Path: app/src/production/java/com/nilhcem/devoxxfr/core/dagger/AppComponent.java
// @Singleton
// @Component(modules = {AppModule.class, ApiModule.class, DataModule.class, DatabaseModule.class})
// public interface AppComponent extends AppGraph {
//
// /**
// * An initializer that creates the production graph from an application.
// */
// final class Initializer {
//
// private Initializer() {
// throw new UnsupportedOperationException();
// }
//
// public static AppComponent init(DevoxxApp app) {
// return DaggerAppComponent.builder()
// .appModule(new AppModule(app))
// .apiModule(new ApiModule())
// .dataModule(new DataModule())
// .databaseModule(new DatabaseModule())
// .build();
// }
// }
// }
//
// Path: app/src/internal/java/com/nilhcem/devoxxfr/debug/lifecycle/ActivityProvider.java
// @Singleton
// public class ActivityProvider implements Application.ActivityLifecycleCallbacks {
//
// private Activity currentActivity;
//
// @Inject
// public ActivityProvider() {
// }
//
// public void init(Application app) {
// app.registerActivityLifecycleCallbacks(this);
// }
//
// public Activity getCurrentActivity() {
// return currentActivity;
// }
//
// @Override
// public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
// }
//
// @Override
// public void onActivityStarted(Activity activity) {
// }
//
// @Override
// public void onActivityResumed(Activity activity) {
// this.currentActivity = activity;
// }
//
// @Override
// public void onActivityPaused(Activity activity) {
// currentActivity = null;
// }
//
// @Override
// public void onActivityStopped(Activity activity) {
// }
//
// @Override
// public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
// }
//
// @Override
// public void onActivityDestroyed(Activity activity) {
// }
// }
//
// Path: app/src/internal/java/com/nilhcem/devoxxfr/debug/stetho/StethoInitializer.java
// public class StethoInitializer implements DumperPluginsProvider {
//
// private final Context context;
// private final AppDumperPlugin appDumper;
// private final ActivityProvider activityProvider;
//
// @Inject
// public StethoInitializer(Application application, AppDumperPlugin appDumper, ActivityProvider activityProvider) {
// this.context = application;
// this.appDumper = appDumper;
// this.activityProvider = activityProvider;
// }
//
// public void init() {
// Timber.plant(new StethoTree());
// Stetho.initialize(
// Stetho.newInitializerBuilder(context)
// .enableDumpapp(this)
// .enableWebKitInspector(createWebkitModulesProvider())
// .build());
// }
//
// @Override
// public Iterable<DumperPlugin> get() {
// List<DumperPlugin> plugins = new ArrayList<>();
// for (DumperPlugin plugin : Stetho.defaultDumperPluginsProvider(context).get()) {
// plugins.add(plugin);
// }
// plugins.add(appDumper);
// return plugins;
// }
//
// private InspectorModulesProvider createWebkitModulesProvider() {
// return () -> new Stetho.DefaultInspectorModulesBuilder(context).runtimeRepl(
// new JsRuntimeReplFactoryBuilder(context)
// .addFunction("activity", new BaseFunction() {
// @Override
// public Object call(org.mozilla.javascript.Context cx, Scriptable scope, Scriptable thisObj, Object[] args) {
// return activityProvider.getCurrentActivity();
// }
// }).build()
// ).finish();
// }
// }
|
import android.os.Build;
import com.frogermcs.androiddevmetrics.AndroidDevMetrics;
import com.nilhcem.devoxxfr.core.dagger.AppComponent;
import com.nilhcem.devoxxfr.debug.lifecycle.ActivityProvider;
import com.nilhcem.devoxxfr.debug.stetho.StethoInitializer;
import javax.inject.Inject;
import jp.wasabeef.takt.Takt;
|
package com.nilhcem.devoxxfr;
public class InternalDevoxxApp extends DevoxxApp {
/**
* Change it manually when you want to display the FPS.
* Useful to test the frame rate.
*/
private static final boolean DISPLAY_FPS = false;
/**
* Change it manually when you want to enable AndroidDevMetrics
*/
private static final boolean ENABLE_ANDROID_DEV_METRICS = false;
@Inject StethoInitializer stetho;
|
// Path: app/src/production/java/com/nilhcem/devoxxfr/core/dagger/AppComponent.java
// @Singleton
// @Component(modules = {AppModule.class, ApiModule.class, DataModule.class, DatabaseModule.class})
// public interface AppComponent extends AppGraph {
//
// /**
// * An initializer that creates the production graph from an application.
// */
// final class Initializer {
//
// private Initializer() {
// throw new UnsupportedOperationException();
// }
//
// public static AppComponent init(DevoxxApp app) {
// return DaggerAppComponent.builder()
// .appModule(new AppModule(app))
// .apiModule(new ApiModule())
// .dataModule(new DataModule())
// .databaseModule(new DatabaseModule())
// .build();
// }
// }
// }
//
// Path: app/src/internal/java/com/nilhcem/devoxxfr/debug/lifecycle/ActivityProvider.java
// @Singleton
// public class ActivityProvider implements Application.ActivityLifecycleCallbacks {
//
// private Activity currentActivity;
//
// @Inject
// public ActivityProvider() {
// }
//
// public void init(Application app) {
// app.registerActivityLifecycleCallbacks(this);
// }
//
// public Activity getCurrentActivity() {
// return currentActivity;
// }
//
// @Override
// public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
// }
//
// @Override
// public void onActivityStarted(Activity activity) {
// }
//
// @Override
// public void onActivityResumed(Activity activity) {
// this.currentActivity = activity;
// }
//
// @Override
// public void onActivityPaused(Activity activity) {
// currentActivity = null;
// }
//
// @Override
// public void onActivityStopped(Activity activity) {
// }
//
// @Override
// public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
// }
//
// @Override
// public void onActivityDestroyed(Activity activity) {
// }
// }
//
// Path: app/src/internal/java/com/nilhcem/devoxxfr/debug/stetho/StethoInitializer.java
// public class StethoInitializer implements DumperPluginsProvider {
//
// private final Context context;
// private final AppDumperPlugin appDumper;
// private final ActivityProvider activityProvider;
//
// @Inject
// public StethoInitializer(Application application, AppDumperPlugin appDumper, ActivityProvider activityProvider) {
// this.context = application;
// this.appDumper = appDumper;
// this.activityProvider = activityProvider;
// }
//
// public void init() {
// Timber.plant(new StethoTree());
// Stetho.initialize(
// Stetho.newInitializerBuilder(context)
// .enableDumpapp(this)
// .enableWebKitInspector(createWebkitModulesProvider())
// .build());
// }
//
// @Override
// public Iterable<DumperPlugin> get() {
// List<DumperPlugin> plugins = new ArrayList<>();
// for (DumperPlugin plugin : Stetho.defaultDumperPluginsProvider(context).get()) {
// plugins.add(plugin);
// }
// plugins.add(appDumper);
// return plugins;
// }
//
// private InspectorModulesProvider createWebkitModulesProvider() {
// return () -> new Stetho.DefaultInspectorModulesBuilder(context).runtimeRepl(
// new JsRuntimeReplFactoryBuilder(context)
// .addFunction("activity", new BaseFunction() {
// @Override
// public Object call(org.mozilla.javascript.Context cx, Scriptable scope, Scriptable thisObj, Object[] args) {
// return activityProvider.getCurrentActivity();
// }
// }).build()
// ).finish();
// }
// }
// Path: app/src/internal/java/com/nilhcem/devoxxfr/InternalDevoxxApp.java
import android.os.Build;
import com.frogermcs.androiddevmetrics.AndroidDevMetrics;
import com.nilhcem.devoxxfr.core.dagger.AppComponent;
import com.nilhcem.devoxxfr.debug.lifecycle.ActivityProvider;
import com.nilhcem.devoxxfr.debug.stetho.StethoInitializer;
import javax.inject.Inject;
import jp.wasabeef.takt.Takt;
package com.nilhcem.devoxxfr;
public class InternalDevoxxApp extends DevoxxApp {
/**
* Change it manually when you want to display the FPS.
* Useful to test the frame rate.
*/
private static final boolean DISPLAY_FPS = false;
/**
* Change it manually when you want to enable AndroidDevMetrics
*/
private static final boolean ENABLE_ANDROID_DEV_METRICS = false;
@Inject StethoInitializer stetho;
|
@Inject ActivityProvider activityProvider;
|
Nilhcem/devoxxfr-2016
|
app/src/internal/java/com/nilhcem/devoxxfr/InternalDevoxxApp.java
|
// Path: app/src/production/java/com/nilhcem/devoxxfr/core/dagger/AppComponent.java
// @Singleton
// @Component(modules = {AppModule.class, ApiModule.class, DataModule.class, DatabaseModule.class})
// public interface AppComponent extends AppGraph {
//
// /**
// * An initializer that creates the production graph from an application.
// */
// final class Initializer {
//
// private Initializer() {
// throw new UnsupportedOperationException();
// }
//
// public static AppComponent init(DevoxxApp app) {
// return DaggerAppComponent.builder()
// .appModule(new AppModule(app))
// .apiModule(new ApiModule())
// .dataModule(new DataModule())
// .databaseModule(new DatabaseModule())
// .build();
// }
// }
// }
//
// Path: app/src/internal/java/com/nilhcem/devoxxfr/debug/lifecycle/ActivityProvider.java
// @Singleton
// public class ActivityProvider implements Application.ActivityLifecycleCallbacks {
//
// private Activity currentActivity;
//
// @Inject
// public ActivityProvider() {
// }
//
// public void init(Application app) {
// app.registerActivityLifecycleCallbacks(this);
// }
//
// public Activity getCurrentActivity() {
// return currentActivity;
// }
//
// @Override
// public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
// }
//
// @Override
// public void onActivityStarted(Activity activity) {
// }
//
// @Override
// public void onActivityResumed(Activity activity) {
// this.currentActivity = activity;
// }
//
// @Override
// public void onActivityPaused(Activity activity) {
// currentActivity = null;
// }
//
// @Override
// public void onActivityStopped(Activity activity) {
// }
//
// @Override
// public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
// }
//
// @Override
// public void onActivityDestroyed(Activity activity) {
// }
// }
//
// Path: app/src/internal/java/com/nilhcem/devoxxfr/debug/stetho/StethoInitializer.java
// public class StethoInitializer implements DumperPluginsProvider {
//
// private final Context context;
// private final AppDumperPlugin appDumper;
// private final ActivityProvider activityProvider;
//
// @Inject
// public StethoInitializer(Application application, AppDumperPlugin appDumper, ActivityProvider activityProvider) {
// this.context = application;
// this.appDumper = appDumper;
// this.activityProvider = activityProvider;
// }
//
// public void init() {
// Timber.plant(new StethoTree());
// Stetho.initialize(
// Stetho.newInitializerBuilder(context)
// .enableDumpapp(this)
// .enableWebKitInspector(createWebkitModulesProvider())
// .build());
// }
//
// @Override
// public Iterable<DumperPlugin> get() {
// List<DumperPlugin> plugins = new ArrayList<>();
// for (DumperPlugin plugin : Stetho.defaultDumperPluginsProvider(context).get()) {
// plugins.add(plugin);
// }
// plugins.add(appDumper);
// return plugins;
// }
//
// private InspectorModulesProvider createWebkitModulesProvider() {
// return () -> new Stetho.DefaultInspectorModulesBuilder(context).runtimeRepl(
// new JsRuntimeReplFactoryBuilder(context)
// .addFunction("activity", new BaseFunction() {
// @Override
// public Object call(org.mozilla.javascript.Context cx, Scriptable scope, Scriptable thisObj, Object[] args) {
// return activityProvider.getCurrentActivity();
// }
// }).build()
// ).finish();
// }
// }
|
import android.os.Build;
import com.frogermcs.androiddevmetrics.AndroidDevMetrics;
import com.nilhcem.devoxxfr.core.dagger.AppComponent;
import com.nilhcem.devoxxfr.debug.lifecycle.ActivityProvider;
import com.nilhcem.devoxxfr.debug.stetho.StethoInitializer;
import javax.inject.Inject;
import jp.wasabeef.takt.Takt;
|
package com.nilhcem.devoxxfr;
public class InternalDevoxxApp extends DevoxxApp {
/**
* Change it manually when you want to display the FPS.
* Useful to test the frame rate.
*/
private static final boolean DISPLAY_FPS = false;
/**
* Change it manually when you want to enable AndroidDevMetrics
*/
private static final boolean ENABLE_ANDROID_DEV_METRICS = false;
@Inject StethoInitializer stetho;
@Inject ActivityProvider activityProvider;
@Override
public void onCreate() {
super.onCreate();
|
// Path: app/src/production/java/com/nilhcem/devoxxfr/core/dagger/AppComponent.java
// @Singleton
// @Component(modules = {AppModule.class, ApiModule.class, DataModule.class, DatabaseModule.class})
// public interface AppComponent extends AppGraph {
//
// /**
// * An initializer that creates the production graph from an application.
// */
// final class Initializer {
//
// private Initializer() {
// throw new UnsupportedOperationException();
// }
//
// public static AppComponent init(DevoxxApp app) {
// return DaggerAppComponent.builder()
// .appModule(new AppModule(app))
// .apiModule(new ApiModule())
// .dataModule(new DataModule())
// .databaseModule(new DatabaseModule())
// .build();
// }
// }
// }
//
// Path: app/src/internal/java/com/nilhcem/devoxxfr/debug/lifecycle/ActivityProvider.java
// @Singleton
// public class ActivityProvider implements Application.ActivityLifecycleCallbacks {
//
// private Activity currentActivity;
//
// @Inject
// public ActivityProvider() {
// }
//
// public void init(Application app) {
// app.registerActivityLifecycleCallbacks(this);
// }
//
// public Activity getCurrentActivity() {
// return currentActivity;
// }
//
// @Override
// public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
// }
//
// @Override
// public void onActivityStarted(Activity activity) {
// }
//
// @Override
// public void onActivityResumed(Activity activity) {
// this.currentActivity = activity;
// }
//
// @Override
// public void onActivityPaused(Activity activity) {
// currentActivity = null;
// }
//
// @Override
// public void onActivityStopped(Activity activity) {
// }
//
// @Override
// public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
// }
//
// @Override
// public void onActivityDestroyed(Activity activity) {
// }
// }
//
// Path: app/src/internal/java/com/nilhcem/devoxxfr/debug/stetho/StethoInitializer.java
// public class StethoInitializer implements DumperPluginsProvider {
//
// private final Context context;
// private final AppDumperPlugin appDumper;
// private final ActivityProvider activityProvider;
//
// @Inject
// public StethoInitializer(Application application, AppDumperPlugin appDumper, ActivityProvider activityProvider) {
// this.context = application;
// this.appDumper = appDumper;
// this.activityProvider = activityProvider;
// }
//
// public void init() {
// Timber.plant(new StethoTree());
// Stetho.initialize(
// Stetho.newInitializerBuilder(context)
// .enableDumpapp(this)
// .enableWebKitInspector(createWebkitModulesProvider())
// .build());
// }
//
// @Override
// public Iterable<DumperPlugin> get() {
// List<DumperPlugin> plugins = new ArrayList<>();
// for (DumperPlugin plugin : Stetho.defaultDumperPluginsProvider(context).get()) {
// plugins.add(plugin);
// }
// plugins.add(appDumper);
// return plugins;
// }
//
// private InspectorModulesProvider createWebkitModulesProvider() {
// return () -> new Stetho.DefaultInspectorModulesBuilder(context).runtimeRepl(
// new JsRuntimeReplFactoryBuilder(context)
// .addFunction("activity", new BaseFunction() {
// @Override
// public Object call(org.mozilla.javascript.Context cx, Scriptable scope, Scriptable thisObj, Object[] args) {
// return activityProvider.getCurrentActivity();
// }
// }).build()
// ).finish();
// }
// }
// Path: app/src/internal/java/com/nilhcem/devoxxfr/InternalDevoxxApp.java
import android.os.Build;
import com.frogermcs.androiddevmetrics.AndroidDevMetrics;
import com.nilhcem.devoxxfr.core.dagger.AppComponent;
import com.nilhcem.devoxxfr.debug.lifecycle.ActivityProvider;
import com.nilhcem.devoxxfr.debug.stetho.StethoInitializer;
import javax.inject.Inject;
import jp.wasabeef.takt.Takt;
package com.nilhcem.devoxxfr;
public class InternalDevoxxApp extends DevoxxApp {
/**
* Change it manually when you want to display the FPS.
* Useful to test the frame rate.
*/
private static final boolean DISPLAY_FPS = false;
/**
* Change it manually when you want to enable AndroidDevMetrics
*/
private static final boolean ENABLE_ANDROID_DEV_METRICS = false;
@Inject StethoInitializer stetho;
@Inject ActivityProvider activityProvider;
@Override
public void onCreate() {
super.onCreate();
|
AppComponent.Initializer.init(this).inject(this);
|
Nilhcem/devoxxfr-2016
|
app/src/main/java/com/nilhcem/devoxxfr/core/dagger/module/DatabaseModule.java
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/database/DbOpenHelper.java
// public class DbOpenHelper extends SQLiteOpenHelper {
//
// private static final String NAME = "devoxx.db";
// private static final int VERSION = 1;
//
// public DbOpenHelper(Context context) {
// super(context, NAME, null, VERSION);
// }
//
// @Override
// public void onCreate(SQLiteDatabase db) {
// createSpeakersTable(db);
// createSessionsTable(db);
// createSelectedSessionsTable(db);
// }
//
// @Override
// public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// }
//
// private void createSpeakersTable(SQLiteDatabase db) {
// db.execSQL("CREATE TABLE " + Speaker.TABLE + " (" +
// Speaker.ID + " INTEGER PRIMARY KEY," +
// Speaker.NAME + " VARCHAR," +
// Speaker.TITLE + " VARCHAR," +
// Speaker.BIO + " VARCHAR," +
// Speaker.WEBSITE + " VARCHAR," +
// Speaker.TWITTER + " VARCHAR," +
// Speaker.GITHUB + " VARCHAR," +
// Speaker.PHOTO + " VARCHAR);");
// }
//
// private void createSessionsTable(SQLiteDatabase db) {
// db.execSQL("CREATE TABLE " + Session.TABLE + " (" +
// Session.ID + " INTEGER PRIMARY KEY," +
// Session.START_AT + " VARCHAR," +
// Session.DURATION + " INTEGER," +
// Session.ROOM_ID + " INTEGER," +
// Session.SPEAKERS_IDS + " VARCHAR," +
// Session.TITLE + " VARCHAR," +
// Session.DESCRIPTION + " VARCHAR);");
// }
//
// private void createSelectedSessionsTable(SQLiteDatabase db) {
// db.execSQL("CREATE TABLE " + SelectedSession.TABLE + " (" +
// SelectedSession.ID + " INTEGER PRIMARY KEY AUTOINCREMENT," +
// SelectedSession.SLOT_TIME + " VARCHAR," +
// SelectedSession.SESSION_ID + " INTEGER);");
// }
// }
|
import android.app.Application;
import android.database.sqlite.SQLiteOpenHelper;
import com.nilhcem.devoxxfr.data.database.DbOpenHelper;
import com.squareup.sqlbrite.BriteDatabase;
import com.squareup.sqlbrite.SqlBrite;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import rx.schedulers.Schedulers;
import timber.log.Timber;
|
package com.nilhcem.devoxxfr.core.dagger.module;
@Module
public class DatabaseModule {
static final String TAG = "database";
@Provides @Singleton SQLiteOpenHelper provideSQLiteOpenHelper(Application application) {
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/database/DbOpenHelper.java
// public class DbOpenHelper extends SQLiteOpenHelper {
//
// private static final String NAME = "devoxx.db";
// private static final int VERSION = 1;
//
// public DbOpenHelper(Context context) {
// super(context, NAME, null, VERSION);
// }
//
// @Override
// public void onCreate(SQLiteDatabase db) {
// createSpeakersTable(db);
// createSessionsTable(db);
// createSelectedSessionsTable(db);
// }
//
// @Override
// public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// }
//
// private void createSpeakersTable(SQLiteDatabase db) {
// db.execSQL("CREATE TABLE " + Speaker.TABLE + " (" +
// Speaker.ID + " INTEGER PRIMARY KEY," +
// Speaker.NAME + " VARCHAR," +
// Speaker.TITLE + " VARCHAR," +
// Speaker.BIO + " VARCHAR," +
// Speaker.WEBSITE + " VARCHAR," +
// Speaker.TWITTER + " VARCHAR," +
// Speaker.GITHUB + " VARCHAR," +
// Speaker.PHOTO + " VARCHAR);");
// }
//
// private void createSessionsTable(SQLiteDatabase db) {
// db.execSQL("CREATE TABLE " + Session.TABLE + " (" +
// Session.ID + " INTEGER PRIMARY KEY," +
// Session.START_AT + " VARCHAR," +
// Session.DURATION + " INTEGER," +
// Session.ROOM_ID + " INTEGER," +
// Session.SPEAKERS_IDS + " VARCHAR," +
// Session.TITLE + " VARCHAR," +
// Session.DESCRIPTION + " VARCHAR);");
// }
//
// private void createSelectedSessionsTable(SQLiteDatabase db) {
// db.execSQL("CREATE TABLE " + SelectedSession.TABLE + " (" +
// SelectedSession.ID + " INTEGER PRIMARY KEY AUTOINCREMENT," +
// SelectedSession.SLOT_TIME + " VARCHAR," +
// SelectedSession.SESSION_ID + " INTEGER);");
// }
// }
// Path: app/src/main/java/com/nilhcem/devoxxfr/core/dagger/module/DatabaseModule.java
import android.app.Application;
import android.database.sqlite.SQLiteOpenHelper;
import com.nilhcem.devoxxfr.data.database.DbOpenHelper;
import com.squareup.sqlbrite.BriteDatabase;
import com.squareup.sqlbrite.SqlBrite;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import rx.schedulers.Schedulers;
import timber.log.Timber;
package com.nilhcem.devoxxfr.core.dagger.module;
@Module
public class DatabaseModule {
static final String TAG = "database";
@Provides @Singleton SQLiteOpenHelper provideSQLiteOpenHelper(Application application) {
|
return new DbOpenHelper(application);
|
Nilhcem/devoxxfr-2016
|
app/src/main/java/com/nilhcem/devoxxfr/core/dagger/module/DataModule.java
|
// Path: app/src/internal/java/com/nilhcem/devoxxfr/core/dagger/OkHttpModule.java
// @Module
// public class OkHttpModule {
//
// @Provides @Singleton OkHttpClient provideOkHttpClient(OkHttpClient.Builder builder) {
// return builder.addNetworkInterceptor(new StethoInterceptor()).build();
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/core/moshi/LocalDateTimeAdapter.java
// @Singleton
// public class LocalDateTimeAdapter {
//
// private final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm", Locale.US);
//
// @Inject
// public LocalDateTimeAdapter() {
// }
//
// @ToJson
// public String toText(LocalDateTime dateTime) {
// return dateTime.format(formatter);
// }
//
// @FromJson
// public LocalDateTime fromText(String text) {
// return LocalDateTime.parse(text, formatter);
// }
// }
|
import android.app.Application;
import android.content.SharedPreferences;
import android.support.v7.preference.PreferenceManager;
import com.jakewharton.picasso.OkHttp3Downloader;
import com.nilhcem.devoxxfr.core.dagger.OkHttpModule;
import com.nilhcem.devoxxfr.core.moshi.LocalDateTimeAdapter;
import com.squareup.moshi.Moshi;
import com.squareup.picasso.Picasso;
import java.io.File;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import okhttp3.Cache;
import okhttp3.OkHttpClient;
import timber.log.Timber;
|
package com.nilhcem.devoxxfr.core.dagger.module;
@Module(includes = OkHttpModule.class)
public final class DataModule {
private static final long DISK_CACHE_SIZE = 31_457_280; // 30MB
@Provides @Singleton SharedPreferences provideSharedPreferences(Application app) {
return PreferenceManager.getDefaultSharedPreferences(app);
}
|
// Path: app/src/internal/java/com/nilhcem/devoxxfr/core/dagger/OkHttpModule.java
// @Module
// public class OkHttpModule {
//
// @Provides @Singleton OkHttpClient provideOkHttpClient(OkHttpClient.Builder builder) {
// return builder.addNetworkInterceptor(new StethoInterceptor()).build();
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/core/moshi/LocalDateTimeAdapter.java
// @Singleton
// public class LocalDateTimeAdapter {
//
// private final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm", Locale.US);
//
// @Inject
// public LocalDateTimeAdapter() {
// }
//
// @ToJson
// public String toText(LocalDateTime dateTime) {
// return dateTime.format(formatter);
// }
//
// @FromJson
// public LocalDateTime fromText(String text) {
// return LocalDateTime.parse(text, formatter);
// }
// }
// Path: app/src/main/java/com/nilhcem/devoxxfr/core/dagger/module/DataModule.java
import android.app.Application;
import android.content.SharedPreferences;
import android.support.v7.preference.PreferenceManager;
import com.jakewharton.picasso.OkHttp3Downloader;
import com.nilhcem.devoxxfr.core.dagger.OkHttpModule;
import com.nilhcem.devoxxfr.core.moshi.LocalDateTimeAdapter;
import com.squareup.moshi.Moshi;
import com.squareup.picasso.Picasso;
import java.io.File;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import okhttp3.Cache;
import okhttp3.OkHttpClient;
import timber.log.Timber;
package com.nilhcem.devoxxfr.core.dagger.module;
@Module(includes = OkHttpModule.class)
public final class DataModule {
private static final long DISK_CACHE_SIZE = 31_457_280; // 30MB
@Provides @Singleton SharedPreferences provideSharedPreferences(Application app) {
return PreferenceManager.getDefaultSharedPreferences(app);
}
|
@Provides @Singleton Moshi provideMoshi(LocalDateTimeAdapter localDateTimeAdapter) {
|
Nilhcem/devoxxfr-2016
|
app/src/test/java/com/nilhcem/devoxxfr/utils/AppTest.java
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Session.java
// @Value
// public class Session implements Parcelable {
//
// public static final Parcelable.Creator<Session> CREATOR = new Parcelable.Creator<Session>() {
// public Session createFromParcel(Parcel source) {
// return new Session(source);
// }
//
// public Session[] newArray(int size) {
// return new Session[size];
// }
// };
//
// int id;
// String room;
// List<Speaker> speakers;
// String title;
// String description;
// LocalDateTime fromTime;
// LocalDateTime toTime;
//
// public Session(int id, String room, List<Speaker> speakers, String title, String description, LocalDateTime fromTime, LocalDateTime toTime) {
// this.id = id;
// this.room = room;
// this.speakers = speakers;
// this.title = title;
// this.description = description;
// this.fromTime = fromTime;
// this.toTime = toTime;
// }
//
// protected Session(Parcel in) {
// id = in.readInt();
// room = in.readString();
// speakers = in.createTypedArrayList(Speaker.CREATOR);
// title = in.readString();
// description = in.readString();
// fromTime = (LocalDateTime) in.readSerializable();
// toTime = (LocalDateTime) in.readSerializable();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(room);
// dest.writeTypedList(speakers);
// dest.writeString(title);
// dest.writeString(description);
// dest.writeSerializable(fromTime);
// dest.writeSerializable(toTime);
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Speaker.java
// @Value
// public class Speaker implements Parcelable {
//
// public static final Parcelable.Creator<Speaker> CREATOR = new Parcelable.Creator<Speaker>() {
// public Speaker createFromParcel(Parcel source) {
// return new Speaker(source);
// }
//
// public Speaker[] newArray(int size) {
// return new Speaker[size];
// }
// };
//
// int id;
// String name;
// String title;
// String bio;
// String website;
// String twitter;
// String github;
// String photo;
//
// public Speaker(int id, String name, String title, String bio, String website, String twitter, String github, String photo) {
// this.id = id;
// this.name = name;
// this.title = title;
// this.bio = bio;
// this.website = website;
// this.twitter = twitter;
// this.github = github;
// this.photo = photo;
// }
//
// protected Speaker(Parcel in) {
// id = in.readInt();
// name = in.readString();
// title = in.readString();
// bio = in.readString();
// website = in.readString();
// twitter = in.readString();
// github = in.readString();
// photo = in.readString();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(name);
// dest.writeString(title);
// dest.writeString(bio);
// dest.writeString(website);
// dest.writeString(twitter);
// dest.writeString(github);
// dest.writeString(photo);
// }
// }
|
import com.nilhcem.devoxxfr.BuildConfig;
import com.nilhcem.devoxxfr.data.app.model.Session;
import com.nilhcem.devoxxfr.data.app.model.Speaker;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.TruthJUnit.assume;
|
package com.nilhcem.devoxxfr.utils;
public class AppTest {
@Test
public void should_return_true_when_api_is_compatible() {
// Given
int apiLevelCompatible = android.os.Build.VERSION.SDK_INT;
int apiLevelBelow = android.os.Build.VERSION.SDK_INT - 1;
// When
boolean result1 = App.isCompatible(apiLevelCompatible);
boolean result2 = App.isCompatible(apiLevelBelow);
// Then
assertThat(result1).isTrue();
assertThat(result2).isTrue();
}
@Test
public void should_return_false_when_api_is_incompatible() {
// Given
int apiLevelIncompatible = android.os.Build.VERSION.SDK_INT + 1;
// When
boolean result = App.isCompatible(apiLevelIncompatible);
// Then
assertThat(result).isFalse();
}
@Test
public void should_return_formatted_string_version() {
// Given
assume().withFailureMessage("Do not test internal builds").that(BuildConfig.INTERNAL_BUILD).isFalse();
String expected = BuildConfig.VERSION_NAME + " (#" + BuildConfig.VERSION_CODE + ")";
// When
String version = App.getVersion();
// Then
assertThat(version).isEqualTo(expected);
}
@Test
public void should_return_null_photourl_when_giving_invalid_data() {
// Given
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Session.java
// @Value
// public class Session implements Parcelable {
//
// public static final Parcelable.Creator<Session> CREATOR = new Parcelable.Creator<Session>() {
// public Session createFromParcel(Parcel source) {
// return new Session(source);
// }
//
// public Session[] newArray(int size) {
// return new Session[size];
// }
// };
//
// int id;
// String room;
// List<Speaker> speakers;
// String title;
// String description;
// LocalDateTime fromTime;
// LocalDateTime toTime;
//
// public Session(int id, String room, List<Speaker> speakers, String title, String description, LocalDateTime fromTime, LocalDateTime toTime) {
// this.id = id;
// this.room = room;
// this.speakers = speakers;
// this.title = title;
// this.description = description;
// this.fromTime = fromTime;
// this.toTime = toTime;
// }
//
// protected Session(Parcel in) {
// id = in.readInt();
// room = in.readString();
// speakers = in.createTypedArrayList(Speaker.CREATOR);
// title = in.readString();
// description = in.readString();
// fromTime = (LocalDateTime) in.readSerializable();
// toTime = (LocalDateTime) in.readSerializable();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(room);
// dest.writeTypedList(speakers);
// dest.writeString(title);
// dest.writeString(description);
// dest.writeSerializable(fromTime);
// dest.writeSerializable(toTime);
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Speaker.java
// @Value
// public class Speaker implements Parcelable {
//
// public static final Parcelable.Creator<Speaker> CREATOR = new Parcelable.Creator<Speaker>() {
// public Speaker createFromParcel(Parcel source) {
// return new Speaker(source);
// }
//
// public Speaker[] newArray(int size) {
// return new Speaker[size];
// }
// };
//
// int id;
// String name;
// String title;
// String bio;
// String website;
// String twitter;
// String github;
// String photo;
//
// public Speaker(int id, String name, String title, String bio, String website, String twitter, String github, String photo) {
// this.id = id;
// this.name = name;
// this.title = title;
// this.bio = bio;
// this.website = website;
// this.twitter = twitter;
// this.github = github;
// this.photo = photo;
// }
//
// protected Speaker(Parcel in) {
// id = in.readInt();
// name = in.readString();
// title = in.readString();
// bio = in.readString();
// website = in.readString();
// twitter = in.readString();
// github = in.readString();
// photo = in.readString();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(name);
// dest.writeString(title);
// dest.writeString(bio);
// dest.writeString(website);
// dest.writeString(twitter);
// dest.writeString(github);
// dest.writeString(photo);
// }
// }
// Path: app/src/test/java/com/nilhcem/devoxxfr/utils/AppTest.java
import com.nilhcem.devoxxfr.BuildConfig;
import com.nilhcem.devoxxfr.data.app.model.Session;
import com.nilhcem.devoxxfr.data.app.model.Speaker;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.TruthJUnit.assume;
package com.nilhcem.devoxxfr.utils;
public class AppTest {
@Test
public void should_return_true_when_api_is_compatible() {
// Given
int apiLevelCompatible = android.os.Build.VERSION.SDK_INT;
int apiLevelBelow = android.os.Build.VERSION.SDK_INT - 1;
// When
boolean result1 = App.isCompatible(apiLevelCompatible);
boolean result2 = App.isCompatible(apiLevelBelow);
// Then
assertThat(result1).isTrue();
assertThat(result2).isTrue();
}
@Test
public void should_return_false_when_api_is_incompatible() {
// Given
int apiLevelIncompatible = android.os.Build.VERSION.SDK_INT + 1;
// When
boolean result = App.isCompatible(apiLevelIncompatible);
// Then
assertThat(result).isFalse();
}
@Test
public void should_return_formatted_string_version() {
// Given
assume().withFailureMessage("Do not test internal builds").that(BuildConfig.INTERNAL_BUILD).isFalse();
String expected = BuildConfig.VERSION_NAME + " (#" + BuildConfig.VERSION_CODE + ")";
// When
String version = App.getVersion();
// Then
assertThat(version).isEqualTo(expected);
}
@Test
public void should_return_null_photourl_when_giving_invalid_data() {
// Given
|
Session session1 = null;
|
Nilhcem/devoxxfr-2016
|
app/src/test/java/com/nilhcem/devoxxfr/utils/AppTest.java
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Session.java
// @Value
// public class Session implements Parcelable {
//
// public static final Parcelable.Creator<Session> CREATOR = new Parcelable.Creator<Session>() {
// public Session createFromParcel(Parcel source) {
// return new Session(source);
// }
//
// public Session[] newArray(int size) {
// return new Session[size];
// }
// };
//
// int id;
// String room;
// List<Speaker> speakers;
// String title;
// String description;
// LocalDateTime fromTime;
// LocalDateTime toTime;
//
// public Session(int id, String room, List<Speaker> speakers, String title, String description, LocalDateTime fromTime, LocalDateTime toTime) {
// this.id = id;
// this.room = room;
// this.speakers = speakers;
// this.title = title;
// this.description = description;
// this.fromTime = fromTime;
// this.toTime = toTime;
// }
//
// protected Session(Parcel in) {
// id = in.readInt();
// room = in.readString();
// speakers = in.createTypedArrayList(Speaker.CREATOR);
// title = in.readString();
// description = in.readString();
// fromTime = (LocalDateTime) in.readSerializable();
// toTime = (LocalDateTime) in.readSerializable();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(room);
// dest.writeTypedList(speakers);
// dest.writeString(title);
// dest.writeString(description);
// dest.writeSerializable(fromTime);
// dest.writeSerializable(toTime);
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Speaker.java
// @Value
// public class Speaker implements Parcelable {
//
// public static final Parcelable.Creator<Speaker> CREATOR = new Parcelable.Creator<Speaker>() {
// public Speaker createFromParcel(Parcel source) {
// return new Speaker(source);
// }
//
// public Speaker[] newArray(int size) {
// return new Speaker[size];
// }
// };
//
// int id;
// String name;
// String title;
// String bio;
// String website;
// String twitter;
// String github;
// String photo;
//
// public Speaker(int id, String name, String title, String bio, String website, String twitter, String github, String photo) {
// this.id = id;
// this.name = name;
// this.title = title;
// this.bio = bio;
// this.website = website;
// this.twitter = twitter;
// this.github = github;
// this.photo = photo;
// }
//
// protected Speaker(Parcel in) {
// id = in.readInt();
// name = in.readString();
// title = in.readString();
// bio = in.readString();
// website = in.readString();
// twitter = in.readString();
// github = in.readString();
// photo = in.readString();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(name);
// dest.writeString(title);
// dest.writeString(bio);
// dest.writeString(website);
// dest.writeString(twitter);
// dest.writeString(github);
// dest.writeString(photo);
// }
// }
|
import com.nilhcem.devoxxfr.BuildConfig;
import com.nilhcem.devoxxfr.data.app.model.Session;
import com.nilhcem.devoxxfr.data.app.model.Speaker;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.TruthJUnit.assume;
|
String expected = BuildConfig.VERSION_NAME + " (#" + BuildConfig.VERSION_CODE + ")";
// When
String version = App.getVersion();
// Then
assertThat(version).isEqualTo(expected);
}
@Test
public void should_return_null_photourl_when_giving_invalid_data() {
// Given
Session session1 = null;
Session session2 = new Session(3, "room1", null, "title", "description", null, null);
Session session3 = new Session(3, "room1", new ArrayList<>(), "title", "description", null, null);
// When
String result1 = App.getPhotoUrl(session1);
String result2 = App.getPhotoUrl(session2);
String result3 = App.getPhotoUrl(session3);
// Then
assertThat(result1).isNull();
assertThat(result2).isNull();
assertThat(result3).isNull();
}
@Test
public void should_return_photo_url_of_first_speaker() {
// Given
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Session.java
// @Value
// public class Session implements Parcelable {
//
// public static final Parcelable.Creator<Session> CREATOR = new Parcelable.Creator<Session>() {
// public Session createFromParcel(Parcel source) {
// return new Session(source);
// }
//
// public Session[] newArray(int size) {
// return new Session[size];
// }
// };
//
// int id;
// String room;
// List<Speaker> speakers;
// String title;
// String description;
// LocalDateTime fromTime;
// LocalDateTime toTime;
//
// public Session(int id, String room, List<Speaker> speakers, String title, String description, LocalDateTime fromTime, LocalDateTime toTime) {
// this.id = id;
// this.room = room;
// this.speakers = speakers;
// this.title = title;
// this.description = description;
// this.fromTime = fromTime;
// this.toTime = toTime;
// }
//
// protected Session(Parcel in) {
// id = in.readInt();
// room = in.readString();
// speakers = in.createTypedArrayList(Speaker.CREATOR);
// title = in.readString();
// description = in.readString();
// fromTime = (LocalDateTime) in.readSerializable();
// toTime = (LocalDateTime) in.readSerializable();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(room);
// dest.writeTypedList(speakers);
// dest.writeString(title);
// dest.writeString(description);
// dest.writeSerializable(fromTime);
// dest.writeSerializable(toTime);
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Speaker.java
// @Value
// public class Speaker implements Parcelable {
//
// public static final Parcelable.Creator<Speaker> CREATOR = new Parcelable.Creator<Speaker>() {
// public Speaker createFromParcel(Parcel source) {
// return new Speaker(source);
// }
//
// public Speaker[] newArray(int size) {
// return new Speaker[size];
// }
// };
//
// int id;
// String name;
// String title;
// String bio;
// String website;
// String twitter;
// String github;
// String photo;
//
// public Speaker(int id, String name, String title, String bio, String website, String twitter, String github, String photo) {
// this.id = id;
// this.name = name;
// this.title = title;
// this.bio = bio;
// this.website = website;
// this.twitter = twitter;
// this.github = github;
// this.photo = photo;
// }
//
// protected Speaker(Parcel in) {
// id = in.readInt();
// name = in.readString();
// title = in.readString();
// bio = in.readString();
// website = in.readString();
// twitter = in.readString();
// github = in.readString();
// photo = in.readString();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(name);
// dest.writeString(title);
// dest.writeString(bio);
// dest.writeString(website);
// dest.writeString(twitter);
// dest.writeString(github);
// dest.writeString(photo);
// }
// }
// Path: app/src/test/java/com/nilhcem/devoxxfr/utils/AppTest.java
import com.nilhcem.devoxxfr.BuildConfig;
import com.nilhcem.devoxxfr.data.app.model.Session;
import com.nilhcem.devoxxfr.data.app.model.Speaker;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.TruthJUnit.assume;
String expected = BuildConfig.VERSION_NAME + " (#" + BuildConfig.VERSION_CODE + ")";
// When
String version = App.getVersion();
// Then
assertThat(version).isEqualTo(expected);
}
@Test
public void should_return_null_photourl_when_giving_invalid_data() {
// Given
Session session1 = null;
Session session2 = new Session(3, "room1", null, "title", "description", null, null);
Session session3 = new Session(3, "room1", new ArrayList<>(), "title", "description", null, null);
// When
String result1 = App.getPhotoUrl(session1);
String result2 = App.getPhotoUrl(session2);
String result3 = App.getPhotoUrl(session3);
// Then
assertThat(result1).isNull();
assertThat(result2).isNull();
assertThat(result3).isNull();
}
@Test
public void should_return_photo_url_of_first_speaker() {
// Given
|
Speaker speaker1 = new Speaker(1, null, null, null, null, null, null, "photo1");
|
Nilhcem/devoxxfr-2016
|
app/src/main/java/com/nilhcem/devoxxfr/ui/sessions/list/SessionsListView.java
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Session.java
// @Value
// public class Session implements Parcelable {
//
// public static final Parcelable.Creator<Session> CREATOR = new Parcelable.Creator<Session>() {
// public Session createFromParcel(Parcel source) {
// return new Session(source);
// }
//
// public Session[] newArray(int size) {
// return new Session[size];
// }
// };
//
// int id;
// String room;
// List<Speaker> speakers;
// String title;
// String description;
// LocalDateTime fromTime;
// LocalDateTime toTime;
//
// public Session(int id, String room, List<Speaker> speakers, String title, String description, LocalDateTime fromTime, LocalDateTime toTime) {
// this.id = id;
// this.room = room;
// this.speakers = speakers;
// this.title = title;
// this.description = description;
// this.fromTime = fromTime;
// this.toTime = toTime;
// }
//
// protected Session(Parcel in) {
// id = in.readInt();
// room = in.readString();
// speakers = in.createTypedArrayList(Speaker.CREATOR);
// title = in.readString();
// description = in.readString();
// fromTime = (LocalDateTime) in.readSerializable();
// toTime = (LocalDateTime) in.readSerializable();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(room);
// dest.writeTypedList(speakers);
// dest.writeString(title);
// dest.writeString(description);
// dest.writeSerializable(fromTime);
// dest.writeSerializable(toTime);
// }
// }
|
import com.nilhcem.devoxxfr.data.app.model.Session;
import java.util.List;
|
package com.nilhcem.devoxxfr.ui.sessions.list;
public interface SessionsListView {
void initToobar(String title);
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Session.java
// @Value
// public class Session implements Parcelable {
//
// public static final Parcelable.Creator<Session> CREATOR = new Parcelable.Creator<Session>() {
// public Session createFromParcel(Parcel source) {
// return new Session(source);
// }
//
// public Session[] newArray(int size) {
// return new Session[size];
// }
// };
//
// int id;
// String room;
// List<Speaker> speakers;
// String title;
// String description;
// LocalDateTime fromTime;
// LocalDateTime toTime;
//
// public Session(int id, String room, List<Speaker> speakers, String title, String description, LocalDateTime fromTime, LocalDateTime toTime) {
// this.id = id;
// this.room = room;
// this.speakers = speakers;
// this.title = title;
// this.description = description;
// this.fromTime = fromTime;
// this.toTime = toTime;
// }
//
// protected Session(Parcel in) {
// id = in.readInt();
// room = in.readString();
// speakers = in.createTypedArrayList(Speaker.CREATOR);
// title = in.readString();
// description = in.readString();
// fromTime = (LocalDateTime) in.readSerializable();
// toTime = (LocalDateTime) in.readSerializable();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(room);
// dest.writeTypedList(speakers);
// dest.writeString(title);
// dest.writeString(description);
// dest.writeSerializable(fromTime);
// dest.writeSerializable(toTime);
// }
// }
// Path: app/src/main/java/com/nilhcem/devoxxfr/ui/sessions/list/SessionsListView.java
import com.nilhcem.devoxxfr.data.app.model.Session;
import java.util.List;
package com.nilhcem.devoxxfr.ui.sessions.list;
public interface SessionsListView {
void initToobar(String title);
|
void initSessionsList(List<Session> sessions);
|
Nilhcem/devoxxfr-2016
|
app/src/main/java/com/nilhcem/devoxxfr/ui/settings/SettingsFragment.java
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/DevoxxApp.java
// @DebugLog
// public class DevoxxApp extends Application {
//
// private AppComponent component;
//
// public static DevoxxApp get(Context context) {
// return (DevoxxApp) context.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// AndroidThreeTen.init(this);
// initGraph();
// initLogger();
// }
//
// public AppComponent component() {
// return component;
// }
//
// private void initGraph() {
// component = AppComponent.Initializer.init(this);
// }
//
// private void initLogger() {
// Timber.plant(new Timber.DebugTree());
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/receiver/reminder/SessionsReminder.java
// @Singleton
// public class SessionsReminder {
//
// private final Context context;
// private final SessionsDao sessionsDao;
// private final SharedPreferences preferences;
// private final AlarmManager alarmManager;
//
// @Inject
// public SessionsReminder(Application app, SessionsDao sessionsDao, SharedPreferences preferences) {
// this.context = app;
// this.sessionsDao = sessionsDao;
// this.preferences = preferences;
// alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
// }
//
// public boolean isEnabled() {
// return preferences.getBoolean(context.getString(R.string.settings_notify_key), false);
// }
//
// public void enableSessionReminder() {
// performOnSelectedSessions(this::addSessionReminder);
// }
//
// public void disableSessionReminder() {
// performOnSelectedSessions(this::removeSessionReminder);
// }
//
// public void addSessionReminder(@NonNull Session session) {
// if (!isEnabled()) {
// Timber.d("SessionsReminder is not enable, skip adding session");
// return;
// }
//
// PendingIntent intent = createSessionReminderIntent(session);
// LocalDateTime now = LocalDateTime.now();
// LocalDateTime sessionStartTime = session.getFromTime().minusMinutes(3);
// if (!sessionStartTime.isAfter(now)) {
// Timber.w("Do not set reminder for passed session");
// return;
// }
// Timber.d("Setting reminder on %s", sessionStartTime);
// App.setExactAlarm(alarmManager, sessionStartTime.atZone(ZoneOffset.systemDefault()).toInstant().toEpochMilli(), intent);
// }
//
// public void removeSessionReminder(@NonNull Session session) {
// Timber.d("Cancelling reminder on %s", session.getFromTime().minusMinutes(3));
// createSessionReminderIntent(session).cancel();
// }
//
// private PendingIntent createSessionReminderIntent(@NonNull Session session) {
// Intent intent = new ReminderReceiverIntentBuilder(session).build(context);
// return PendingIntent.getBroadcast(context, session.getId(), intent, PendingIntent.FLAG_UPDATE_CURRENT);
// }
//
// private void performOnSelectedSessions(Action1<? super Session> onNext) {
// sessionsDao.getSelectedSessions()
// .flatMap(Observable::from)
// .subscribeOn(Schedulers.io())
// .observeOn(Schedulers.computation())
// .subscribe(onNext, throwable -> Timber.e(throwable, "Error getting sessions"));
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/utils/Intents.java
// public final class Intents {
//
// private Intents() {
// throw new UnsupportedOperationException();
// }
//
// public static boolean startUri(@NonNull Context context, @NonNull String url) {
// Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
// if (intent.resolveActivity(context.getPackageManager()) != null) {
// context.startActivity(intent);
// return true;
// }
// return false;
// }
//
// public static void startExternalUrl(@NonNull Activity activity, @NonNull String url) {
// CustomTabsIntent intent = new CustomTabsIntent.Builder()
// .setShowTitle(true)
// .setToolbarColor(ContextCompat.getColor(activity, R.color.primary))
// .build();
// intent.launchUrl(activity, Uri.parse(url));
// }
// }
|
import android.os.Bundle;
import android.support.annotation.StringRes;
import android.support.v7.preference.CheckBoxPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceFragmentCompat;
import com.nilhcem.devoxxfr.DevoxxApp;
import com.nilhcem.devoxxfr.R;
import com.nilhcem.devoxxfr.receiver.reminder.SessionsReminder;
import com.nilhcem.devoxxfr.utils.Intents;
import javax.inject.Inject;
|
package com.nilhcem.devoxxfr.ui.settings;
public class SettingsFragment extends PreferenceFragmentCompat implements SettingsView {
@Inject SessionsReminder sessionsReminder;
private SettingsPresenter presenter;
private CheckBoxPreference notifySessions;
private Preference appVersion;
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
bindPreferences();
initPresenter();
notifySessions.setOnPreferenceChangeListener((preference, newValue) ->
presenter.onNotifySessionsChange((Boolean) newValue));
}
@Override
public void setNotifySessionsCheckbox(boolean checked) {
notifySessions.setChecked(checked);
}
@Override
public void setAppVersion(CharSequence version) {
appVersion.setSummary(version);
}
private void initPresenter() {
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/DevoxxApp.java
// @DebugLog
// public class DevoxxApp extends Application {
//
// private AppComponent component;
//
// public static DevoxxApp get(Context context) {
// return (DevoxxApp) context.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// AndroidThreeTen.init(this);
// initGraph();
// initLogger();
// }
//
// public AppComponent component() {
// return component;
// }
//
// private void initGraph() {
// component = AppComponent.Initializer.init(this);
// }
//
// private void initLogger() {
// Timber.plant(new Timber.DebugTree());
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/receiver/reminder/SessionsReminder.java
// @Singleton
// public class SessionsReminder {
//
// private final Context context;
// private final SessionsDao sessionsDao;
// private final SharedPreferences preferences;
// private final AlarmManager alarmManager;
//
// @Inject
// public SessionsReminder(Application app, SessionsDao sessionsDao, SharedPreferences preferences) {
// this.context = app;
// this.sessionsDao = sessionsDao;
// this.preferences = preferences;
// alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
// }
//
// public boolean isEnabled() {
// return preferences.getBoolean(context.getString(R.string.settings_notify_key), false);
// }
//
// public void enableSessionReminder() {
// performOnSelectedSessions(this::addSessionReminder);
// }
//
// public void disableSessionReminder() {
// performOnSelectedSessions(this::removeSessionReminder);
// }
//
// public void addSessionReminder(@NonNull Session session) {
// if (!isEnabled()) {
// Timber.d("SessionsReminder is not enable, skip adding session");
// return;
// }
//
// PendingIntent intent = createSessionReminderIntent(session);
// LocalDateTime now = LocalDateTime.now();
// LocalDateTime sessionStartTime = session.getFromTime().minusMinutes(3);
// if (!sessionStartTime.isAfter(now)) {
// Timber.w("Do not set reminder for passed session");
// return;
// }
// Timber.d("Setting reminder on %s", sessionStartTime);
// App.setExactAlarm(alarmManager, sessionStartTime.atZone(ZoneOffset.systemDefault()).toInstant().toEpochMilli(), intent);
// }
//
// public void removeSessionReminder(@NonNull Session session) {
// Timber.d("Cancelling reminder on %s", session.getFromTime().minusMinutes(3));
// createSessionReminderIntent(session).cancel();
// }
//
// private PendingIntent createSessionReminderIntent(@NonNull Session session) {
// Intent intent = new ReminderReceiverIntentBuilder(session).build(context);
// return PendingIntent.getBroadcast(context, session.getId(), intent, PendingIntent.FLAG_UPDATE_CURRENT);
// }
//
// private void performOnSelectedSessions(Action1<? super Session> onNext) {
// sessionsDao.getSelectedSessions()
// .flatMap(Observable::from)
// .subscribeOn(Schedulers.io())
// .observeOn(Schedulers.computation())
// .subscribe(onNext, throwable -> Timber.e(throwable, "Error getting sessions"));
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/utils/Intents.java
// public final class Intents {
//
// private Intents() {
// throw new UnsupportedOperationException();
// }
//
// public static boolean startUri(@NonNull Context context, @NonNull String url) {
// Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
// if (intent.resolveActivity(context.getPackageManager()) != null) {
// context.startActivity(intent);
// return true;
// }
// return false;
// }
//
// public static void startExternalUrl(@NonNull Activity activity, @NonNull String url) {
// CustomTabsIntent intent = new CustomTabsIntent.Builder()
// .setShowTitle(true)
// .setToolbarColor(ContextCompat.getColor(activity, R.color.primary))
// .build();
// intent.launchUrl(activity, Uri.parse(url));
// }
// }
// Path: app/src/main/java/com/nilhcem/devoxxfr/ui/settings/SettingsFragment.java
import android.os.Bundle;
import android.support.annotation.StringRes;
import android.support.v7.preference.CheckBoxPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceFragmentCompat;
import com.nilhcem.devoxxfr.DevoxxApp;
import com.nilhcem.devoxxfr.R;
import com.nilhcem.devoxxfr.receiver.reminder.SessionsReminder;
import com.nilhcem.devoxxfr.utils.Intents;
import javax.inject.Inject;
package com.nilhcem.devoxxfr.ui.settings;
public class SettingsFragment extends PreferenceFragmentCompat implements SettingsView {
@Inject SessionsReminder sessionsReminder;
private SettingsPresenter presenter;
private CheckBoxPreference notifySessions;
private Preference appVersion;
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
bindPreferences();
initPresenter();
notifySessions.setOnPreferenceChangeListener((preference, newValue) ->
presenter.onNotifySessionsChange((Boolean) newValue));
}
@Override
public void setNotifySessionsCheckbox(boolean checked) {
notifySessions.setChecked(checked);
}
@Override
public void setAppVersion(CharSequence version) {
appVersion.setSummary(version);
}
private void initPresenter() {
|
DevoxxApp.get(getContext()).component().inject(this);
|
Nilhcem/devoxxfr-2016
|
app/src/main/java/com/nilhcem/devoxxfr/ui/settings/SettingsFragment.java
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/DevoxxApp.java
// @DebugLog
// public class DevoxxApp extends Application {
//
// private AppComponent component;
//
// public static DevoxxApp get(Context context) {
// return (DevoxxApp) context.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// AndroidThreeTen.init(this);
// initGraph();
// initLogger();
// }
//
// public AppComponent component() {
// return component;
// }
//
// private void initGraph() {
// component = AppComponent.Initializer.init(this);
// }
//
// private void initLogger() {
// Timber.plant(new Timber.DebugTree());
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/receiver/reminder/SessionsReminder.java
// @Singleton
// public class SessionsReminder {
//
// private final Context context;
// private final SessionsDao sessionsDao;
// private final SharedPreferences preferences;
// private final AlarmManager alarmManager;
//
// @Inject
// public SessionsReminder(Application app, SessionsDao sessionsDao, SharedPreferences preferences) {
// this.context = app;
// this.sessionsDao = sessionsDao;
// this.preferences = preferences;
// alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
// }
//
// public boolean isEnabled() {
// return preferences.getBoolean(context.getString(R.string.settings_notify_key), false);
// }
//
// public void enableSessionReminder() {
// performOnSelectedSessions(this::addSessionReminder);
// }
//
// public void disableSessionReminder() {
// performOnSelectedSessions(this::removeSessionReminder);
// }
//
// public void addSessionReminder(@NonNull Session session) {
// if (!isEnabled()) {
// Timber.d("SessionsReminder is not enable, skip adding session");
// return;
// }
//
// PendingIntent intent = createSessionReminderIntent(session);
// LocalDateTime now = LocalDateTime.now();
// LocalDateTime sessionStartTime = session.getFromTime().minusMinutes(3);
// if (!sessionStartTime.isAfter(now)) {
// Timber.w("Do not set reminder for passed session");
// return;
// }
// Timber.d("Setting reminder on %s", sessionStartTime);
// App.setExactAlarm(alarmManager, sessionStartTime.atZone(ZoneOffset.systemDefault()).toInstant().toEpochMilli(), intent);
// }
//
// public void removeSessionReminder(@NonNull Session session) {
// Timber.d("Cancelling reminder on %s", session.getFromTime().minusMinutes(3));
// createSessionReminderIntent(session).cancel();
// }
//
// private PendingIntent createSessionReminderIntent(@NonNull Session session) {
// Intent intent = new ReminderReceiverIntentBuilder(session).build(context);
// return PendingIntent.getBroadcast(context, session.getId(), intent, PendingIntent.FLAG_UPDATE_CURRENT);
// }
//
// private void performOnSelectedSessions(Action1<? super Session> onNext) {
// sessionsDao.getSelectedSessions()
// .flatMap(Observable::from)
// .subscribeOn(Schedulers.io())
// .observeOn(Schedulers.computation())
// .subscribe(onNext, throwable -> Timber.e(throwable, "Error getting sessions"));
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/utils/Intents.java
// public final class Intents {
//
// private Intents() {
// throw new UnsupportedOperationException();
// }
//
// public static boolean startUri(@NonNull Context context, @NonNull String url) {
// Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
// if (intent.resolveActivity(context.getPackageManager()) != null) {
// context.startActivity(intent);
// return true;
// }
// return false;
// }
//
// public static void startExternalUrl(@NonNull Activity activity, @NonNull String url) {
// CustomTabsIntent intent = new CustomTabsIntent.Builder()
// .setShowTitle(true)
// .setToolbarColor(ContextCompat.getColor(activity, R.color.primary))
// .build();
// intent.launchUrl(activity, Uri.parse(url));
// }
// }
|
import android.os.Bundle;
import android.support.annotation.StringRes;
import android.support.v7.preference.CheckBoxPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceFragmentCompat;
import com.nilhcem.devoxxfr.DevoxxApp;
import com.nilhcem.devoxxfr.R;
import com.nilhcem.devoxxfr.receiver.reminder.SessionsReminder;
import com.nilhcem.devoxxfr.utils.Intents;
import javax.inject.Inject;
|
public void setNotifySessionsCheckbox(boolean checked) {
notifySessions.setChecked(checked);
}
@Override
public void setAppVersion(CharSequence version) {
appVersion.setSummary(version);
}
private void initPresenter() {
DevoxxApp.get(getContext()).component().inject(this);
presenter = new SettingsPresenter(getContext(), this, sessionsReminder);
presenter.onCreate();
}
private void bindPreferences() {
addPreferencesFromResource(R.xml.settings);
notifySessions = findPreference(R.string.settings_notify_key);
appVersion = findPreference(R.string.settings_version_key);
initPreferenceLink(R.string.settings_conf_key);
initPreferenceLink(R.string.settings_github_key);
initPreferenceLink(R.string.settings_developer_key);
}
private <T extends Preference> T findPreference(@StringRes int resId) {
return (T) findPreference(getString(resId));
}
private void initPreferenceLink(@StringRes int resId) {
findPreference(resId).setOnPreferenceClickListener(preference -> {
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/DevoxxApp.java
// @DebugLog
// public class DevoxxApp extends Application {
//
// private AppComponent component;
//
// public static DevoxxApp get(Context context) {
// return (DevoxxApp) context.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// AndroidThreeTen.init(this);
// initGraph();
// initLogger();
// }
//
// public AppComponent component() {
// return component;
// }
//
// private void initGraph() {
// component = AppComponent.Initializer.init(this);
// }
//
// private void initLogger() {
// Timber.plant(new Timber.DebugTree());
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/receiver/reminder/SessionsReminder.java
// @Singleton
// public class SessionsReminder {
//
// private final Context context;
// private final SessionsDao sessionsDao;
// private final SharedPreferences preferences;
// private final AlarmManager alarmManager;
//
// @Inject
// public SessionsReminder(Application app, SessionsDao sessionsDao, SharedPreferences preferences) {
// this.context = app;
// this.sessionsDao = sessionsDao;
// this.preferences = preferences;
// alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
// }
//
// public boolean isEnabled() {
// return preferences.getBoolean(context.getString(R.string.settings_notify_key), false);
// }
//
// public void enableSessionReminder() {
// performOnSelectedSessions(this::addSessionReminder);
// }
//
// public void disableSessionReminder() {
// performOnSelectedSessions(this::removeSessionReminder);
// }
//
// public void addSessionReminder(@NonNull Session session) {
// if (!isEnabled()) {
// Timber.d("SessionsReminder is not enable, skip adding session");
// return;
// }
//
// PendingIntent intent = createSessionReminderIntent(session);
// LocalDateTime now = LocalDateTime.now();
// LocalDateTime sessionStartTime = session.getFromTime().minusMinutes(3);
// if (!sessionStartTime.isAfter(now)) {
// Timber.w("Do not set reminder for passed session");
// return;
// }
// Timber.d("Setting reminder on %s", sessionStartTime);
// App.setExactAlarm(alarmManager, sessionStartTime.atZone(ZoneOffset.systemDefault()).toInstant().toEpochMilli(), intent);
// }
//
// public void removeSessionReminder(@NonNull Session session) {
// Timber.d("Cancelling reminder on %s", session.getFromTime().minusMinutes(3));
// createSessionReminderIntent(session).cancel();
// }
//
// private PendingIntent createSessionReminderIntent(@NonNull Session session) {
// Intent intent = new ReminderReceiverIntentBuilder(session).build(context);
// return PendingIntent.getBroadcast(context, session.getId(), intent, PendingIntent.FLAG_UPDATE_CURRENT);
// }
//
// private void performOnSelectedSessions(Action1<? super Session> onNext) {
// sessionsDao.getSelectedSessions()
// .flatMap(Observable::from)
// .subscribeOn(Schedulers.io())
// .observeOn(Schedulers.computation())
// .subscribe(onNext, throwable -> Timber.e(throwable, "Error getting sessions"));
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/utils/Intents.java
// public final class Intents {
//
// private Intents() {
// throw new UnsupportedOperationException();
// }
//
// public static boolean startUri(@NonNull Context context, @NonNull String url) {
// Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
// if (intent.resolveActivity(context.getPackageManager()) != null) {
// context.startActivity(intent);
// return true;
// }
// return false;
// }
//
// public static void startExternalUrl(@NonNull Activity activity, @NonNull String url) {
// CustomTabsIntent intent = new CustomTabsIntent.Builder()
// .setShowTitle(true)
// .setToolbarColor(ContextCompat.getColor(activity, R.color.primary))
// .build();
// intent.launchUrl(activity, Uri.parse(url));
// }
// }
// Path: app/src/main/java/com/nilhcem/devoxxfr/ui/settings/SettingsFragment.java
import android.os.Bundle;
import android.support.annotation.StringRes;
import android.support.v7.preference.CheckBoxPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceFragmentCompat;
import com.nilhcem.devoxxfr.DevoxxApp;
import com.nilhcem.devoxxfr.R;
import com.nilhcem.devoxxfr.receiver.reminder.SessionsReminder;
import com.nilhcem.devoxxfr.utils.Intents;
import javax.inject.Inject;
public void setNotifySessionsCheckbox(boolean checked) {
notifySessions.setChecked(checked);
}
@Override
public void setAppVersion(CharSequence version) {
appVersion.setSummary(version);
}
private void initPresenter() {
DevoxxApp.get(getContext()).component().inject(this);
presenter = new SettingsPresenter(getContext(), this, sessionsReminder);
presenter.onCreate();
}
private void bindPreferences() {
addPreferencesFromResource(R.xml.settings);
notifySessions = findPreference(R.string.settings_notify_key);
appVersion = findPreference(R.string.settings_version_key);
initPreferenceLink(R.string.settings_conf_key);
initPreferenceLink(R.string.settings_github_key);
initPreferenceLink(R.string.settings_developer_key);
}
private <T extends Preference> T findPreference(@StringRes int resId) {
return (T) findPreference(getString(resId));
}
private void initPreferenceLink(@StringRes int resId) {
findPreference(resId).setOnPreferenceClickListener(preference -> {
|
Intents.startExternalUrl(getActivity(), preference.getSummary().toString());
|
Nilhcem/devoxxfr-2016
|
app/src/main/java/com/nilhcem/devoxxfr/data/app/SelectedSessionsMemory.java
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Session.java
// @Value
// public class Session implements Parcelable {
//
// public static final Parcelable.Creator<Session> CREATOR = new Parcelable.Creator<Session>() {
// public Session createFromParcel(Parcel source) {
// return new Session(source);
// }
//
// public Session[] newArray(int size) {
// return new Session[size];
// }
// };
//
// int id;
// String room;
// List<Speaker> speakers;
// String title;
// String description;
// LocalDateTime fromTime;
// LocalDateTime toTime;
//
// public Session(int id, String room, List<Speaker> speakers, String title, String description, LocalDateTime fromTime, LocalDateTime toTime) {
// this.id = id;
// this.room = room;
// this.speakers = speakers;
// this.title = title;
// this.description = description;
// this.fromTime = fromTime;
// this.toTime = toTime;
// }
//
// protected Session(Parcel in) {
// id = in.readInt();
// room = in.readString();
// speakers = in.createTypedArrayList(Speaker.CREATOR);
// title = in.readString();
// description = in.readString();
// fromTime = (LocalDateTime) in.readSerializable();
// toTime = (LocalDateTime) in.readSerializable();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(room);
// dest.writeTypedList(speakers);
// dest.writeString(title);
// dest.writeString(description);
// dest.writeSerializable(fromTime);
// dest.writeSerializable(toTime);
// }
// }
|
import com.nilhcem.devoxxfr.data.app.model.Session;
import org.threeten.bp.LocalDateTime;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import javax.inject.Inject;
import javax.inject.Singleton;
|
package com.nilhcem.devoxxfr.data.app;
@Singleton
public class SelectedSessionsMemory {
private final Map<LocalDateTime, Integer> selectedSessions = new ConcurrentHashMap<>();
@Inject
public SelectedSessionsMemory() {
}
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Session.java
// @Value
// public class Session implements Parcelable {
//
// public static final Parcelable.Creator<Session> CREATOR = new Parcelable.Creator<Session>() {
// public Session createFromParcel(Parcel source) {
// return new Session(source);
// }
//
// public Session[] newArray(int size) {
// return new Session[size];
// }
// };
//
// int id;
// String room;
// List<Speaker> speakers;
// String title;
// String description;
// LocalDateTime fromTime;
// LocalDateTime toTime;
//
// public Session(int id, String room, List<Speaker> speakers, String title, String description, LocalDateTime fromTime, LocalDateTime toTime) {
// this.id = id;
// this.room = room;
// this.speakers = speakers;
// this.title = title;
// this.description = description;
// this.fromTime = fromTime;
// this.toTime = toTime;
// }
//
// protected Session(Parcel in) {
// id = in.readInt();
// room = in.readString();
// speakers = in.createTypedArrayList(Speaker.CREATOR);
// title = in.readString();
// description = in.readString();
// fromTime = (LocalDateTime) in.readSerializable();
// toTime = (LocalDateTime) in.readSerializable();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(room);
// dest.writeTypedList(speakers);
// dest.writeString(title);
// dest.writeString(description);
// dest.writeSerializable(fromTime);
// dest.writeSerializable(toTime);
// }
// }
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/SelectedSessionsMemory.java
import com.nilhcem.devoxxfr.data.app.model.Session;
import org.threeten.bp.LocalDateTime;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import javax.inject.Inject;
import javax.inject.Singleton;
package com.nilhcem.devoxxfr.data.app;
@Singleton
public class SelectedSessionsMemory {
private final Map<LocalDateTime, Integer> selectedSessions = new ConcurrentHashMap<>();
@Inject
public SelectedSessionsMemory() {
}
|
public boolean isSelected(Session session) {
|
Nilhcem/devoxxfr-2016
|
app/src/main/java/com/nilhcem/devoxxfr/data/database/model/SelectedSession.java
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/utils/Database.java
// public class Database {
//
// public static String getString(Cursor cursor, String columnName) {
// return cursor.getString(cursor.getColumnIndexOrThrow(columnName));
// }
//
// public static int getInt(Cursor cursor, String columnName) {
// return cursor.getInt(cursor.getColumnIndexOrThrow(columnName));
// }
//
// private Database() {
// throw new UnsupportedOperationException();
// }
// }
|
import android.content.ContentValues;
import android.database.Cursor;
import com.nilhcem.devoxxfr.utils.Database;
import rx.functions.Func1;
|
package com.nilhcem.devoxxfr.data.database.model;
public class SelectedSession {
public static final String TABLE = "selected_sessions";
public static final String ID = "_id";
public static final String SLOT_TIME = "slot_time";
public static final String SESSION_ID = "session_id";
public final String slotTime;
public final int sessionId;
public SelectedSession(String slotTime, int sessionId) {
this.slotTime = slotTime;
this.sessionId = sessionId;
}
public static final Func1<Cursor, SelectedSession> MAPPER = cursor -> {
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/utils/Database.java
// public class Database {
//
// public static String getString(Cursor cursor, String columnName) {
// return cursor.getString(cursor.getColumnIndexOrThrow(columnName));
// }
//
// public static int getInt(Cursor cursor, String columnName) {
// return cursor.getInt(cursor.getColumnIndexOrThrow(columnName));
// }
//
// private Database() {
// throw new UnsupportedOperationException();
// }
// }
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/database/model/SelectedSession.java
import android.content.ContentValues;
import android.database.Cursor;
import com.nilhcem.devoxxfr.utils.Database;
import rx.functions.Func1;
package com.nilhcem.devoxxfr.data.database.model;
public class SelectedSession {
public static final String TABLE = "selected_sessions";
public static final String ID = "_id";
public static final String SLOT_TIME = "slot_time";
public static final String SESSION_ID = "session_id";
public final String slotTime;
public final int sessionId;
public SelectedSession(String slotTime, int sessionId) {
this.slotTime = slotTime;
this.sessionId = sessionId;
}
public static final Func1<Cursor, SelectedSession> MAPPER = cursor -> {
|
String slotTime = Database.getString(cursor, SLOT_TIME);
|
Nilhcem/devoxxfr-2016
|
app/src/main/java/com/nilhcem/devoxxfr/ui/venue/ZoomableImageActivity.java
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/ui/BaseActivity.java
// public abstract class BaseActivity<P extends BaseActivityPresenter> extends AppCompatActivity {
//
// protected P presenter;
//
// protected abstract P newPresenter();
//
// @Override
// protected void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// presenter = newPresenter();
// }
//
// @Override
// protected void onPostCreate(@Nullable Bundle savedInstanceState) {
// super.onPostCreate(savedInstanceState);
// presenter.onPostCreate(savedInstanceState);
// }
//
// @Override
// protected void onResume() {
// super.onResume();
// presenter.onResume();
// }
//
// @Override
// protected void onSaveInstanceState(Bundle outState) {
// super.onSaveInstanceState(outState);
// presenter.onSaveInstanceState(outState);
// }
//
// @Override
// protected void onRestoreInstanceState(Bundle savedInstanceState) {
// super.onRestoreInstanceState(savedInstanceState);
// presenter.onRestoreInstanceState(savedInstanceState);
// }
//
// @Override
// public void setContentView(@LayoutRes int layoutResID) {
// super.setContentView(layoutResID);
// ButterKnife.bind(this);
// }
//
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// if (item.getItemId() == android.R.id.home) {
// onBackPressed();
// return true;
// }
// return super.onOptionsItemSelected(item);
// }
//
// @Override
// public void onBackPressed() {
// if (presenter.onBackPressed()) {
// return;
// }
// super.onBackPressed();
// }
//
// @Override
// protected void onDestroy() {
// presenter = null;
// super.onDestroy();
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/ui/BaseActivityPresenter.java
// public abstract class BaseActivityPresenter<V> extends BasePresenter<V> {
//
// public BaseActivityPresenter(V view) {
// super(view);
// }
//
// public void onPostCreate(Bundle savedInstanceState) {
// // Nothing to do by default
// }
//
// public void onResume() {
// // Nothing to do by default
// }
//
// @CallSuper
// public void onSaveInstanceState(Bundle outState) {
// Icepick.saveInstanceState(this, outState);
// }
//
// @CallSuper
// public void onRestoreInstanceState(Bundle savedInstanceState) {
// Icepick.restoreInstanceState(this, savedInstanceState);
// }
//
// public void onNavigationItemSelected(@IdRes int itemId) {
// // Nothing to do by default
// }
//
// public boolean onBackPressed() {
// return false;
// }
// }
|
import android.os.Bundle;
import android.support.annotation.DrawableRes;
import android.support.annotation.Nullable;
import android.support.annotation.StringRes;
import android.support.v4.content.ContextCompat;
import com.nilhcem.devoxxfr.R;
import com.nilhcem.devoxxfr.ui.BaseActivity;
import com.nilhcem.devoxxfr.ui.BaseActivityPresenter;
import se.emilsjolander.intentbuilder.Extra;
import se.emilsjolander.intentbuilder.IntentBuilder;
import uk.co.senab.photoview.PhotoView;
|
package com.nilhcem.devoxxfr.ui.venue;
@IntentBuilder
public class ZoomableImageActivity extends BaseActivity<ZoomableImageActivity.ZoomableImageActivityPresenter> {
public static final Integer TYPE_ROOMS = 0;
public static final Integer TYPE_EXHIBITORS = 1;
@Extra Integer type;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ZoomableImageActivityIntentBuilder.inject(getIntent(), this);
PhotoView view = new PhotoView(this);
@DrawableRes int drawableRes;
@StringRes int titleRes;
if (type.equals(TYPE_ROOMS)) {
drawableRes = R.drawable.venue_rooms;
titleRes = R.string.venue_see_rooms;
} else {
drawableRes = R.drawable.venue_exhibitors;
titleRes = R.string.venue_see_exhibitors;
}
view.setImageDrawable(ContextCompat.getDrawable(this, drawableRes));
getSupportActionBar().setTitle(titleRes);
setContentView(view);
}
@Override
protected ZoomableImageActivityPresenter newPresenter() {
return new ZoomableImageActivityPresenter(this);
}
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/ui/BaseActivity.java
// public abstract class BaseActivity<P extends BaseActivityPresenter> extends AppCompatActivity {
//
// protected P presenter;
//
// protected abstract P newPresenter();
//
// @Override
// protected void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// presenter = newPresenter();
// }
//
// @Override
// protected void onPostCreate(@Nullable Bundle savedInstanceState) {
// super.onPostCreate(savedInstanceState);
// presenter.onPostCreate(savedInstanceState);
// }
//
// @Override
// protected void onResume() {
// super.onResume();
// presenter.onResume();
// }
//
// @Override
// protected void onSaveInstanceState(Bundle outState) {
// super.onSaveInstanceState(outState);
// presenter.onSaveInstanceState(outState);
// }
//
// @Override
// protected void onRestoreInstanceState(Bundle savedInstanceState) {
// super.onRestoreInstanceState(savedInstanceState);
// presenter.onRestoreInstanceState(savedInstanceState);
// }
//
// @Override
// public void setContentView(@LayoutRes int layoutResID) {
// super.setContentView(layoutResID);
// ButterKnife.bind(this);
// }
//
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// if (item.getItemId() == android.R.id.home) {
// onBackPressed();
// return true;
// }
// return super.onOptionsItemSelected(item);
// }
//
// @Override
// public void onBackPressed() {
// if (presenter.onBackPressed()) {
// return;
// }
// super.onBackPressed();
// }
//
// @Override
// protected void onDestroy() {
// presenter = null;
// super.onDestroy();
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/ui/BaseActivityPresenter.java
// public abstract class BaseActivityPresenter<V> extends BasePresenter<V> {
//
// public BaseActivityPresenter(V view) {
// super(view);
// }
//
// public void onPostCreate(Bundle savedInstanceState) {
// // Nothing to do by default
// }
//
// public void onResume() {
// // Nothing to do by default
// }
//
// @CallSuper
// public void onSaveInstanceState(Bundle outState) {
// Icepick.saveInstanceState(this, outState);
// }
//
// @CallSuper
// public void onRestoreInstanceState(Bundle savedInstanceState) {
// Icepick.restoreInstanceState(this, savedInstanceState);
// }
//
// public void onNavigationItemSelected(@IdRes int itemId) {
// // Nothing to do by default
// }
//
// public boolean onBackPressed() {
// return false;
// }
// }
// Path: app/src/main/java/com/nilhcem/devoxxfr/ui/venue/ZoomableImageActivity.java
import android.os.Bundle;
import android.support.annotation.DrawableRes;
import android.support.annotation.Nullable;
import android.support.annotation.StringRes;
import android.support.v4.content.ContextCompat;
import com.nilhcem.devoxxfr.R;
import com.nilhcem.devoxxfr.ui.BaseActivity;
import com.nilhcem.devoxxfr.ui.BaseActivityPresenter;
import se.emilsjolander.intentbuilder.Extra;
import se.emilsjolander.intentbuilder.IntentBuilder;
import uk.co.senab.photoview.PhotoView;
package com.nilhcem.devoxxfr.ui.venue;
@IntentBuilder
public class ZoomableImageActivity extends BaseActivity<ZoomableImageActivity.ZoomableImageActivityPresenter> {
public static final Integer TYPE_ROOMS = 0;
public static final Integer TYPE_EXHIBITORS = 1;
@Extra Integer type;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ZoomableImageActivityIntentBuilder.inject(getIntent(), this);
PhotoView view = new PhotoView(this);
@DrawableRes int drawableRes;
@StringRes int titleRes;
if (type.equals(TYPE_ROOMS)) {
drawableRes = R.drawable.venue_rooms;
titleRes = R.string.venue_see_rooms;
} else {
drawableRes = R.drawable.venue_exhibitors;
titleRes = R.string.venue_see_exhibitors;
}
view.setImageDrawable(ContextCompat.getDrawable(this, drawableRes));
getSupportActionBar().setTitle(titleRes);
setContentView(view);
}
@Override
protected ZoomableImageActivityPresenter newPresenter() {
return new ZoomableImageActivityPresenter(this);
}
|
static class ZoomableImageActivityPresenter extends BaseActivityPresenter<ZoomableImageActivity> {
|
Nilhcem/devoxxfr-2016
|
app/src/main/java/com/nilhcem/devoxxfr/ui/sessions/details/SessionDetailsSpeaker.java
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Speaker.java
// @Value
// public class Speaker implements Parcelable {
//
// public static final Parcelable.Creator<Speaker> CREATOR = new Parcelable.Creator<Speaker>() {
// public Speaker createFromParcel(Parcel source) {
// return new Speaker(source);
// }
//
// public Speaker[] newArray(int size) {
// return new Speaker[size];
// }
// };
//
// int id;
// String name;
// String title;
// String bio;
// String website;
// String twitter;
// String github;
// String photo;
//
// public Speaker(int id, String name, String title, String bio, String website, String twitter, String github, String photo) {
// this.id = id;
// this.name = name;
// this.title = title;
// this.bio = bio;
// this.website = website;
// this.twitter = twitter;
// this.github = github;
// this.photo = photo;
// }
//
// protected Speaker(Parcel in) {
// id = in.readInt();
// name = in.readString();
// title = in.readString();
// bio = in.readString();
// website = in.readString();
// twitter = in.readString();
// github = in.readString();
// photo = in.readString();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(name);
// dest.writeString(title);
// dest.writeString(bio);
// dest.writeString(website);
// dest.writeString(twitter);
// dest.writeString(github);
// dest.writeString(photo);
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/ui/core/picasso/CircleTransformation.java
// public class CircleTransformation implements Transformation {
//
// @Override
// public Bitmap transform(Bitmap source) {
// int size = Math.min(source.getWidth(), source.getHeight());
//
// int x = (source.getWidth() - size) / 2;
// int y = (source.getHeight() - size) / 2;
//
// Bitmap squaredBitmap = Bitmap.createBitmap(source, x, y, size, size);
// if (squaredBitmap != source) {
// source.recycle();
// }
//
// Bitmap.Config config = source.getConfig() != null ? source.getConfig() : Bitmap.Config.ARGB_8888;
// Bitmap bitmap = Bitmap.createBitmap(size, size, config);
//
// Canvas canvas = new Canvas(bitmap);
// Paint paint = new Paint();
// BitmapShader shader = new BitmapShader(squaredBitmap, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP);
// paint.setShader(shader);
// paint.setAntiAlias(true);
//
// float r = size / 2f;
// canvas.drawCircle(r, r, r, paint);
//
// squaredBitmap.recycle();
// return bitmap;
// }
//
// @Override
// public String key() {
// return "circle";
// }
// }
|
import android.content.Context;
import android.content.res.TypedArray;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import com.nilhcem.devoxxfr.R;
import com.nilhcem.devoxxfr.data.app.model.Speaker;
import com.nilhcem.devoxxfr.ui.core.picasso.CircleTransformation;
import com.squareup.picasso.Picasso;
import butterknife.Bind;
import butterknife.ButterKnife;
|
package com.nilhcem.devoxxfr.ui.sessions.details;
public class SessionDetailsSpeaker extends FrameLayout {
@Bind(R.id.session_details_speaker_photo) ImageView photo;
@Bind(R.id.session_details_speaker_name) TextView name;
@Bind(R.id.session_details_speaker_title) TextView title;
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Speaker.java
// @Value
// public class Speaker implements Parcelable {
//
// public static final Parcelable.Creator<Speaker> CREATOR = new Parcelable.Creator<Speaker>() {
// public Speaker createFromParcel(Parcel source) {
// return new Speaker(source);
// }
//
// public Speaker[] newArray(int size) {
// return new Speaker[size];
// }
// };
//
// int id;
// String name;
// String title;
// String bio;
// String website;
// String twitter;
// String github;
// String photo;
//
// public Speaker(int id, String name, String title, String bio, String website, String twitter, String github, String photo) {
// this.id = id;
// this.name = name;
// this.title = title;
// this.bio = bio;
// this.website = website;
// this.twitter = twitter;
// this.github = github;
// this.photo = photo;
// }
//
// protected Speaker(Parcel in) {
// id = in.readInt();
// name = in.readString();
// title = in.readString();
// bio = in.readString();
// website = in.readString();
// twitter = in.readString();
// github = in.readString();
// photo = in.readString();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(name);
// dest.writeString(title);
// dest.writeString(bio);
// dest.writeString(website);
// dest.writeString(twitter);
// dest.writeString(github);
// dest.writeString(photo);
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/ui/core/picasso/CircleTransformation.java
// public class CircleTransformation implements Transformation {
//
// @Override
// public Bitmap transform(Bitmap source) {
// int size = Math.min(source.getWidth(), source.getHeight());
//
// int x = (source.getWidth() - size) / 2;
// int y = (source.getHeight() - size) / 2;
//
// Bitmap squaredBitmap = Bitmap.createBitmap(source, x, y, size, size);
// if (squaredBitmap != source) {
// source.recycle();
// }
//
// Bitmap.Config config = source.getConfig() != null ? source.getConfig() : Bitmap.Config.ARGB_8888;
// Bitmap bitmap = Bitmap.createBitmap(size, size, config);
//
// Canvas canvas = new Canvas(bitmap);
// Paint paint = new Paint();
// BitmapShader shader = new BitmapShader(squaredBitmap, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP);
// paint.setShader(shader);
// paint.setAntiAlias(true);
//
// float r = size / 2f;
// canvas.drawCircle(r, r, r, paint);
//
// squaredBitmap.recycle();
// return bitmap;
// }
//
// @Override
// public String key() {
// return "circle";
// }
// }
// Path: app/src/main/java/com/nilhcem/devoxxfr/ui/sessions/details/SessionDetailsSpeaker.java
import android.content.Context;
import android.content.res.TypedArray;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import com.nilhcem.devoxxfr.R;
import com.nilhcem.devoxxfr.data.app.model.Speaker;
import com.nilhcem.devoxxfr.ui.core.picasso.CircleTransformation;
import com.squareup.picasso.Picasso;
import butterknife.Bind;
import butterknife.ButterKnife;
package com.nilhcem.devoxxfr.ui.sessions.details;
public class SessionDetailsSpeaker extends FrameLayout {
@Bind(R.id.session_details_speaker_photo) ImageView photo;
@Bind(R.id.session_details_speaker_name) TextView name;
@Bind(R.id.session_details_speaker_title) TextView title;
|
public SessionDetailsSpeaker(Context context, Speaker speaker, Picasso picasso) {
|
Nilhcem/devoxxfr-2016
|
app/src/main/java/com/nilhcem/devoxxfr/ui/sessions/details/SessionDetailsSpeaker.java
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Speaker.java
// @Value
// public class Speaker implements Parcelable {
//
// public static final Parcelable.Creator<Speaker> CREATOR = new Parcelable.Creator<Speaker>() {
// public Speaker createFromParcel(Parcel source) {
// return new Speaker(source);
// }
//
// public Speaker[] newArray(int size) {
// return new Speaker[size];
// }
// };
//
// int id;
// String name;
// String title;
// String bio;
// String website;
// String twitter;
// String github;
// String photo;
//
// public Speaker(int id, String name, String title, String bio, String website, String twitter, String github, String photo) {
// this.id = id;
// this.name = name;
// this.title = title;
// this.bio = bio;
// this.website = website;
// this.twitter = twitter;
// this.github = github;
// this.photo = photo;
// }
//
// protected Speaker(Parcel in) {
// id = in.readInt();
// name = in.readString();
// title = in.readString();
// bio = in.readString();
// website = in.readString();
// twitter = in.readString();
// github = in.readString();
// photo = in.readString();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(name);
// dest.writeString(title);
// dest.writeString(bio);
// dest.writeString(website);
// dest.writeString(twitter);
// dest.writeString(github);
// dest.writeString(photo);
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/ui/core/picasso/CircleTransformation.java
// public class CircleTransformation implements Transformation {
//
// @Override
// public Bitmap transform(Bitmap source) {
// int size = Math.min(source.getWidth(), source.getHeight());
//
// int x = (source.getWidth() - size) / 2;
// int y = (source.getHeight() - size) / 2;
//
// Bitmap squaredBitmap = Bitmap.createBitmap(source, x, y, size, size);
// if (squaredBitmap != source) {
// source.recycle();
// }
//
// Bitmap.Config config = source.getConfig() != null ? source.getConfig() : Bitmap.Config.ARGB_8888;
// Bitmap bitmap = Bitmap.createBitmap(size, size, config);
//
// Canvas canvas = new Canvas(bitmap);
// Paint paint = new Paint();
// BitmapShader shader = new BitmapShader(squaredBitmap, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP);
// paint.setShader(shader);
// paint.setAntiAlias(true);
//
// float r = size / 2f;
// canvas.drawCircle(r, r, r, paint);
//
// squaredBitmap.recycle();
// return bitmap;
// }
//
// @Override
// public String key() {
// return "circle";
// }
// }
|
import android.content.Context;
import android.content.res.TypedArray;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import com.nilhcem.devoxxfr.R;
import com.nilhcem.devoxxfr.data.app.model.Speaker;
import com.nilhcem.devoxxfr.ui.core.picasso.CircleTransformation;
import com.squareup.picasso.Picasso;
import butterknife.Bind;
import butterknife.ButterKnife;
|
package com.nilhcem.devoxxfr.ui.sessions.details;
public class SessionDetailsSpeaker extends FrameLayout {
@Bind(R.id.session_details_speaker_photo) ImageView photo;
@Bind(R.id.session_details_speaker_name) TextView name;
@Bind(R.id.session_details_speaker_title) TextView title;
public SessionDetailsSpeaker(Context context, Speaker speaker, Picasso picasso) {
super(context);
int[] attrs = new int[]{android.R.attr.selectableItemBackground};
TypedArray ta = context.obtainStyledAttributes(attrs);
setForeground(ta.getDrawable(0));
ta.recycle();
LayoutInflater.from(context).inflate(R.layout.session_details_speaker, this);
ButterKnife.bind(this, this);
bind(speaker, picasso);
}
private void bind(Speaker speaker, Picasso picasso) {
String photoUrl = speaker.getPhoto();
if (!TextUtils.isEmpty(photoUrl)) {
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Speaker.java
// @Value
// public class Speaker implements Parcelable {
//
// public static final Parcelable.Creator<Speaker> CREATOR = new Parcelable.Creator<Speaker>() {
// public Speaker createFromParcel(Parcel source) {
// return new Speaker(source);
// }
//
// public Speaker[] newArray(int size) {
// return new Speaker[size];
// }
// };
//
// int id;
// String name;
// String title;
// String bio;
// String website;
// String twitter;
// String github;
// String photo;
//
// public Speaker(int id, String name, String title, String bio, String website, String twitter, String github, String photo) {
// this.id = id;
// this.name = name;
// this.title = title;
// this.bio = bio;
// this.website = website;
// this.twitter = twitter;
// this.github = github;
// this.photo = photo;
// }
//
// protected Speaker(Parcel in) {
// id = in.readInt();
// name = in.readString();
// title = in.readString();
// bio = in.readString();
// website = in.readString();
// twitter = in.readString();
// github = in.readString();
// photo = in.readString();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(name);
// dest.writeString(title);
// dest.writeString(bio);
// dest.writeString(website);
// dest.writeString(twitter);
// dest.writeString(github);
// dest.writeString(photo);
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/ui/core/picasso/CircleTransformation.java
// public class CircleTransformation implements Transformation {
//
// @Override
// public Bitmap transform(Bitmap source) {
// int size = Math.min(source.getWidth(), source.getHeight());
//
// int x = (source.getWidth() - size) / 2;
// int y = (source.getHeight() - size) / 2;
//
// Bitmap squaredBitmap = Bitmap.createBitmap(source, x, y, size, size);
// if (squaredBitmap != source) {
// source.recycle();
// }
//
// Bitmap.Config config = source.getConfig() != null ? source.getConfig() : Bitmap.Config.ARGB_8888;
// Bitmap bitmap = Bitmap.createBitmap(size, size, config);
//
// Canvas canvas = new Canvas(bitmap);
// Paint paint = new Paint();
// BitmapShader shader = new BitmapShader(squaredBitmap, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP);
// paint.setShader(shader);
// paint.setAntiAlias(true);
//
// float r = size / 2f;
// canvas.drawCircle(r, r, r, paint);
//
// squaredBitmap.recycle();
// return bitmap;
// }
//
// @Override
// public String key() {
// return "circle";
// }
// }
// Path: app/src/main/java/com/nilhcem/devoxxfr/ui/sessions/details/SessionDetailsSpeaker.java
import android.content.Context;
import android.content.res.TypedArray;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import com.nilhcem.devoxxfr.R;
import com.nilhcem.devoxxfr.data.app.model.Speaker;
import com.nilhcem.devoxxfr.ui.core.picasso.CircleTransformation;
import com.squareup.picasso.Picasso;
import butterknife.Bind;
import butterknife.ButterKnife;
package com.nilhcem.devoxxfr.ui.sessions.details;
public class SessionDetailsSpeaker extends FrameLayout {
@Bind(R.id.session_details_speaker_photo) ImageView photo;
@Bind(R.id.session_details_speaker_name) TextView name;
@Bind(R.id.session_details_speaker_title) TextView title;
public SessionDetailsSpeaker(Context context, Speaker speaker, Picasso picasso) {
super(context);
int[] attrs = new int[]{android.R.attr.selectableItemBackground};
TypedArray ta = context.obtainStyledAttributes(attrs);
setForeground(ta.getDrawable(0));
ta.recycle();
LayoutInflater.from(context).inflate(R.layout.session_details_speaker, this);
ButterKnife.bind(this, this);
bind(speaker, picasso);
}
private void bind(Speaker speaker, Picasso picasso) {
String photoUrl = speaker.getPhoto();
if (!TextUtils.isEmpty(photoUrl)) {
|
picasso.load(photoUrl).transform(new CircleTransformation()).into(photo);
|
Nilhcem/devoxxfr-2016
|
app/src/main/java/com/nilhcem/devoxxfr/ui/sessions/list/SessionsListPresenter.java
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/ScheduleSlot.java
// @Value
// public class ScheduleSlot implements Parcelable {
//
// public static final Parcelable.Creator<ScheduleSlot> CREATOR = new Parcelable.Creator<ScheduleSlot>() {
// public ScheduleSlot createFromParcel(Parcel source) {
// return new ScheduleSlot(source);
// }
//
// public ScheduleSlot[] newArray(int size) {
// return new ScheduleSlot[size];
// }
// };
//
// LocalDateTime time;
// List<Session> sessions;
//
// public ScheduleSlot(LocalDateTime time, List<Session> sessions) {
// this.time = time;
// this.sessions = sessions;
// }
//
// protected ScheduleSlot(Parcel in) {
// time = (LocalDateTime) in.readSerializable();
// sessions = in.createTypedArrayList(Session.CREATOR);
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeSerializable(time);
// dest.writeTypedList(sessions);
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Session.java
// @Value
// public class Session implements Parcelable {
//
// public static final Parcelable.Creator<Session> CREATOR = new Parcelable.Creator<Session>() {
// public Session createFromParcel(Parcel source) {
// return new Session(source);
// }
//
// public Session[] newArray(int size) {
// return new Session[size];
// }
// };
//
// int id;
// String room;
// List<Speaker> speakers;
// String title;
// String description;
// LocalDateTime fromTime;
// LocalDateTime toTime;
//
// public Session(int id, String room, List<Speaker> speakers, String title, String description, LocalDateTime fromTime, LocalDateTime toTime) {
// this.id = id;
// this.room = room;
// this.speakers = speakers;
// this.title = title;
// this.description = description;
// this.fromTime = fromTime;
// this.toTime = toTime;
// }
//
// protected Session(Parcel in) {
// id = in.readInt();
// room = in.readString();
// speakers = in.createTypedArrayList(Speaker.CREATOR);
// title = in.readString();
// description = in.readString();
// fromTime = (LocalDateTime) in.readSerializable();
// toTime = (LocalDateTime) in.readSerializable();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(room);
// dest.writeTypedList(speakers);
// dest.writeString(title);
// dest.writeString(description);
// dest.writeSerializable(fromTime);
// dest.writeSerializable(toTime);
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/ui/BaseActivityPresenter.java
// public abstract class BaseActivityPresenter<V> extends BasePresenter<V> {
//
// public BaseActivityPresenter(V view) {
// super(view);
// }
//
// public void onPostCreate(Bundle savedInstanceState) {
// // Nothing to do by default
// }
//
// public void onResume() {
// // Nothing to do by default
// }
//
// @CallSuper
// public void onSaveInstanceState(Bundle outState) {
// Icepick.saveInstanceState(this, outState);
// }
//
// @CallSuper
// public void onRestoreInstanceState(Bundle savedInstanceState) {
// Icepick.restoreInstanceState(this, savedInstanceState);
// }
//
// public void onNavigationItemSelected(@IdRes int itemId) {
// // Nothing to do by default
// }
//
// public boolean onBackPressed() {
// return false;
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/utils/Strings.java
// public class Strings {
//
// private Strings() {
// throw new UnsupportedOperationException();
// }
//
// public static String capitalizeFirstLetter(@NonNull String src) {
// return src.substring(0, 1).toUpperCase(Locale.getDefault()) + src.substring(1);
// }
// }
|
import android.content.Context;
import android.os.Bundle;
import com.nilhcem.devoxxfr.R;
import com.nilhcem.devoxxfr.data.app.model.ScheduleSlot;
import com.nilhcem.devoxxfr.data.app.model.Session;
import com.nilhcem.devoxxfr.ui.BaseActivityPresenter;
import com.nilhcem.devoxxfr.utils.Strings;
import org.threeten.bp.LocalDateTime;
import org.threeten.bp.format.DateTimeFormatter;
import org.threeten.bp.format.FormatStyle;
import java.util.List;
import java.util.Locale;
|
package com.nilhcem.devoxxfr.ui.sessions.list;
public class SessionsListPresenter extends BaseActivityPresenter<SessionsListView> {
private final List<Session> sessions;
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/ScheduleSlot.java
// @Value
// public class ScheduleSlot implements Parcelable {
//
// public static final Parcelable.Creator<ScheduleSlot> CREATOR = new Parcelable.Creator<ScheduleSlot>() {
// public ScheduleSlot createFromParcel(Parcel source) {
// return new ScheduleSlot(source);
// }
//
// public ScheduleSlot[] newArray(int size) {
// return new ScheduleSlot[size];
// }
// };
//
// LocalDateTime time;
// List<Session> sessions;
//
// public ScheduleSlot(LocalDateTime time, List<Session> sessions) {
// this.time = time;
// this.sessions = sessions;
// }
//
// protected ScheduleSlot(Parcel in) {
// time = (LocalDateTime) in.readSerializable();
// sessions = in.createTypedArrayList(Session.CREATOR);
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeSerializable(time);
// dest.writeTypedList(sessions);
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Session.java
// @Value
// public class Session implements Parcelable {
//
// public static final Parcelable.Creator<Session> CREATOR = new Parcelable.Creator<Session>() {
// public Session createFromParcel(Parcel source) {
// return new Session(source);
// }
//
// public Session[] newArray(int size) {
// return new Session[size];
// }
// };
//
// int id;
// String room;
// List<Speaker> speakers;
// String title;
// String description;
// LocalDateTime fromTime;
// LocalDateTime toTime;
//
// public Session(int id, String room, List<Speaker> speakers, String title, String description, LocalDateTime fromTime, LocalDateTime toTime) {
// this.id = id;
// this.room = room;
// this.speakers = speakers;
// this.title = title;
// this.description = description;
// this.fromTime = fromTime;
// this.toTime = toTime;
// }
//
// protected Session(Parcel in) {
// id = in.readInt();
// room = in.readString();
// speakers = in.createTypedArrayList(Speaker.CREATOR);
// title = in.readString();
// description = in.readString();
// fromTime = (LocalDateTime) in.readSerializable();
// toTime = (LocalDateTime) in.readSerializable();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(room);
// dest.writeTypedList(speakers);
// dest.writeString(title);
// dest.writeString(description);
// dest.writeSerializable(fromTime);
// dest.writeSerializable(toTime);
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/ui/BaseActivityPresenter.java
// public abstract class BaseActivityPresenter<V> extends BasePresenter<V> {
//
// public BaseActivityPresenter(V view) {
// super(view);
// }
//
// public void onPostCreate(Bundle savedInstanceState) {
// // Nothing to do by default
// }
//
// public void onResume() {
// // Nothing to do by default
// }
//
// @CallSuper
// public void onSaveInstanceState(Bundle outState) {
// Icepick.saveInstanceState(this, outState);
// }
//
// @CallSuper
// public void onRestoreInstanceState(Bundle savedInstanceState) {
// Icepick.restoreInstanceState(this, savedInstanceState);
// }
//
// public void onNavigationItemSelected(@IdRes int itemId) {
// // Nothing to do by default
// }
//
// public boolean onBackPressed() {
// return false;
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/utils/Strings.java
// public class Strings {
//
// private Strings() {
// throw new UnsupportedOperationException();
// }
//
// public static String capitalizeFirstLetter(@NonNull String src) {
// return src.substring(0, 1).toUpperCase(Locale.getDefault()) + src.substring(1);
// }
// }
// Path: app/src/main/java/com/nilhcem/devoxxfr/ui/sessions/list/SessionsListPresenter.java
import android.content.Context;
import android.os.Bundle;
import com.nilhcem.devoxxfr.R;
import com.nilhcem.devoxxfr.data.app.model.ScheduleSlot;
import com.nilhcem.devoxxfr.data.app.model.Session;
import com.nilhcem.devoxxfr.ui.BaseActivityPresenter;
import com.nilhcem.devoxxfr.utils.Strings;
import org.threeten.bp.LocalDateTime;
import org.threeten.bp.format.DateTimeFormatter;
import org.threeten.bp.format.FormatStyle;
import java.util.List;
import java.util.Locale;
package com.nilhcem.devoxxfr.ui.sessions.list;
public class SessionsListPresenter extends BaseActivityPresenter<SessionsListView> {
private final List<Session> sessions;
|
public SessionsListPresenter(Context context, SessionsListView view, ScheduleSlot slot) {
|
Nilhcem/devoxxfr-2016
|
app/src/main/java/com/nilhcem/devoxxfr/ui/sessions/list/SessionsListPresenter.java
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/ScheduleSlot.java
// @Value
// public class ScheduleSlot implements Parcelable {
//
// public static final Parcelable.Creator<ScheduleSlot> CREATOR = new Parcelable.Creator<ScheduleSlot>() {
// public ScheduleSlot createFromParcel(Parcel source) {
// return new ScheduleSlot(source);
// }
//
// public ScheduleSlot[] newArray(int size) {
// return new ScheduleSlot[size];
// }
// };
//
// LocalDateTime time;
// List<Session> sessions;
//
// public ScheduleSlot(LocalDateTime time, List<Session> sessions) {
// this.time = time;
// this.sessions = sessions;
// }
//
// protected ScheduleSlot(Parcel in) {
// time = (LocalDateTime) in.readSerializable();
// sessions = in.createTypedArrayList(Session.CREATOR);
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeSerializable(time);
// dest.writeTypedList(sessions);
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Session.java
// @Value
// public class Session implements Parcelable {
//
// public static final Parcelable.Creator<Session> CREATOR = new Parcelable.Creator<Session>() {
// public Session createFromParcel(Parcel source) {
// return new Session(source);
// }
//
// public Session[] newArray(int size) {
// return new Session[size];
// }
// };
//
// int id;
// String room;
// List<Speaker> speakers;
// String title;
// String description;
// LocalDateTime fromTime;
// LocalDateTime toTime;
//
// public Session(int id, String room, List<Speaker> speakers, String title, String description, LocalDateTime fromTime, LocalDateTime toTime) {
// this.id = id;
// this.room = room;
// this.speakers = speakers;
// this.title = title;
// this.description = description;
// this.fromTime = fromTime;
// this.toTime = toTime;
// }
//
// protected Session(Parcel in) {
// id = in.readInt();
// room = in.readString();
// speakers = in.createTypedArrayList(Speaker.CREATOR);
// title = in.readString();
// description = in.readString();
// fromTime = (LocalDateTime) in.readSerializable();
// toTime = (LocalDateTime) in.readSerializable();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(room);
// dest.writeTypedList(speakers);
// dest.writeString(title);
// dest.writeString(description);
// dest.writeSerializable(fromTime);
// dest.writeSerializable(toTime);
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/ui/BaseActivityPresenter.java
// public abstract class BaseActivityPresenter<V> extends BasePresenter<V> {
//
// public BaseActivityPresenter(V view) {
// super(view);
// }
//
// public void onPostCreate(Bundle savedInstanceState) {
// // Nothing to do by default
// }
//
// public void onResume() {
// // Nothing to do by default
// }
//
// @CallSuper
// public void onSaveInstanceState(Bundle outState) {
// Icepick.saveInstanceState(this, outState);
// }
//
// @CallSuper
// public void onRestoreInstanceState(Bundle savedInstanceState) {
// Icepick.restoreInstanceState(this, savedInstanceState);
// }
//
// public void onNavigationItemSelected(@IdRes int itemId) {
// // Nothing to do by default
// }
//
// public boolean onBackPressed() {
// return false;
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/utils/Strings.java
// public class Strings {
//
// private Strings() {
// throw new UnsupportedOperationException();
// }
//
// public static String capitalizeFirstLetter(@NonNull String src) {
// return src.substring(0, 1).toUpperCase(Locale.getDefault()) + src.substring(1);
// }
// }
|
import android.content.Context;
import android.os.Bundle;
import com.nilhcem.devoxxfr.R;
import com.nilhcem.devoxxfr.data.app.model.ScheduleSlot;
import com.nilhcem.devoxxfr.data.app.model.Session;
import com.nilhcem.devoxxfr.ui.BaseActivityPresenter;
import com.nilhcem.devoxxfr.utils.Strings;
import org.threeten.bp.LocalDateTime;
import org.threeten.bp.format.DateTimeFormatter;
import org.threeten.bp.format.FormatStyle;
import java.util.List;
import java.util.Locale;
|
package com.nilhcem.devoxxfr.ui.sessions.list;
public class SessionsListPresenter extends BaseActivityPresenter<SessionsListView> {
private final List<Session> sessions;
public SessionsListPresenter(Context context, SessionsListView view, ScheduleSlot slot) {
super(view);
this.view.initToobar(formatDateTime(context, slot.getTime()));
sessions = slot.getSessions();
}
@Override
public void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
this.view.initSessionsList(sessions);
}
private String formatDateTime(Context context, LocalDateTime dateTime) {
String dayPattern = context.getString(R.string.schedule_pager_day_pattern);
DateTimeFormatter dayFormatter = DateTimeFormatter.ofPattern(dayPattern, Locale.getDefault());
DateTimeFormatter timeFormatter = DateTimeFormatter.ofLocalizedTime(FormatStyle.SHORT);
String formatted = context.getString(R.string.schedule_browse_sessions_title_pattern,
dateTime.format(dayFormatter),
dateTime.format(timeFormatter));
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/ScheduleSlot.java
// @Value
// public class ScheduleSlot implements Parcelable {
//
// public static final Parcelable.Creator<ScheduleSlot> CREATOR = new Parcelable.Creator<ScheduleSlot>() {
// public ScheduleSlot createFromParcel(Parcel source) {
// return new ScheduleSlot(source);
// }
//
// public ScheduleSlot[] newArray(int size) {
// return new ScheduleSlot[size];
// }
// };
//
// LocalDateTime time;
// List<Session> sessions;
//
// public ScheduleSlot(LocalDateTime time, List<Session> sessions) {
// this.time = time;
// this.sessions = sessions;
// }
//
// protected ScheduleSlot(Parcel in) {
// time = (LocalDateTime) in.readSerializable();
// sessions = in.createTypedArrayList(Session.CREATOR);
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeSerializable(time);
// dest.writeTypedList(sessions);
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Session.java
// @Value
// public class Session implements Parcelable {
//
// public static final Parcelable.Creator<Session> CREATOR = new Parcelable.Creator<Session>() {
// public Session createFromParcel(Parcel source) {
// return new Session(source);
// }
//
// public Session[] newArray(int size) {
// return new Session[size];
// }
// };
//
// int id;
// String room;
// List<Speaker> speakers;
// String title;
// String description;
// LocalDateTime fromTime;
// LocalDateTime toTime;
//
// public Session(int id, String room, List<Speaker> speakers, String title, String description, LocalDateTime fromTime, LocalDateTime toTime) {
// this.id = id;
// this.room = room;
// this.speakers = speakers;
// this.title = title;
// this.description = description;
// this.fromTime = fromTime;
// this.toTime = toTime;
// }
//
// protected Session(Parcel in) {
// id = in.readInt();
// room = in.readString();
// speakers = in.createTypedArrayList(Speaker.CREATOR);
// title = in.readString();
// description = in.readString();
// fromTime = (LocalDateTime) in.readSerializable();
// toTime = (LocalDateTime) in.readSerializable();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(room);
// dest.writeTypedList(speakers);
// dest.writeString(title);
// dest.writeString(description);
// dest.writeSerializable(fromTime);
// dest.writeSerializable(toTime);
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/ui/BaseActivityPresenter.java
// public abstract class BaseActivityPresenter<V> extends BasePresenter<V> {
//
// public BaseActivityPresenter(V view) {
// super(view);
// }
//
// public void onPostCreate(Bundle savedInstanceState) {
// // Nothing to do by default
// }
//
// public void onResume() {
// // Nothing to do by default
// }
//
// @CallSuper
// public void onSaveInstanceState(Bundle outState) {
// Icepick.saveInstanceState(this, outState);
// }
//
// @CallSuper
// public void onRestoreInstanceState(Bundle savedInstanceState) {
// Icepick.restoreInstanceState(this, savedInstanceState);
// }
//
// public void onNavigationItemSelected(@IdRes int itemId) {
// // Nothing to do by default
// }
//
// public boolean onBackPressed() {
// return false;
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/utils/Strings.java
// public class Strings {
//
// private Strings() {
// throw new UnsupportedOperationException();
// }
//
// public static String capitalizeFirstLetter(@NonNull String src) {
// return src.substring(0, 1).toUpperCase(Locale.getDefault()) + src.substring(1);
// }
// }
// Path: app/src/main/java/com/nilhcem/devoxxfr/ui/sessions/list/SessionsListPresenter.java
import android.content.Context;
import android.os.Bundle;
import com.nilhcem.devoxxfr.R;
import com.nilhcem.devoxxfr.data.app.model.ScheduleSlot;
import com.nilhcem.devoxxfr.data.app.model.Session;
import com.nilhcem.devoxxfr.ui.BaseActivityPresenter;
import com.nilhcem.devoxxfr.utils.Strings;
import org.threeten.bp.LocalDateTime;
import org.threeten.bp.format.DateTimeFormatter;
import org.threeten.bp.format.FormatStyle;
import java.util.List;
import java.util.Locale;
package com.nilhcem.devoxxfr.ui.sessions.list;
public class SessionsListPresenter extends BaseActivityPresenter<SessionsListView> {
private final List<Session> sessions;
public SessionsListPresenter(Context context, SessionsListView view, ScheduleSlot slot) {
super(view);
this.view.initToobar(formatDateTime(context, slot.getTime()));
sessions = slot.getSessions();
}
@Override
public void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
this.view.initSessionsList(sessions);
}
private String formatDateTime(Context context, LocalDateTime dateTime) {
String dayPattern = context.getString(R.string.schedule_pager_day_pattern);
DateTimeFormatter dayFormatter = DateTimeFormatter.ofPattern(dayPattern, Locale.getDefault());
DateTimeFormatter timeFormatter = DateTimeFormatter.ofLocalizedTime(FormatStyle.SHORT);
String formatted = context.getString(R.string.schedule_browse_sessions_title_pattern,
dateTime.format(dayFormatter),
dateTime.format(timeFormatter));
|
return Strings.capitalizeFirstLetter(formatted);
|
Nilhcem/devoxxfr-2016
|
app/src/main/java/com/nilhcem/devoxxfr/ui/schedule/pager/SchedulePagerPresenter.java
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/DataProvider.java
// @Singleton
// public class DataProvider {
//
// private final AppMapper appMapper;
// private final NetworkMapper networkMapper;
// private final DevoxxService service;
// private final SpeakersDao speakersDao;
// private final SessionsDao sessionsDao;
// private final DataProviderCache cache;
//
// @Inject
// public DataProvider(AppMapper appMapper, NetworkMapper networkMapper, DevoxxService service, SpeakersDao speakersDao, SessionsDao sessionsDao) {
// this.appMapper = appMapper;
// this.networkMapper = networkMapper;
// this.service = service;
// this.speakersDao = speakersDao;
// this.sessionsDao = sessionsDao;
// this.cache = new DataProviderCache();
// }
//
// public Observable<Schedule> getSchedule() {
// sessionsDao.initSelectedSessionsMemory();
// return getSessions().map(appMapper::toSchedule);
// }
//
// public Observable<List<Speaker>> getSpeakers() {
// return Observable.create(subscriber -> speakersDao.getSpeakers().subscribe(speakers -> {
// if (!speakers.isEmpty()) {
// subscriber.onNext(speakers);
// }
//
// if (!subscriber.isUnsubscribed()) {
// getSpeakersFromNetwork(subscriber);
// }
// subscriber.onCompleted();
// }, subscriber::onError));
// }
//
// private void getSpeakersFromNetwork(Subscriber<? super List<Speaker>> subscriber) {
// List<Speaker> fromCache = cache.getSpeakers();
// if (fromCache == null) {
// service.loadSpeakers()
// .map(networkMapper::toAppSpeakers)
// .subscribe(speakers -> {
// subscriber.onNext(speakers);
// speakersDao.saveSpeakers(speakers);
// cache.saveSpeakers(speakers);
// }, throwable -> Timber.e(throwable, "Error getting speakers from network"));
// } else {
// subscriber.onNext(fromCache);
// }
// }
//
// private Observable<List<Session>> getSessions() {
// return Observable.create(subscriber -> sessionsDao.getSessions().subscribe(sessions -> {
// if (!sessions.isEmpty()) {
// subscriber.onNext(sessions);
// }
//
// if (!subscriber.isUnsubscribed()) {
// getSessionsFromNetwork(subscriber);
// }
// subscriber.onCompleted();
// }, subscriber::onError));
// }
//
// private void getSessionsFromNetwork(Subscriber<? super List<Session>> subscriber) {
// List<Session> fromCache = cache.getSessions();
// if (fromCache == null) {
// Observable.zip(
// service.loadSessions(),
// getSpeakers().last().map(appMapper::speakersToMap),
// networkMapper::toAppSessions)
// .subscribe(sessions -> {
// subscriber.onNext(sessions);
// sessionsDao.saveSessions(sessions);
// cache.saveSessions(sessions);
// }, throwable -> Timber.e(throwable, "Error getting sessions from network"));
// } else {
// subscriber.onNext(fromCache);
// }
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Schedule.java
// public class Schedule extends ArrayList<ScheduleDay> implements Parcelable {
//
// public static final Parcelable.Creator<Schedule> CREATOR = new Parcelable.Creator<Schedule>() {
// public Schedule createFromParcel(Parcel source) {
// return new Schedule(source);
// }
//
// public Schedule[] newArray(int size) {
// return new Schedule[size];
// }
// };
//
// public Schedule() {
// }
//
// protected Schedule(Parcel in) {
// addAll(in.createTypedArrayList(ScheduleDay.CREATOR));
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeTypedList(this);
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/ui/BaseFragmentPresenter.java
// public abstract class BaseFragmentPresenter<V> extends BasePresenter<V> {
//
// public BaseFragmentPresenter(V view) {
// super(view);
// }
//
// @CallSuper
// public void onCreate(Bundle savedInstanceState) {
// if (savedInstanceState != null) {
// Icepick.restoreInstanceState(this, savedInstanceState);
// }
// }
//
// public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
// // Nothing to do by default
// }
//
// public void onStart() {
// // Nothing to do by default
// }
//
// public void onResume() {
// // Nothing to do by default
// }
//
// public void onStop() {
// // Nothing to do by default
// }
//
// @CallSuper
// public void onSaveInstanceState(Bundle outState) {
// Icepick.saveInstanceState(this, outState);
// }
// }
|
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import com.nilhcem.devoxxfr.data.app.DataProvider;
import com.nilhcem.devoxxfr.data.app.model.Schedule;
import com.nilhcem.devoxxfr.ui.BaseFragmentPresenter;
import icepick.State;
import rx.Subscription;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
import timber.log.Timber;
|
package com.nilhcem.devoxxfr.ui.schedule.pager;
public class SchedulePagerPresenter extends BaseFragmentPresenter<SchedulePagerView> {
@State Schedule schedule;
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/DataProvider.java
// @Singleton
// public class DataProvider {
//
// private final AppMapper appMapper;
// private final NetworkMapper networkMapper;
// private final DevoxxService service;
// private final SpeakersDao speakersDao;
// private final SessionsDao sessionsDao;
// private final DataProviderCache cache;
//
// @Inject
// public DataProvider(AppMapper appMapper, NetworkMapper networkMapper, DevoxxService service, SpeakersDao speakersDao, SessionsDao sessionsDao) {
// this.appMapper = appMapper;
// this.networkMapper = networkMapper;
// this.service = service;
// this.speakersDao = speakersDao;
// this.sessionsDao = sessionsDao;
// this.cache = new DataProviderCache();
// }
//
// public Observable<Schedule> getSchedule() {
// sessionsDao.initSelectedSessionsMemory();
// return getSessions().map(appMapper::toSchedule);
// }
//
// public Observable<List<Speaker>> getSpeakers() {
// return Observable.create(subscriber -> speakersDao.getSpeakers().subscribe(speakers -> {
// if (!speakers.isEmpty()) {
// subscriber.onNext(speakers);
// }
//
// if (!subscriber.isUnsubscribed()) {
// getSpeakersFromNetwork(subscriber);
// }
// subscriber.onCompleted();
// }, subscriber::onError));
// }
//
// private void getSpeakersFromNetwork(Subscriber<? super List<Speaker>> subscriber) {
// List<Speaker> fromCache = cache.getSpeakers();
// if (fromCache == null) {
// service.loadSpeakers()
// .map(networkMapper::toAppSpeakers)
// .subscribe(speakers -> {
// subscriber.onNext(speakers);
// speakersDao.saveSpeakers(speakers);
// cache.saveSpeakers(speakers);
// }, throwable -> Timber.e(throwable, "Error getting speakers from network"));
// } else {
// subscriber.onNext(fromCache);
// }
// }
//
// private Observable<List<Session>> getSessions() {
// return Observable.create(subscriber -> sessionsDao.getSessions().subscribe(sessions -> {
// if (!sessions.isEmpty()) {
// subscriber.onNext(sessions);
// }
//
// if (!subscriber.isUnsubscribed()) {
// getSessionsFromNetwork(subscriber);
// }
// subscriber.onCompleted();
// }, subscriber::onError));
// }
//
// private void getSessionsFromNetwork(Subscriber<? super List<Session>> subscriber) {
// List<Session> fromCache = cache.getSessions();
// if (fromCache == null) {
// Observable.zip(
// service.loadSessions(),
// getSpeakers().last().map(appMapper::speakersToMap),
// networkMapper::toAppSessions)
// .subscribe(sessions -> {
// subscriber.onNext(sessions);
// sessionsDao.saveSessions(sessions);
// cache.saveSessions(sessions);
// }, throwable -> Timber.e(throwable, "Error getting sessions from network"));
// } else {
// subscriber.onNext(fromCache);
// }
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Schedule.java
// public class Schedule extends ArrayList<ScheduleDay> implements Parcelable {
//
// public static final Parcelable.Creator<Schedule> CREATOR = new Parcelable.Creator<Schedule>() {
// public Schedule createFromParcel(Parcel source) {
// return new Schedule(source);
// }
//
// public Schedule[] newArray(int size) {
// return new Schedule[size];
// }
// };
//
// public Schedule() {
// }
//
// protected Schedule(Parcel in) {
// addAll(in.createTypedArrayList(ScheduleDay.CREATOR));
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeTypedList(this);
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/ui/BaseFragmentPresenter.java
// public abstract class BaseFragmentPresenter<V> extends BasePresenter<V> {
//
// public BaseFragmentPresenter(V view) {
// super(view);
// }
//
// @CallSuper
// public void onCreate(Bundle savedInstanceState) {
// if (savedInstanceState != null) {
// Icepick.restoreInstanceState(this, savedInstanceState);
// }
// }
//
// public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
// // Nothing to do by default
// }
//
// public void onStart() {
// // Nothing to do by default
// }
//
// public void onResume() {
// // Nothing to do by default
// }
//
// public void onStop() {
// // Nothing to do by default
// }
//
// @CallSuper
// public void onSaveInstanceState(Bundle outState) {
// Icepick.saveInstanceState(this, outState);
// }
// }
// Path: app/src/main/java/com/nilhcem/devoxxfr/ui/schedule/pager/SchedulePagerPresenter.java
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import com.nilhcem.devoxxfr.data.app.DataProvider;
import com.nilhcem.devoxxfr.data.app.model.Schedule;
import com.nilhcem.devoxxfr.ui.BaseFragmentPresenter;
import icepick.State;
import rx.Subscription;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
import timber.log.Timber;
package com.nilhcem.devoxxfr.ui.schedule.pager;
public class SchedulePagerPresenter extends BaseFragmentPresenter<SchedulePagerView> {
@State Schedule schedule;
|
private final DataProvider dataProvider;
|
Nilhcem/devoxxfr-2016
|
app/src/main/java/com/nilhcem/devoxxfr/data/app/DataProviderCache.java
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Session.java
// @Value
// public class Session implements Parcelable {
//
// public static final Parcelable.Creator<Session> CREATOR = new Parcelable.Creator<Session>() {
// public Session createFromParcel(Parcel source) {
// return new Session(source);
// }
//
// public Session[] newArray(int size) {
// return new Session[size];
// }
// };
//
// int id;
// String room;
// List<Speaker> speakers;
// String title;
// String description;
// LocalDateTime fromTime;
// LocalDateTime toTime;
//
// public Session(int id, String room, List<Speaker> speakers, String title, String description, LocalDateTime fromTime, LocalDateTime toTime) {
// this.id = id;
// this.room = room;
// this.speakers = speakers;
// this.title = title;
// this.description = description;
// this.fromTime = fromTime;
// this.toTime = toTime;
// }
//
// protected Session(Parcel in) {
// id = in.readInt();
// room = in.readString();
// speakers = in.createTypedArrayList(Speaker.CREATOR);
// title = in.readString();
// description = in.readString();
// fromTime = (LocalDateTime) in.readSerializable();
// toTime = (LocalDateTime) in.readSerializable();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(room);
// dest.writeTypedList(speakers);
// dest.writeString(title);
// dest.writeString(description);
// dest.writeSerializable(fromTime);
// dest.writeSerializable(toTime);
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Speaker.java
// @Value
// public class Speaker implements Parcelable {
//
// public static final Parcelable.Creator<Speaker> CREATOR = new Parcelable.Creator<Speaker>() {
// public Speaker createFromParcel(Parcel source) {
// return new Speaker(source);
// }
//
// public Speaker[] newArray(int size) {
// return new Speaker[size];
// }
// };
//
// int id;
// String name;
// String title;
// String bio;
// String website;
// String twitter;
// String github;
// String photo;
//
// public Speaker(int id, String name, String title, String bio, String website, String twitter, String github, String photo) {
// this.id = id;
// this.name = name;
// this.title = title;
// this.bio = bio;
// this.website = website;
// this.twitter = twitter;
// this.github = github;
// this.photo = photo;
// }
//
// protected Speaker(Parcel in) {
// id = in.readInt();
// name = in.readString();
// title = in.readString();
// bio = in.readString();
// website = in.readString();
// twitter = in.readString();
// github = in.readString();
// photo = in.readString();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(name);
// dest.writeString(title);
// dest.writeString(bio);
// dest.writeString(website);
// dest.writeString(twitter);
// dest.writeString(github);
// dest.writeString(photo);
// }
// }
|
import com.nilhcem.devoxxfr.data.app.model.Session;
import com.nilhcem.devoxxfr.data.app.model.Speaker;
import org.threeten.bp.LocalDateTime;
import java.util.List;
import timber.log.Timber;
|
package com.nilhcem.devoxxfr.data.app;
public class DataProviderCache {
private static final long CACHE_DURATION_MN = 10;
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Session.java
// @Value
// public class Session implements Parcelable {
//
// public static final Parcelable.Creator<Session> CREATOR = new Parcelable.Creator<Session>() {
// public Session createFromParcel(Parcel source) {
// return new Session(source);
// }
//
// public Session[] newArray(int size) {
// return new Session[size];
// }
// };
//
// int id;
// String room;
// List<Speaker> speakers;
// String title;
// String description;
// LocalDateTime fromTime;
// LocalDateTime toTime;
//
// public Session(int id, String room, List<Speaker> speakers, String title, String description, LocalDateTime fromTime, LocalDateTime toTime) {
// this.id = id;
// this.room = room;
// this.speakers = speakers;
// this.title = title;
// this.description = description;
// this.fromTime = fromTime;
// this.toTime = toTime;
// }
//
// protected Session(Parcel in) {
// id = in.readInt();
// room = in.readString();
// speakers = in.createTypedArrayList(Speaker.CREATOR);
// title = in.readString();
// description = in.readString();
// fromTime = (LocalDateTime) in.readSerializable();
// toTime = (LocalDateTime) in.readSerializable();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(room);
// dest.writeTypedList(speakers);
// dest.writeString(title);
// dest.writeString(description);
// dest.writeSerializable(fromTime);
// dest.writeSerializable(toTime);
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Speaker.java
// @Value
// public class Speaker implements Parcelable {
//
// public static final Parcelable.Creator<Speaker> CREATOR = new Parcelable.Creator<Speaker>() {
// public Speaker createFromParcel(Parcel source) {
// return new Speaker(source);
// }
//
// public Speaker[] newArray(int size) {
// return new Speaker[size];
// }
// };
//
// int id;
// String name;
// String title;
// String bio;
// String website;
// String twitter;
// String github;
// String photo;
//
// public Speaker(int id, String name, String title, String bio, String website, String twitter, String github, String photo) {
// this.id = id;
// this.name = name;
// this.title = title;
// this.bio = bio;
// this.website = website;
// this.twitter = twitter;
// this.github = github;
// this.photo = photo;
// }
//
// protected Speaker(Parcel in) {
// id = in.readInt();
// name = in.readString();
// title = in.readString();
// bio = in.readString();
// website = in.readString();
// twitter = in.readString();
// github = in.readString();
// photo = in.readString();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(name);
// dest.writeString(title);
// dest.writeString(bio);
// dest.writeString(website);
// dest.writeString(twitter);
// dest.writeString(github);
// dest.writeString(photo);
// }
// }
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/DataProviderCache.java
import com.nilhcem.devoxxfr.data.app.model.Session;
import com.nilhcem.devoxxfr.data.app.model.Speaker;
import org.threeten.bp.LocalDateTime;
import java.util.List;
import timber.log.Timber;
package com.nilhcem.devoxxfr.data.app;
public class DataProviderCache {
private static final long CACHE_DURATION_MN = 10;
|
List<Session> sessions;
|
Nilhcem/devoxxfr-2016
|
app/src/main/java/com/nilhcem/devoxxfr/data/app/DataProviderCache.java
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Session.java
// @Value
// public class Session implements Parcelable {
//
// public static final Parcelable.Creator<Session> CREATOR = new Parcelable.Creator<Session>() {
// public Session createFromParcel(Parcel source) {
// return new Session(source);
// }
//
// public Session[] newArray(int size) {
// return new Session[size];
// }
// };
//
// int id;
// String room;
// List<Speaker> speakers;
// String title;
// String description;
// LocalDateTime fromTime;
// LocalDateTime toTime;
//
// public Session(int id, String room, List<Speaker> speakers, String title, String description, LocalDateTime fromTime, LocalDateTime toTime) {
// this.id = id;
// this.room = room;
// this.speakers = speakers;
// this.title = title;
// this.description = description;
// this.fromTime = fromTime;
// this.toTime = toTime;
// }
//
// protected Session(Parcel in) {
// id = in.readInt();
// room = in.readString();
// speakers = in.createTypedArrayList(Speaker.CREATOR);
// title = in.readString();
// description = in.readString();
// fromTime = (LocalDateTime) in.readSerializable();
// toTime = (LocalDateTime) in.readSerializable();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(room);
// dest.writeTypedList(speakers);
// dest.writeString(title);
// dest.writeString(description);
// dest.writeSerializable(fromTime);
// dest.writeSerializable(toTime);
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Speaker.java
// @Value
// public class Speaker implements Parcelable {
//
// public static final Parcelable.Creator<Speaker> CREATOR = new Parcelable.Creator<Speaker>() {
// public Speaker createFromParcel(Parcel source) {
// return new Speaker(source);
// }
//
// public Speaker[] newArray(int size) {
// return new Speaker[size];
// }
// };
//
// int id;
// String name;
// String title;
// String bio;
// String website;
// String twitter;
// String github;
// String photo;
//
// public Speaker(int id, String name, String title, String bio, String website, String twitter, String github, String photo) {
// this.id = id;
// this.name = name;
// this.title = title;
// this.bio = bio;
// this.website = website;
// this.twitter = twitter;
// this.github = github;
// this.photo = photo;
// }
//
// protected Speaker(Parcel in) {
// id = in.readInt();
// name = in.readString();
// title = in.readString();
// bio = in.readString();
// website = in.readString();
// twitter = in.readString();
// github = in.readString();
// photo = in.readString();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(name);
// dest.writeString(title);
// dest.writeString(bio);
// dest.writeString(website);
// dest.writeString(twitter);
// dest.writeString(github);
// dest.writeString(photo);
// }
// }
|
import com.nilhcem.devoxxfr.data.app.model.Session;
import com.nilhcem.devoxxfr.data.app.model.Speaker;
import org.threeten.bp.LocalDateTime;
import java.util.List;
import timber.log.Timber;
|
package com.nilhcem.devoxxfr.data.app;
public class DataProviderCache {
private static final long CACHE_DURATION_MN = 10;
List<Session> sessions;
LocalDateTime sessionsFetchedTime;
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Session.java
// @Value
// public class Session implements Parcelable {
//
// public static final Parcelable.Creator<Session> CREATOR = new Parcelable.Creator<Session>() {
// public Session createFromParcel(Parcel source) {
// return new Session(source);
// }
//
// public Session[] newArray(int size) {
// return new Session[size];
// }
// };
//
// int id;
// String room;
// List<Speaker> speakers;
// String title;
// String description;
// LocalDateTime fromTime;
// LocalDateTime toTime;
//
// public Session(int id, String room, List<Speaker> speakers, String title, String description, LocalDateTime fromTime, LocalDateTime toTime) {
// this.id = id;
// this.room = room;
// this.speakers = speakers;
// this.title = title;
// this.description = description;
// this.fromTime = fromTime;
// this.toTime = toTime;
// }
//
// protected Session(Parcel in) {
// id = in.readInt();
// room = in.readString();
// speakers = in.createTypedArrayList(Speaker.CREATOR);
// title = in.readString();
// description = in.readString();
// fromTime = (LocalDateTime) in.readSerializable();
// toTime = (LocalDateTime) in.readSerializable();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(room);
// dest.writeTypedList(speakers);
// dest.writeString(title);
// dest.writeString(description);
// dest.writeSerializable(fromTime);
// dest.writeSerializable(toTime);
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Speaker.java
// @Value
// public class Speaker implements Parcelable {
//
// public static final Parcelable.Creator<Speaker> CREATOR = new Parcelable.Creator<Speaker>() {
// public Speaker createFromParcel(Parcel source) {
// return new Speaker(source);
// }
//
// public Speaker[] newArray(int size) {
// return new Speaker[size];
// }
// };
//
// int id;
// String name;
// String title;
// String bio;
// String website;
// String twitter;
// String github;
// String photo;
//
// public Speaker(int id, String name, String title, String bio, String website, String twitter, String github, String photo) {
// this.id = id;
// this.name = name;
// this.title = title;
// this.bio = bio;
// this.website = website;
// this.twitter = twitter;
// this.github = github;
// this.photo = photo;
// }
//
// protected Speaker(Parcel in) {
// id = in.readInt();
// name = in.readString();
// title = in.readString();
// bio = in.readString();
// website = in.readString();
// twitter = in.readString();
// github = in.readString();
// photo = in.readString();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(name);
// dest.writeString(title);
// dest.writeString(bio);
// dest.writeString(website);
// dest.writeString(twitter);
// dest.writeString(github);
// dest.writeString(photo);
// }
// }
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/DataProviderCache.java
import com.nilhcem.devoxxfr.data.app.model.Session;
import com.nilhcem.devoxxfr.data.app.model.Speaker;
import org.threeten.bp.LocalDateTime;
import java.util.List;
import timber.log.Timber;
package com.nilhcem.devoxxfr.data.app;
public class DataProviderCache {
private static final long CACHE_DURATION_MN = 10;
List<Session> sessions;
LocalDateTime sessionsFetchedTime;
|
List<Speaker> speakers;
|
Nilhcem/devoxxfr-2016
|
app/src/main/java/com/nilhcem/devoxxfr/ui/schedule/day/ScheduleDayEntrySpeaker.java
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Speaker.java
// @Value
// public class Speaker implements Parcelable {
//
// public static final Parcelable.Creator<Speaker> CREATOR = new Parcelable.Creator<Speaker>() {
// public Speaker createFromParcel(Parcel source) {
// return new Speaker(source);
// }
//
// public Speaker[] newArray(int size) {
// return new Speaker[size];
// }
// };
//
// int id;
// String name;
// String title;
// String bio;
// String website;
// String twitter;
// String github;
// String photo;
//
// public Speaker(int id, String name, String title, String bio, String website, String twitter, String github, String photo) {
// this.id = id;
// this.name = name;
// this.title = title;
// this.bio = bio;
// this.website = website;
// this.twitter = twitter;
// this.github = github;
// this.photo = photo;
// }
//
// protected Speaker(Parcel in) {
// id = in.readInt();
// name = in.readString();
// title = in.readString();
// bio = in.readString();
// website = in.readString();
// twitter = in.readString();
// github = in.readString();
// photo = in.readString();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(name);
// dest.writeString(title);
// dest.writeString(bio);
// dest.writeString(website);
// dest.writeString(twitter);
// dest.writeString(github);
// dest.writeString(photo);
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/ui/core/picasso/CircleTransformation.java
// public class CircleTransformation implements Transformation {
//
// @Override
// public Bitmap transform(Bitmap source) {
// int size = Math.min(source.getWidth(), source.getHeight());
//
// int x = (source.getWidth() - size) / 2;
// int y = (source.getHeight() - size) / 2;
//
// Bitmap squaredBitmap = Bitmap.createBitmap(source, x, y, size, size);
// if (squaredBitmap != source) {
// source.recycle();
// }
//
// Bitmap.Config config = source.getConfig() != null ? source.getConfig() : Bitmap.Config.ARGB_8888;
// Bitmap bitmap = Bitmap.createBitmap(size, size, config);
//
// Canvas canvas = new Canvas(bitmap);
// Paint paint = new Paint();
// BitmapShader shader = new BitmapShader(squaredBitmap, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP);
// paint.setShader(shader);
// paint.setAntiAlias(true);
//
// float r = size / 2f;
// canvas.drawCircle(r, r, r, paint);
//
// squaredBitmap.recycle();
// return bitmap;
// }
//
// @Override
// public String key() {
// return "circle";
// }
// }
|
import android.content.Context;
import android.text.TextUtils;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.nilhcem.devoxxfr.R;
import com.nilhcem.devoxxfr.data.app.model.Speaker;
import com.nilhcem.devoxxfr.ui.core.picasso.CircleTransformation;
import com.squareup.picasso.Picasso;
import butterknife.Bind;
import butterknife.ButterKnife;
|
package com.nilhcem.devoxxfr.ui.schedule.day;
public class ScheduleDayEntrySpeaker extends LinearLayout {
@Bind(R.id.schedule_day_entry_speaker_photo) ImageView photo;
@Bind(R.id.schedule_day_entry_speaker_name) TextView name;
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Speaker.java
// @Value
// public class Speaker implements Parcelable {
//
// public static final Parcelable.Creator<Speaker> CREATOR = new Parcelable.Creator<Speaker>() {
// public Speaker createFromParcel(Parcel source) {
// return new Speaker(source);
// }
//
// public Speaker[] newArray(int size) {
// return new Speaker[size];
// }
// };
//
// int id;
// String name;
// String title;
// String bio;
// String website;
// String twitter;
// String github;
// String photo;
//
// public Speaker(int id, String name, String title, String bio, String website, String twitter, String github, String photo) {
// this.id = id;
// this.name = name;
// this.title = title;
// this.bio = bio;
// this.website = website;
// this.twitter = twitter;
// this.github = github;
// this.photo = photo;
// }
//
// protected Speaker(Parcel in) {
// id = in.readInt();
// name = in.readString();
// title = in.readString();
// bio = in.readString();
// website = in.readString();
// twitter = in.readString();
// github = in.readString();
// photo = in.readString();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(name);
// dest.writeString(title);
// dest.writeString(bio);
// dest.writeString(website);
// dest.writeString(twitter);
// dest.writeString(github);
// dest.writeString(photo);
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/ui/core/picasso/CircleTransformation.java
// public class CircleTransformation implements Transformation {
//
// @Override
// public Bitmap transform(Bitmap source) {
// int size = Math.min(source.getWidth(), source.getHeight());
//
// int x = (source.getWidth() - size) / 2;
// int y = (source.getHeight() - size) / 2;
//
// Bitmap squaredBitmap = Bitmap.createBitmap(source, x, y, size, size);
// if (squaredBitmap != source) {
// source.recycle();
// }
//
// Bitmap.Config config = source.getConfig() != null ? source.getConfig() : Bitmap.Config.ARGB_8888;
// Bitmap bitmap = Bitmap.createBitmap(size, size, config);
//
// Canvas canvas = new Canvas(bitmap);
// Paint paint = new Paint();
// BitmapShader shader = new BitmapShader(squaredBitmap, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP);
// paint.setShader(shader);
// paint.setAntiAlias(true);
//
// float r = size / 2f;
// canvas.drawCircle(r, r, r, paint);
//
// squaredBitmap.recycle();
// return bitmap;
// }
//
// @Override
// public String key() {
// return "circle";
// }
// }
// Path: app/src/main/java/com/nilhcem/devoxxfr/ui/schedule/day/ScheduleDayEntrySpeaker.java
import android.content.Context;
import android.text.TextUtils;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.nilhcem.devoxxfr.R;
import com.nilhcem.devoxxfr.data.app.model.Speaker;
import com.nilhcem.devoxxfr.ui.core.picasso.CircleTransformation;
import com.squareup.picasso.Picasso;
import butterknife.Bind;
import butterknife.ButterKnife;
package com.nilhcem.devoxxfr.ui.schedule.day;
public class ScheduleDayEntrySpeaker extends LinearLayout {
@Bind(R.id.schedule_day_entry_speaker_photo) ImageView photo;
@Bind(R.id.schedule_day_entry_speaker_name) TextView name;
|
public ScheduleDayEntrySpeaker(Context context, Speaker speaker, Picasso picasso) {
|
Nilhcem/devoxxfr-2016
|
app/src/main/java/com/nilhcem/devoxxfr/ui/schedule/day/ScheduleDayEntrySpeaker.java
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Speaker.java
// @Value
// public class Speaker implements Parcelable {
//
// public static final Parcelable.Creator<Speaker> CREATOR = new Parcelable.Creator<Speaker>() {
// public Speaker createFromParcel(Parcel source) {
// return new Speaker(source);
// }
//
// public Speaker[] newArray(int size) {
// return new Speaker[size];
// }
// };
//
// int id;
// String name;
// String title;
// String bio;
// String website;
// String twitter;
// String github;
// String photo;
//
// public Speaker(int id, String name, String title, String bio, String website, String twitter, String github, String photo) {
// this.id = id;
// this.name = name;
// this.title = title;
// this.bio = bio;
// this.website = website;
// this.twitter = twitter;
// this.github = github;
// this.photo = photo;
// }
//
// protected Speaker(Parcel in) {
// id = in.readInt();
// name = in.readString();
// title = in.readString();
// bio = in.readString();
// website = in.readString();
// twitter = in.readString();
// github = in.readString();
// photo = in.readString();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(name);
// dest.writeString(title);
// dest.writeString(bio);
// dest.writeString(website);
// dest.writeString(twitter);
// dest.writeString(github);
// dest.writeString(photo);
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/ui/core/picasso/CircleTransformation.java
// public class CircleTransformation implements Transformation {
//
// @Override
// public Bitmap transform(Bitmap source) {
// int size = Math.min(source.getWidth(), source.getHeight());
//
// int x = (source.getWidth() - size) / 2;
// int y = (source.getHeight() - size) / 2;
//
// Bitmap squaredBitmap = Bitmap.createBitmap(source, x, y, size, size);
// if (squaredBitmap != source) {
// source.recycle();
// }
//
// Bitmap.Config config = source.getConfig() != null ? source.getConfig() : Bitmap.Config.ARGB_8888;
// Bitmap bitmap = Bitmap.createBitmap(size, size, config);
//
// Canvas canvas = new Canvas(bitmap);
// Paint paint = new Paint();
// BitmapShader shader = new BitmapShader(squaredBitmap, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP);
// paint.setShader(shader);
// paint.setAntiAlias(true);
//
// float r = size / 2f;
// canvas.drawCircle(r, r, r, paint);
//
// squaredBitmap.recycle();
// return bitmap;
// }
//
// @Override
// public String key() {
// return "circle";
// }
// }
|
import android.content.Context;
import android.text.TextUtils;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.nilhcem.devoxxfr.R;
import com.nilhcem.devoxxfr.data.app.model.Speaker;
import com.nilhcem.devoxxfr.ui.core.picasso.CircleTransformation;
import com.squareup.picasso.Picasso;
import butterknife.Bind;
import butterknife.ButterKnife;
|
package com.nilhcem.devoxxfr.ui.schedule.day;
public class ScheduleDayEntrySpeaker extends LinearLayout {
@Bind(R.id.schedule_day_entry_speaker_photo) ImageView photo;
@Bind(R.id.schedule_day_entry_speaker_name) TextView name;
public ScheduleDayEntrySpeaker(Context context, Speaker speaker, Picasso picasso) {
super(context);
setOrientation(HORIZONTAL);
int padding = Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, context.getResources().getDisplayMetrics()));
setPadding(0, padding, 0, padding);
LayoutInflater.from(context).inflate(R.layout.schedule_day_entry_speaker, this);
ButterKnife.bind(this, this);
bind(speaker, picasso);
}
private void bind(Speaker speaker, Picasso picasso) {
String photoUrl = speaker.getPhoto();
if (!TextUtils.isEmpty(photoUrl)) {
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Speaker.java
// @Value
// public class Speaker implements Parcelable {
//
// public static final Parcelable.Creator<Speaker> CREATOR = new Parcelable.Creator<Speaker>() {
// public Speaker createFromParcel(Parcel source) {
// return new Speaker(source);
// }
//
// public Speaker[] newArray(int size) {
// return new Speaker[size];
// }
// };
//
// int id;
// String name;
// String title;
// String bio;
// String website;
// String twitter;
// String github;
// String photo;
//
// public Speaker(int id, String name, String title, String bio, String website, String twitter, String github, String photo) {
// this.id = id;
// this.name = name;
// this.title = title;
// this.bio = bio;
// this.website = website;
// this.twitter = twitter;
// this.github = github;
// this.photo = photo;
// }
//
// protected Speaker(Parcel in) {
// id = in.readInt();
// name = in.readString();
// title = in.readString();
// bio = in.readString();
// website = in.readString();
// twitter = in.readString();
// github = in.readString();
// photo = in.readString();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(name);
// dest.writeString(title);
// dest.writeString(bio);
// dest.writeString(website);
// dest.writeString(twitter);
// dest.writeString(github);
// dest.writeString(photo);
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/ui/core/picasso/CircleTransformation.java
// public class CircleTransformation implements Transformation {
//
// @Override
// public Bitmap transform(Bitmap source) {
// int size = Math.min(source.getWidth(), source.getHeight());
//
// int x = (source.getWidth() - size) / 2;
// int y = (source.getHeight() - size) / 2;
//
// Bitmap squaredBitmap = Bitmap.createBitmap(source, x, y, size, size);
// if (squaredBitmap != source) {
// source.recycle();
// }
//
// Bitmap.Config config = source.getConfig() != null ? source.getConfig() : Bitmap.Config.ARGB_8888;
// Bitmap bitmap = Bitmap.createBitmap(size, size, config);
//
// Canvas canvas = new Canvas(bitmap);
// Paint paint = new Paint();
// BitmapShader shader = new BitmapShader(squaredBitmap, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP);
// paint.setShader(shader);
// paint.setAntiAlias(true);
//
// float r = size / 2f;
// canvas.drawCircle(r, r, r, paint);
//
// squaredBitmap.recycle();
// return bitmap;
// }
//
// @Override
// public String key() {
// return "circle";
// }
// }
// Path: app/src/main/java/com/nilhcem/devoxxfr/ui/schedule/day/ScheduleDayEntrySpeaker.java
import android.content.Context;
import android.text.TextUtils;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.nilhcem.devoxxfr.R;
import com.nilhcem.devoxxfr.data.app.model.Speaker;
import com.nilhcem.devoxxfr.ui.core.picasso.CircleTransformation;
import com.squareup.picasso.Picasso;
import butterknife.Bind;
import butterknife.ButterKnife;
package com.nilhcem.devoxxfr.ui.schedule.day;
public class ScheduleDayEntrySpeaker extends LinearLayout {
@Bind(R.id.schedule_day_entry_speaker_photo) ImageView photo;
@Bind(R.id.schedule_day_entry_speaker_name) TextView name;
public ScheduleDayEntrySpeaker(Context context, Speaker speaker, Picasso picasso) {
super(context);
setOrientation(HORIZONTAL);
int padding = Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, context.getResources().getDisplayMetrics()));
setPadding(0, padding, 0, padding);
LayoutInflater.from(context).inflate(R.layout.schedule_day_entry_speaker, this);
ButterKnife.bind(this, this);
bind(speaker, picasso);
}
private void bind(Speaker speaker, Picasso picasso) {
String photoUrl = speaker.getPhoto();
if (!TextUtils.isEmpty(photoUrl)) {
|
picasso.load(photoUrl).transform(new CircleTransformation()).into(photo);
|
Nilhcem/devoxxfr-2016
|
app/src/main/java/com/nilhcem/devoxxfr/core/dagger/module/AppModule.java
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/DevoxxApp.java
// @DebugLog
// public class DevoxxApp extends Application {
//
// private AppComponent component;
//
// public static DevoxxApp get(Context context) {
// return (DevoxxApp) context.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// AndroidThreeTen.init(this);
// initGraph();
// initLogger();
// }
//
// public AppComponent component() {
// return component;
// }
//
// private void initGraph() {
// component = AppComponent.Initializer.init(this);
// }
//
// private void initLogger() {
// Timber.plant(new Timber.DebugTree());
// }
// }
|
import android.app.Application;
import com.nilhcem.devoxxfr.DevoxxApp;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
|
package com.nilhcem.devoxxfr.core.dagger.module;
@Module
public final class AppModule {
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/DevoxxApp.java
// @DebugLog
// public class DevoxxApp extends Application {
//
// private AppComponent component;
//
// public static DevoxxApp get(Context context) {
// return (DevoxxApp) context.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// AndroidThreeTen.init(this);
// initGraph();
// initLogger();
// }
//
// public AppComponent component() {
// return component;
// }
//
// private void initGraph() {
// component = AppComponent.Initializer.init(this);
// }
//
// private void initLogger() {
// Timber.plant(new Timber.DebugTree());
// }
// }
// Path: app/src/main/java/com/nilhcem/devoxxfr/core/dagger/module/AppModule.java
import android.app.Application;
import com.nilhcem.devoxxfr.DevoxxApp;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
package com.nilhcem.devoxxfr.core.dagger.module;
@Module
public final class AppModule {
|
private final DevoxxApp app;
|
Nilhcem/devoxxfr-2016
|
app/src/test/java/com/nilhcem/devoxxfr/ui/schedule/day/ScheduleDayPresenterTest.java
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/ScheduleDay.java
// @Value
// public class ScheduleDay implements Parcelable {
//
// public static final Parcelable.Creator<ScheduleDay> CREATOR = new Parcelable.Creator<ScheduleDay>() {
// public ScheduleDay createFromParcel(Parcel source) {
// return new ScheduleDay(source);
// }
//
// public ScheduleDay[] newArray(int size) {
// return new ScheduleDay[size];
// }
// };
//
// LocalDate day;
// List<ScheduleSlot> slots;
//
// public ScheduleDay(LocalDate day, List<ScheduleSlot> slots) {
// this.day = day;
// this.slots = slots;
// }
//
// protected ScheduleDay(Parcel in) {
// day = (LocalDate) in.readSerializable();
// slots = in.createTypedArrayList(ScheduleSlot.CREATOR);
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeSerializable(day);
// dest.writeTypedList(slots);
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/ScheduleSlot.java
// @Value
// public class ScheduleSlot implements Parcelable {
//
// public static final Parcelable.Creator<ScheduleSlot> CREATOR = new Parcelable.Creator<ScheduleSlot>() {
// public ScheduleSlot createFromParcel(Parcel source) {
// return new ScheduleSlot(source);
// }
//
// public ScheduleSlot[] newArray(int size) {
// return new ScheduleSlot[size];
// }
// };
//
// LocalDateTime time;
// List<Session> sessions;
//
// public ScheduleSlot(LocalDateTime time, List<Session> sessions) {
// this.time = time;
// this.sessions = sessions;
// }
//
// protected ScheduleSlot(Parcel in) {
// time = (LocalDateTime) in.readSerializable();
// sessions = in.createTypedArrayList(Session.CREATOR);
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeSerializable(time);
// dest.writeTypedList(sessions);
// }
// }
|
import android.os.Build;
import com.nilhcem.devoxxfr.BuildConfig;
import com.nilhcem.devoxxfr.data.app.model.ScheduleDay;
import com.nilhcem.devoxxfr.data.app.model.ScheduleSlot;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricGradleTestRunner;
import org.robolectric.annotation.Config;
import org.threeten.bp.LocalDate;
import java.util.ArrayList;
import java.util.List;
import static org.mockito.Mockito.verify;
|
package com.nilhcem.devoxxfr.ui.schedule.day;
@RunWith(RobolectricGradleTestRunner.class)
@Config(constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP)
public class ScheduleDayPresenterTest {
@Mock ScheduleDayView view;
private ScheduleDayPresenter presenter;
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/ScheduleDay.java
// @Value
// public class ScheduleDay implements Parcelable {
//
// public static final Parcelable.Creator<ScheduleDay> CREATOR = new Parcelable.Creator<ScheduleDay>() {
// public ScheduleDay createFromParcel(Parcel source) {
// return new ScheduleDay(source);
// }
//
// public ScheduleDay[] newArray(int size) {
// return new ScheduleDay[size];
// }
// };
//
// LocalDate day;
// List<ScheduleSlot> slots;
//
// public ScheduleDay(LocalDate day, List<ScheduleSlot> slots) {
// this.day = day;
// this.slots = slots;
// }
//
// protected ScheduleDay(Parcel in) {
// day = (LocalDate) in.readSerializable();
// slots = in.createTypedArrayList(ScheduleSlot.CREATOR);
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeSerializable(day);
// dest.writeTypedList(slots);
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/ScheduleSlot.java
// @Value
// public class ScheduleSlot implements Parcelable {
//
// public static final Parcelable.Creator<ScheduleSlot> CREATOR = new Parcelable.Creator<ScheduleSlot>() {
// public ScheduleSlot createFromParcel(Parcel source) {
// return new ScheduleSlot(source);
// }
//
// public ScheduleSlot[] newArray(int size) {
// return new ScheduleSlot[size];
// }
// };
//
// LocalDateTime time;
// List<Session> sessions;
//
// public ScheduleSlot(LocalDateTime time, List<Session> sessions) {
// this.time = time;
// this.sessions = sessions;
// }
//
// protected ScheduleSlot(Parcel in) {
// time = (LocalDateTime) in.readSerializable();
// sessions = in.createTypedArrayList(Session.CREATOR);
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeSerializable(time);
// dest.writeTypedList(sessions);
// }
// }
// Path: app/src/test/java/com/nilhcem/devoxxfr/ui/schedule/day/ScheduleDayPresenterTest.java
import android.os.Build;
import com.nilhcem.devoxxfr.BuildConfig;
import com.nilhcem.devoxxfr.data.app.model.ScheduleDay;
import com.nilhcem.devoxxfr.data.app.model.ScheduleSlot;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricGradleTestRunner;
import org.robolectric.annotation.Config;
import org.threeten.bp.LocalDate;
import java.util.ArrayList;
import java.util.List;
import static org.mockito.Mockito.verify;
package com.nilhcem.devoxxfr.ui.schedule.day;
@RunWith(RobolectricGradleTestRunner.class)
@Config(constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP)
public class ScheduleDayPresenterTest {
@Mock ScheduleDayView view;
private ScheduleDayPresenter presenter;
|
private final List<ScheduleSlot> slots = new ArrayList<>();
|
Nilhcem/devoxxfr-2016
|
app/src/test/java/com/nilhcem/devoxxfr/ui/schedule/day/ScheduleDayPresenterTest.java
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/ScheduleDay.java
// @Value
// public class ScheduleDay implements Parcelable {
//
// public static final Parcelable.Creator<ScheduleDay> CREATOR = new Parcelable.Creator<ScheduleDay>() {
// public ScheduleDay createFromParcel(Parcel source) {
// return new ScheduleDay(source);
// }
//
// public ScheduleDay[] newArray(int size) {
// return new ScheduleDay[size];
// }
// };
//
// LocalDate day;
// List<ScheduleSlot> slots;
//
// public ScheduleDay(LocalDate day, List<ScheduleSlot> slots) {
// this.day = day;
// this.slots = slots;
// }
//
// protected ScheduleDay(Parcel in) {
// day = (LocalDate) in.readSerializable();
// slots = in.createTypedArrayList(ScheduleSlot.CREATOR);
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeSerializable(day);
// dest.writeTypedList(slots);
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/ScheduleSlot.java
// @Value
// public class ScheduleSlot implements Parcelable {
//
// public static final Parcelable.Creator<ScheduleSlot> CREATOR = new Parcelable.Creator<ScheduleSlot>() {
// public ScheduleSlot createFromParcel(Parcel source) {
// return new ScheduleSlot(source);
// }
//
// public ScheduleSlot[] newArray(int size) {
// return new ScheduleSlot[size];
// }
// };
//
// LocalDateTime time;
// List<Session> sessions;
//
// public ScheduleSlot(LocalDateTime time, List<Session> sessions) {
// this.time = time;
// this.sessions = sessions;
// }
//
// protected ScheduleSlot(Parcel in) {
// time = (LocalDateTime) in.readSerializable();
// sessions = in.createTypedArrayList(Session.CREATOR);
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeSerializable(time);
// dest.writeTypedList(sessions);
// }
// }
|
import android.os.Build;
import com.nilhcem.devoxxfr.BuildConfig;
import com.nilhcem.devoxxfr.data.app.model.ScheduleDay;
import com.nilhcem.devoxxfr.data.app.model.ScheduleSlot;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricGradleTestRunner;
import org.robolectric.annotation.Config;
import org.threeten.bp.LocalDate;
import java.util.ArrayList;
import java.util.List;
import static org.mockito.Mockito.verify;
|
package com.nilhcem.devoxxfr.ui.schedule.day;
@RunWith(RobolectricGradleTestRunner.class)
@Config(constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP)
public class ScheduleDayPresenterTest {
@Mock ScheduleDayView view;
private ScheduleDayPresenter presenter;
private final List<ScheduleSlot> slots = new ArrayList<>();
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/ScheduleDay.java
// @Value
// public class ScheduleDay implements Parcelable {
//
// public static final Parcelable.Creator<ScheduleDay> CREATOR = new Parcelable.Creator<ScheduleDay>() {
// public ScheduleDay createFromParcel(Parcel source) {
// return new ScheduleDay(source);
// }
//
// public ScheduleDay[] newArray(int size) {
// return new ScheduleDay[size];
// }
// };
//
// LocalDate day;
// List<ScheduleSlot> slots;
//
// public ScheduleDay(LocalDate day, List<ScheduleSlot> slots) {
// this.day = day;
// this.slots = slots;
// }
//
// protected ScheduleDay(Parcel in) {
// day = (LocalDate) in.readSerializable();
// slots = in.createTypedArrayList(ScheduleSlot.CREATOR);
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeSerializable(day);
// dest.writeTypedList(slots);
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/ScheduleSlot.java
// @Value
// public class ScheduleSlot implements Parcelable {
//
// public static final Parcelable.Creator<ScheduleSlot> CREATOR = new Parcelable.Creator<ScheduleSlot>() {
// public ScheduleSlot createFromParcel(Parcel source) {
// return new ScheduleSlot(source);
// }
//
// public ScheduleSlot[] newArray(int size) {
// return new ScheduleSlot[size];
// }
// };
//
// LocalDateTime time;
// List<Session> sessions;
//
// public ScheduleSlot(LocalDateTime time, List<Session> sessions) {
// this.time = time;
// this.sessions = sessions;
// }
//
// protected ScheduleSlot(Parcel in) {
// time = (LocalDateTime) in.readSerializable();
// sessions = in.createTypedArrayList(Session.CREATOR);
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeSerializable(time);
// dest.writeTypedList(sessions);
// }
// }
// Path: app/src/test/java/com/nilhcem/devoxxfr/ui/schedule/day/ScheduleDayPresenterTest.java
import android.os.Build;
import com.nilhcem.devoxxfr.BuildConfig;
import com.nilhcem.devoxxfr.data.app.model.ScheduleDay;
import com.nilhcem.devoxxfr.data.app.model.ScheduleSlot;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricGradleTestRunner;
import org.robolectric.annotation.Config;
import org.threeten.bp.LocalDate;
import java.util.ArrayList;
import java.util.List;
import static org.mockito.Mockito.verify;
package com.nilhcem.devoxxfr.ui.schedule.day;
@RunWith(RobolectricGradleTestRunner.class)
@Config(constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP)
public class ScheduleDayPresenterTest {
@Mock ScheduleDayView view;
private ScheduleDayPresenter presenter;
private final List<ScheduleSlot> slots = new ArrayList<>();
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
|
ScheduleDay scheduleDay = new ScheduleDay(LocalDate.now(), slots);
|
Nilhcem/devoxxfr-2016
|
app/src/main/java/com/nilhcem/devoxxfr/data/network/DevoxxService.java
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/network/model/Session.java
// @Value
// public class Session {
//
// int id;
// LocalDateTime startAt;
// int duration;
// int roomId;
// List<Integer> speakersId;
// String title;
// String description;
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/network/model/Speaker.java
// @Value
// public class Speaker {
//
// int id;
// String name;
// String title;
// String bio;
// String website;
// String twitter;
// String github;
// String photo;
// }
|
import com.nilhcem.devoxxfr.data.network.model.Session;
import com.nilhcem.devoxxfr.data.network.model.Speaker;
import java.util.List;
import retrofit2.http.GET;
import rx.Observable;
|
package com.nilhcem.devoxxfr.data.network;
public interface DevoxxService {
@GET("sessions")
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/network/model/Session.java
// @Value
// public class Session {
//
// int id;
// LocalDateTime startAt;
// int duration;
// int roomId;
// List<Integer> speakersId;
// String title;
// String description;
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/network/model/Speaker.java
// @Value
// public class Speaker {
//
// int id;
// String name;
// String title;
// String bio;
// String website;
// String twitter;
// String github;
// String photo;
// }
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/network/DevoxxService.java
import com.nilhcem.devoxxfr.data.network.model.Session;
import com.nilhcem.devoxxfr.data.network.model.Speaker;
import java.util.List;
import retrofit2.http.GET;
import rx.Observable;
package com.nilhcem.devoxxfr.data.network;
public interface DevoxxService {
@GET("sessions")
|
Observable<List<Session>> loadSessions();
|
Nilhcem/devoxxfr-2016
|
app/src/main/java/com/nilhcem/devoxxfr/data/network/DevoxxService.java
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/network/model/Session.java
// @Value
// public class Session {
//
// int id;
// LocalDateTime startAt;
// int duration;
// int roomId;
// List<Integer> speakersId;
// String title;
// String description;
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/network/model/Speaker.java
// @Value
// public class Speaker {
//
// int id;
// String name;
// String title;
// String bio;
// String website;
// String twitter;
// String github;
// String photo;
// }
|
import com.nilhcem.devoxxfr.data.network.model.Session;
import com.nilhcem.devoxxfr.data.network.model.Speaker;
import java.util.List;
import retrofit2.http.GET;
import rx.Observable;
|
package com.nilhcem.devoxxfr.data.network;
public interface DevoxxService {
@GET("sessions")
Observable<List<Session>> loadSessions();
@GET("speakers")
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/network/model/Session.java
// @Value
// public class Session {
//
// int id;
// LocalDateTime startAt;
// int duration;
// int roomId;
// List<Integer> speakersId;
// String title;
// String description;
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/network/model/Speaker.java
// @Value
// public class Speaker {
//
// int id;
// String name;
// String title;
// String bio;
// String website;
// String twitter;
// String github;
// String photo;
// }
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/network/DevoxxService.java
import com.nilhcem.devoxxfr.data.network.model.Session;
import com.nilhcem.devoxxfr.data.network.model.Speaker;
import java.util.List;
import retrofit2.http.GET;
import rx.Observable;
package com.nilhcem.devoxxfr.data.network;
public interface DevoxxService {
@GET("sessions")
Observable<List<Session>> loadSessions();
@GET("speakers")
|
Observable<List<Speaker>> loadSpeakers();
|
danielgimenes/NasaPic
|
app/src/main/java/br/com/dgimenes/nasapic/control/activity/TrackedActivity.java
|
// Path: app/src/main/java/br/com/dgimenes/nasapic/service/EventsLogger.java
// public class EventsLogger {
//
// private static boolean initialized = false;
//
// public static void initialize(Context context) {
// if (!initialized) {
// initialized = true;
//
// // Fabric
// Fabric.with(context, new Crashlytics(), new Answers());
//
// // Flurry
// try {
// ApplicationInfo ai = context.getPackageManager()
// .getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA);
// Bundle bundle = ai.metaData;
// String flurryApiKey = bundle.getString("flurry.ApiKey");
// FlurryAgent.setLogEnabled(false);
// FlurryAgent.setContinueSessionMillis(30000);
// FlurryAgent.init(context, flurryApiKey);
// } catch (Exception e) {
// Crashlytics.logException(e);
// }
// }
// }
//
// public static void logSessionStart(Context context) {
// // Flurry
// FlurryAgent.onStartSession(context);
// }
//
// public static void logSessionEnd(Context context) {
// // Flurry
// FlurryAgent.onEndSession(context);
// }
//
// public static void logEvent(String description) {
// // Fabric
// Answers.getInstance().logCustom(new CustomEvent(description));
//
// // Flurry
// FlurryAgent.logEvent(description);
// }
//
// public static void logError(ErrorMessage error, Throwable e) {
// // Fabric
// Answers.getInstance().logCustom(new CustomEvent("ERROR" + error.analyticsMessage));
// if (e != null) {
// Crashlytics.logException(e);
// }
//
// // Flurry
// if (e != null) {
// FlurryAgent.onError(error.id, error.analyticsMessage, e);
// } else {
// FlurryAgent.onError(error.id, error.analyticsMessage, "unknown");
// }
// }
// }
|
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import br.com.dgimenes.nasapic.service.EventsLogger;
|
package br.com.dgimenes.nasapic.control.activity;
public class TrackedActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
|
// Path: app/src/main/java/br/com/dgimenes/nasapic/service/EventsLogger.java
// public class EventsLogger {
//
// private static boolean initialized = false;
//
// public static void initialize(Context context) {
// if (!initialized) {
// initialized = true;
//
// // Fabric
// Fabric.with(context, new Crashlytics(), new Answers());
//
// // Flurry
// try {
// ApplicationInfo ai = context.getPackageManager()
// .getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA);
// Bundle bundle = ai.metaData;
// String flurryApiKey = bundle.getString("flurry.ApiKey");
// FlurryAgent.setLogEnabled(false);
// FlurryAgent.setContinueSessionMillis(30000);
// FlurryAgent.init(context, flurryApiKey);
// } catch (Exception e) {
// Crashlytics.logException(e);
// }
// }
// }
//
// public static void logSessionStart(Context context) {
// // Flurry
// FlurryAgent.onStartSession(context);
// }
//
// public static void logSessionEnd(Context context) {
// // Flurry
// FlurryAgent.onEndSession(context);
// }
//
// public static void logEvent(String description) {
// // Fabric
// Answers.getInstance().logCustom(new CustomEvent(description));
//
// // Flurry
// FlurryAgent.logEvent(description);
// }
//
// public static void logError(ErrorMessage error, Throwable e) {
// // Fabric
// Answers.getInstance().logCustom(new CustomEvent("ERROR" + error.analyticsMessage));
// if (e != null) {
// Crashlytics.logException(e);
// }
//
// // Flurry
// if (e != null) {
// FlurryAgent.onError(error.id, error.analyticsMessage, e);
// } else {
// FlurryAgent.onError(error.id, error.analyticsMessage, "unknown");
// }
// }
// }
// Path: app/src/main/java/br/com/dgimenes/nasapic/control/activity/TrackedActivity.java
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import br.com.dgimenes.nasapic.service.EventsLogger;
package br.com.dgimenes.nasapic.control.activity;
public class TrackedActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
|
EventsLogger.initialize(this);
|
danielgimenes/NasaPic
|
app/src/main/java/br/com/dgimenes/nasapic/model/SpacePic.java
|
// Path: app/src/main/java/br/com/dgimenes/nasapic/model/api/SpacePicDTO.java
// public class SpacePicDTO {
//
// @SerializedName("hd-image-url")
// private String hdImageUrl;
//
// @SerializedName("preview-image-url")
// private String previewImageUrl;
//
// @SerializedName("originally-published-at")
// private Date originallyPublishedAt;
//
// private String description;
//
// private String title;
//
// @SerializedName("published-at")
// private Date publishedAt;
//
// private String source;
//
// public SpacePicDTO() {
// }
//
// public String getHdImageUrl() {
// return hdImageUrl;
// }
//
// public void setHdImageUrl(String hdImageUrl) {
// this.hdImageUrl = hdImageUrl;
// }
//
// public String getPreviewImageUrl() {
// return previewImageUrl;
// }
//
// public void setPreviewImageUrl(String previewImageUrl) {
// this.previewImageUrl = previewImageUrl;
// }
//
// public Date getOriginallyPublishedAt() {
// return originallyPublishedAt;
// }
//
// public void setOriginallyPublishedAt(Date originallyPublishedAt) {
// this.originallyPublishedAt = originallyPublishedAt;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public Date getPublishedAt() {
// return publishedAt;
// }
//
// public void setPublishedAt(Date publishedAt) {
// this.publishedAt = publishedAt;
// }
//
// public String getSource() {
// return source;
// }
//
// public void setSource(String source) {
// this.source = source;
// }
// }
|
import android.os.Parcel;
import android.os.Parcelable;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import br.com.dgimenes.nasapic.model.api.SpacePicDTO;
|
package br.com.dgimenes.nasapic.model;
public class SpacePic implements Parcelable {
private String hdImageUrl;
private String previewImageUrl;
private Date originallyPublishedAt;
private String description;
private String title;
private Date publishedAt;
private String source;
public SpacePic(String hdImageUrl, String previewImageUrl, Date originallyPublishedAt,
String description, String title, Date publishedAt, String source) {
this.hdImageUrl = hdImageUrl;
this.previewImageUrl = previewImageUrl;
this.originallyPublishedAt = originallyPublishedAt;
this.description = description;
this.title = title;
this.publishedAt = publishedAt;
this.source = source;
}
|
// Path: app/src/main/java/br/com/dgimenes/nasapic/model/api/SpacePicDTO.java
// public class SpacePicDTO {
//
// @SerializedName("hd-image-url")
// private String hdImageUrl;
//
// @SerializedName("preview-image-url")
// private String previewImageUrl;
//
// @SerializedName("originally-published-at")
// private Date originallyPublishedAt;
//
// private String description;
//
// private String title;
//
// @SerializedName("published-at")
// private Date publishedAt;
//
// private String source;
//
// public SpacePicDTO() {
// }
//
// public String getHdImageUrl() {
// return hdImageUrl;
// }
//
// public void setHdImageUrl(String hdImageUrl) {
// this.hdImageUrl = hdImageUrl;
// }
//
// public String getPreviewImageUrl() {
// return previewImageUrl;
// }
//
// public void setPreviewImageUrl(String previewImageUrl) {
// this.previewImageUrl = previewImageUrl;
// }
//
// public Date getOriginallyPublishedAt() {
// return originallyPublishedAt;
// }
//
// public void setOriginallyPublishedAt(Date originallyPublishedAt) {
// this.originallyPublishedAt = originallyPublishedAt;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public Date getPublishedAt() {
// return publishedAt;
// }
//
// public void setPublishedAt(Date publishedAt) {
// this.publishedAt = publishedAt;
// }
//
// public String getSource() {
// return source;
// }
//
// public void setSource(String source) {
// this.source = source;
// }
// }
// Path: app/src/main/java/br/com/dgimenes/nasapic/model/SpacePic.java
import android.os.Parcel;
import android.os.Parcelable;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import br.com.dgimenes.nasapic.model.api.SpacePicDTO;
package br.com.dgimenes.nasapic.model;
public class SpacePic implements Parcelable {
private String hdImageUrl;
private String previewImageUrl;
private Date originallyPublishedAt;
private String description;
private String title;
private Date publishedAt;
private String source;
public SpacePic(String hdImageUrl, String previewImageUrl, Date originallyPublishedAt,
String description, String title, Date publishedAt, String source) {
this.hdImageUrl = hdImageUrl;
this.previewImageUrl = previewImageUrl;
this.originallyPublishedAt = originallyPublishedAt;
this.description = description;
this.title = title;
this.publishedAt = publishedAt;
this.source = source;
}
|
public SpacePic(SpacePicDTO dto) {
|
danielgimenes/NasaPic
|
app/src/main/java/br/com/dgimenes/nasapic/model/APOD.java
|
// Path: app/src/main/java/br/com/dgimenes/nasapic/model/api/ApodDTO.java
// public class ApodDTO {
// private String url;
// @SerializedName("media_type")
// private String mediaType;
// private String explanation;
// private List<String> concepts;
// private String title;
//
// public ApodDTO(String url, String mediaType, String explanation, List<String> concepts, String title) {
// this.url = url;
// this.mediaType = mediaType;
// this.explanation = explanation;
// this.concepts = concepts;
// this.title = title;
// }
//
// public String getUrl() {
// return url;
// }
//
// public String getMediaType() {
// return mediaType;
// }
//
// public String getExplanation() {
// return explanation;
// }
//
// public List<String> getConcepts() {
// return concepts;
// }
//
// public String getTitle() {
// return title;
// }
// }
|
import android.os.Parcel;
import android.os.Parcelable;
import java.util.Date;
import br.com.dgimenes.nasapic.model.api.ApodDTO;
|
package br.com.dgimenes.nasapic.model;
public class APOD implements Parcelable {
private String url;
private String explanation;
private String title;
private Date date;
|
// Path: app/src/main/java/br/com/dgimenes/nasapic/model/api/ApodDTO.java
// public class ApodDTO {
// private String url;
// @SerializedName("media_type")
// private String mediaType;
// private String explanation;
// private List<String> concepts;
// private String title;
//
// public ApodDTO(String url, String mediaType, String explanation, List<String> concepts, String title) {
// this.url = url;
// this.mediaType = mediaType;
// this.explanation = explanation;
// this.concepts = concepts;
// this.title = title;
// }
//
// public String getUrl() {
// return url;
// }
//
// public String getMediaType() {
// return mediaType;
// }
//
// public String getExplanation() {
// return explanation;
// }
//
// public List<String> getConcepts() {
// return concepts;
// }
//
// public String getTitle() {
// return title;
// }
// }
// Path: app/src/main/java/br/com/dgimenes/nasapic/model/APOD.java
import android.os.Parcel;
import android.os.Parcelable;
import java.util.Date;
import br.com.dgimenes.nasapic.model.api.ApodDTO;
package br.com.dgimenes.nasapic.model;
public class APOD implements Parcelable {
private String url;
private String explanation;
private String title;
private Date date;
|
public APOD(ApodDTO apodDTO, Date date) {
|
danielgimenes/NasaPic
|
app/src/main/java/br/com/dgimenes/nasapic/service/EventsLogger.java
|
// Path: app/src/main/java/br/com/dgimenes/nasapic/control/ErrorMessage.java
// public enum ErrorMessage {
// DOWNLOADING_IMAGE("Error downloading image", R.string.error_downloading_apod), //
// LOADING_RECENT_PICS("Error loading recent pictures", R.string.error_loading_feed),
// LOADING_BEST_PICS("Error loading best pictures", R.string.error_loading_feed), //
// SETTING_WALLPAPER("Error setting wallpaper set manually", R.string.error_setting_wallpaper), //
// SETTING_WALLPAPER_AUTO("Error setting wallpaper set automatically", R.string.periodic_change_error), //
// UNDOING_WALLPAPER_CHANGE("Error undoing wallpaper change", R.string.undo_error_message), //
// ; //
//
// public final String id;
// public final String analyticsMessage;
// public final int userMessageRes;
//
// ErrorMessage(String analyticsMessage, int userMessageRes) {
// this.id = this.name();
// this.analyticsMessage = analyticsMessage;
// this.userMessageRes = userMessageRes;
// }
// }
|
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import com.crashlytics.android.Crashlytics;
import com.crashlytics.android.answers.Answers;
import com.crashlytics.android.answers.CustomEvent;
import com.flurry.android.FlurryAgent;
import br.com.dgimenes.nasapic.control.ErrorMessage;
import io.fabric.sdk.android.Fabric;
|
package br.com.dgimenes.nasapic.service;
public class EventsLogger {
private static boolean initialized = false;
public static void initialize(Context context) {
if (!initialized) {
initialized = true;
// Fabric
Fabric.with(context, new Crashlytics(), new Answers());
// Flurry
try {
ApplicationInfo ai = context.getPackageManager()
.getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA);
Bundle bundle = ai.metaData;
String flurryApiKey = bundle.getString("flurry.ApiKey");
FlurryAgent.setLogEnabled(false);
FlurryAgent.setContinueSessionMillis(30000);
FlurryAgent.init(context, flurryApiKey);
} catch (Exception e) {
Crashlytics.logException(e);
}
}
}
public static void logSessionStart(Context context) {
// Flurry
FlurryAgent.onStartSession(context);
}
public static void logSessionEnd(Context context) {
// Flurry
FlurryAgent.onEndSession(context);
}
public static void logEvent(String description) {
// Fabric
Answers.getInstance().logCustom(new CustomEvent(description));
// Flurry
FlurryAgent.logEvent(description);
}
|
// Path: app/src/main/java/br/com/dgimenes/nasapic/control/ErrorMessage.java
// public enum ErrorMessage {
// DOWNLOADING_IMAGE("Error downloading image", R.string.error_downloading_apod), //
// LOADING_RECENT_PICS("Error loading recent pictures", R.string.error_loading_feed),
// LOADING_BEST_PICS("Error loading best pictures", R.string.error_loading_feed), //
// SETTING_WALLPAPER("Error setting wallpaper set manually", R.string.error_setting_wallpaper), //
// SETTING_WALLPAPER_AUTO("Error setting wallpaper set automatically", R.string.periodic_change_error), //
// UNDOING_WALLPAPER_CHANGE("Error undoing wallpaper change", R.string.undo_error_message), //
// ; //
//
// public final String id;
// public final String analyticsMessage;
// public final int userMessageRes;
//
// ErrorMessage(String analyticsMessage, int userMessageRes) {
// this.id = this.name();
// this.analyticsMessage = analyticsMessage;
// this.userMessageRes = userMessageRes;
// }
// }
// Path: app/src/main/java/br/com/dgimenes/nasapic/service/EventsLogger.java
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import com.crashlytics.android.Crashlytics;
import com.crashlytics.android.answers.Answers;
import com.crashlytics.android.answers.CustomEvent;
import com.flurry.android.FlurryAgent;
import br.com.dgimenes.nasapic.control.ErrorMessage;
import io.fabric.sdk.android.Fabric;
package br.com.dgimenes.nasapic.service;
public class EventsLogger {
private static boolean initialized = false;
public static void initialize(Context context) {
if (!initialized) {
initialized = true;
// Fabric
Fabric.with(context, new Crashlytics(), new Answers());
// Flurry
try {
ApplicationInfo ai = context.getPackageManager()
.getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA);
Bundle bundle = ai.metaData;
String flurryApiKey = bundle.getString("flurry.ApiKey");
FlurryAgent.setLogEnabled(false);
FlurryAgent.setContinueSessionMillis(30000);
FlurryAgent.init(context, flurryApiKey);
} catch (Exception e) {
Crashlytics.logException(e);
}
}
}
public static void logSessionStart(Context context) {
// Flurry
FlurryAgent.onStartSession(context);
}
public static void logSessionEnd(Context context) {
// Flurry
FlurryAgent.onEndSession(context);
}
public static void logEvent(String description) {
// Fabric
Answers.getInstance().logCustom(new CustomEvent(description));
// Flurry
FlurryAgent.logEvent(description);
}
|
public static void logError(ErrorMessage error, Throwable e) {
|
danielgimenes/NasaPic
|
app/src/main/java/br/com/dgimenes/nasapic/service/web/NasaPicServerWebservice.java
|
// Path: app/src/main/java/br/com/dgimenes/nasapic/model/api/FeedDTO.java
// public class FeedDTO {
// @SerializedName("paging")
// private PagingInfo pagingInfo;
//
// @SerializedName("data")
// private List<SpacePicDTO> spacePics;
//
// public List<SpacePicDTO> getSpacePics() {
// return spacePics;
// }
//
// public void setSpacePics(List<SpacePicDTO> spacePics) {
// this.spacePics = spacePics;
// }
//
// public PagingInfo getPagingInfo() {
// return pagingInfo;
// }
//
// public void setPagingInfo(PagingInfo pagingInfo) {
// this.pagingInfo = pagingInfo;
// }
// }
|
import br.com.dgimenes.nasapic.model.api.FeedDTO;
import retrofit.Callback;
import retrofit.http.GET;
import retrofit.http.Query;
|
package br.com.dgimenes.nasapic.service.web;
public interface NasaPicServerWebservice {
@GET("/feed/list")
|
// Path: app/src/main/java/br/com/dgimenes/nasapic/model/api/FeedDTO.java
// public class FeedDTO {
// @SerializedName("paging")
// private PagingInfo pagingInfo;
//
// @SerializedName("data")
// private List<SpacePicDTO> spacePics;
//
// public List<SpacePicDTO> getSpacePics() {
// return spacePics;
// }
//
// public void setSpacePics(List<SpacePicDTO> spacePics) {
// this.spacePics = spacePics;
// }
//
// public PagingInfo getPagingInfo() {
// return pagingInfo;
// }
//
// public void setPagingInfo(PagingInfo pagingInfo) {
// this.pagingInfo = pagingInfo;
// }
// }
// Path: app/src/main/java/br/com/dgimenes/nasapic/service/web/NasaPicServerWebservice.java
import br.com.dgimenes.nasapic.model.api.FeedDTO;
import retrofit.Callback;
import retrofit.http.GET;
import retrofit.http.Query;
package br.com.dgimenes.nasapic.service.web;
public interface NasaPicServerWebservice {
@GET("/feed/list")
|
void getFeed(@Query("page") int page, Callback<FeedDTO> callback);
|
aponom84/MetrizedSmallWorld
|
src/main/java/org/latna/msw/PowerLawTestTrec3.java
|
// Path: src/main/java/org/latna/msw/documents/DocumentFileFactory.java
// public class DocumentFileFactory implements MetricElementFactory {
// public String testDataDirPath="C:/msw/MetricSpaceLibrary/dbs/documents/short";
// private int maxDoc;
//
// @Override
// public List<MetricElement> getElements() {
// List <MetricElement> docList = new ArrayList();
// File dir = new File(testDataDirPath);
// int i = 0;
// for (File file: dir.listFiles() ) {
// if (i > maxDoc) break;
//
// Scanner sc = null;
// try {
// sc = new Scanner(file);
// Document newDoc = new Document(file.getName());
//
// while (sc.hasNext()) {
// String termId = sc.next();
// String d = sc.next();
// double value = new Double(d);
//
// newDoc.addTerm(termId, value);
// }
// docList.add(newDoc);
// } catch (FileNotFoundException ex) {
// System.out.println(ex);
// } finally {
// sc.close();
// }
// i++;
// }
// System.out.println(i+ " documents readed");
// return docList;
// }
// /**
// * DocumentFileFactory get two parameters: [dir="filePath"] - path to directory
// * which contains set of documents presented by frequence term vector and
// * [maxDoc=d+] - the restriction on the number returned documents.
// * if you want do not restrict the number of documents set maxDoc=0
// * @param param
// */
// @Override
// public void setParameterString(String param) {
// Scanner s = new Scanner(new StringReader(param));
// s.findInLine("dir=(.+); maxDoc=(\\d+)");
// MatchResult matchResult = s.match();
//
// for (int i=1; i<=matchResult.groupCount(); i++)
// System.out.println(matchResult.group(i));
//
// s.close();
//
// testDataDirPath = matchResult.group(1);
// maxDoc = Integer.valueOf(matchResult.group(2));
//
// if (maxDoc == 0) maxDoc = Integer.MAX_VALUE;
//
// }
//
// }
|
import org.latna.msw.documents.DocumentFileFactory;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.TreeSet;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
|
package org.latna.msw;
/**
* This is a simple example of building MetrizedSmallWorld over the set of
* document objects from the trec-3 collection.
* Any document or query is represented by term frequency vector.
* The test is divided into the three stages.
*
* The first stage - reading data set to the memory (documents and queries),
* configuring algorithms and building the data structure.
*
* The second stage - to obtain the true nearest neighbor element for every
* query by the use sequentially scan
*
* The third stage - a search in metric data structure with several number
* of attempts, validate the search result.
*/
public class PowerLawTestTrec3 {
/**
* Scans input string and runs the test
* @param args the command line arguments
*/
public static void main(String[] args) {
int nn = 7; //number of nearest neighbors used in construction algorithm to approximate voronoi neighbor
int k = 5; //number of k-closest elements for the knn search
int initAttempts = 5; //number of search attempts used during the contruction of the structure
int minAttempts = 1 ; //minimum number of attempts used during the test search
int maxAttempts = 10; //maximum number of attempts
// int dataBaseSize = 1000;
int dataBaseSize = 0; //the restriction on the number of elements in the data structure. To set no restriction set value = 0
int querySetSize = 50; //the restriction on the number of quleries. To set no restriction set value = 0
int testSeqSize = 30; //number elements in the random selected subset used to verify accuracy of the search.
String dataPath = "C:/msw/MetricSpaceLibrary/dbs/documents/short"; //Path to directory documents from Trec-3 collection. See Metric Space Library
String queryPath = "C:/msw/MetricSpaceLibrary/dbs/documents/shortQueries"; //Path to queries
/* int nn = Integer.valueOf(args[0]);
int k = Integer.valueOf(args[1]);
int initAttempts = Integer.valueOf(args[2]);
int minAttempts = Integer.valueOf(args[3]);
int maxAttempts = Integer.valueOf(args[4]);
int dataBaseSize = Integer.valueOf(args[5]);
int querySetSize = Integer.valueOf(args[6]);
int testSeqSize = Integer.valueOf(args[7]);
String dataPath = args[8];
String queryPath = args[9];
*/
System.out.println("nn=" + nn + " k=" + k + " initAttemps="+initAttempts + " minAttempts=" + minAttempts + " maxAttempts=" +
maxAttempts + " dataBaseSize=" + dataBaseSize + " querySetSize=" + querySetSize + " testSeqSize=" + testSeqSize);
|
// Path: src/main/java/org/latna/msw/documents/DocumentFileFactory.java
// public class DocumentFileFactory implements MetricElementFactory {
// public String testDataDirPath="C:/msw/MetricSpaceLibrary/dbs/documents/short";
// private int maxDoc;
//
// @Override
// public List<MetricElement> getElements() {
// List <MetricElement> docList = new ArrayList();
// File dir = new File(testDataDirPath);
// int i = 0;
// for (File file: dir.listFiles() ) {
// if (i > maxDoc) break;
//
// Scanner sc = null;
// try {
// sc = new Scanner(file);
// Document newDoc = new Document(file.getName());
//
// while (sc.hasNext()) {
// String termId = sc.next();
// String d = sc.next();
// double value = new Double(d);
//
// newDoc.addTerm(termId, value);
// }
// docList.add(newDoc);
// } catch (FileNotFoundException ex) {
// System.out.println(ex);
// } finally {
// sc.close();
// }
// i++;
// }
// System.out.println(i+ " documents readed");
// return docList;
// }
// /**
// * DocumentFileFactory get two parameters: [dir="filePath"] - path to directory
// * which contains set of documents presented by frequence term vector and
// * [maxDoc=d+] - the restriction on the number returned documents.
// * if you want do not restrict the number of documents set maxDoc=0
// * @param param
// */
// @Override
// public void setParameterString(String param) {
// Scanner s = new Scanner(new StringReader(param));
// s.findInLine("dir=(.+); maxDoc=(\\d+)");
// MatchResult matchResult = s.match();
//
// for (int i=1; i<=matchResult.groupCount(); i++)
// System.out.println(matchResult.group(i));
//
// s.close();
//
// testDataDirPath = matchResult.group(1);
// maxDoc = Integer.valueOf(matchResult.group(2));
//
// if (maxDoc == 0) maxDoc = Integer.MAX_VALUE;
//
// }
//
// }
// Path: src/main/java/org/latna/msw/PowerLawTestTrec3.java
import org.latna.msw.documents.DocumentFileFactory;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.TreeSet;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
package org.latna.msw;
/**
* This is a simple example of building MetrizedSmallWorld over the set of
* document objects from the trec-3 collection.
* Any document or query is represented by term frequency vector.
* The test is divided into the three stages.
*
* The first stage - reading data set to the memory (documents and queries),
* configuring algorithms and building the data structure.
*
* The second stage - to obtain the true nearest neighbor element for every
* query by the use sequentially scan
*
* The third stage - a search in metric data structure with several number
* of attempts, validate the search result.
*/
public class PowerLawTestTrec3 {
/**
* Scans input string and runs the test
* @param args the command line arguments
*/
public static void main(String[] args) {
int nn = 7; //number of nearest neighbors used in construction algorithm to approximate voronoi neighbor
int k = 5; //number of k-closest elements for the knn search
int initAttempts = 5; //number of search attempts used during the contruction of the structure
int minAttempts = 1 ; //minimum number of attempts used during the test search
int maxAttempts = 10; //maximum number of attempts
// int dataBaseSize = 1000;
int dataBaseSize = 0; //the restriction on the number of elements in the data structure. To set no restriction set value = 0
int querySetSize = 50; //the restriction on the number of quleries. To set no restriction set value = 0
int testSeqSize = 30; //number elements in the random selected subset used to verify accuracy of the search.
String dataPath = "C:/msw/MetricSpaceLibrary/dbs/documents/short"; //Path to directory documents from Trec-3 collection. See Metric Space Library
String queryPath = "C:/msw/MetricSpaceLibrary/dbs/documents/shortQueries"; //Path to queries
/* int nn = Integer.valueOf(args[0]);
int k = Integer.valueOf(args[1]);
int initAttempts = Integer.valueOf(args[2]);
int minAttempts = Integer.valueOf(args[3]);
int maxAttempts = Integer.valueOf(args[4]);
int dataBaseSize = Integer.valueOf(args[5]);
int querySetSize = Integer.valueOf(args[6]);
int testSeqSize = Integer.valueOf(args[7]);
String dataPath = args[8];
String queryPath = args[9];
*/
System.out.println("nn=" + nn + " k=" + k + " initAttemps="+initAttempts + " minAttempts=" + minAttempts + " maxAttempts=" +
maxAttempts + " dataBaseSize=" + dataBaseSize + " querySetSize=" + querySetSize + " testSeqSize=" + testSeqSize);
|
MetricElementFactory elementFactory= new DocumentFileFactory();
|
aponom84/MetrizedSmallWorld
|
src/main/java/org/latna/msw/documents/DocumentFileFactory.java
|
// Path: src/main/java/org/latna/msw/MetricElement.java
// public abstract class MetricElement {
// private final List<MetricElement> friends;
//
// public MetricElement() {
// friends = Collections.synchronizedList(new ArrayList());
// }
//
// /**
// * Calculate metric between current object and another.
// * @param gme any element for whose metric can be calculated. Any element from domain set.
// * @return distance value
// */
// public abstract double calcDistance(MetricElement gme);
//
// public synchronized List<MetricElement> getAllFriends() {
// return friends;
// }
//
// public List<MetricElement> getAllFriendsOfAllFriends() {
// HashSet <MetricElement> hs=new HashSet();
// hs.add(this);
// for(int i=0;i<friends.size();i++){
// hs.add(friends.get(i));
// for(int j=0;j<friends.get(i).getAllFriends().size();j++)
// hs.add(friends.get(i).getAllFriends().get(j));
// }
// return new ArrayList(hs);
// }
//
// public MetricElement getClosestElemet(MetricElement q) {
// double min=this.calcDistance(q);
// int nummin=-1;
// for(int i=0;i<friends.size();i++){
// double temp=friends.get(i).calcDistance(q);
// if(temp<min){
// nummin=i;
// min=temp;
// }
//
// }
// if(nummin==-1)
// return this;
// else
// return friends.get(nummin);
// }
//
// public SearchResult getClosestElemetSearchResult(MetricElement q) {
// SearchResult s;
// TreeSet <EvaluatedElement> set = new TreeSet();
// for(int i=0;i<friends.size();i++){
// double temp=friends.get(i).calcDistance(q);
//
// set.add(new EvaluatedElement(temp, friends.get(i)));
//
// }
// return new SearchResult(set, null);
// }
//
// public synchronized void addFriend(MetricElement e) {
// if(!friends.contains(e))
// friends.add(e);
// }
//
// public synchronized void removeFriend(MetricElement e) {
// if(friends.contains(e))
// friends.remove(e);
// }
//
// public synchronized void removeAllFriends() {
// friends.clear();
// }
//
// }
//
// Path: src/main/java/org/latna/msw/MetricElementFactory.java
// public interface MetricElementFactory {
// /**
// *
// * @return List of Metric elements
// */
// public List <MetricElement> getElements();
// /**
// * Distinct implementation can have many configuration which may be incompatible
// * among themselves, therefore we use String to pass configuration to the factory
// * @param param configuration string for the factory
// */
// public void setParameterString(String param);
// }
|
import org.latna.msw.MetricElement;
import org.latna.msw.MetricElementFactory;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.regex.MatchResult;
|
package org.latna.msw.documents;
/**
* Reads the file directory and creates list of Documents
* @author Alexander Ponomarenko [email protected]
*/
public class DocumentFileFactory implements MetricElementFactory {
public String testDataDirPath="C:/msw/MetricSpaceLibrary/dbs/documents/short";
private int maxDoc;
@Override
|
// Path: src/main/java/org/latna/msw/MetricElement.java
// public abstract class MetricElement {
// private final List<MetricElement> friends;
//
// public MetricElement() {
// friends = Collections.synchronizedList(new ArrayList());
// }
//
// /**
// * Calculate metric between current object and another.
// * @param gme any element for whose metric can be calculated. Any element from domain set.
// * @return distance value
// */
// public abstract double calcDistance(MetricElement gme);
//
// public synchronized List<MetricElement> getAllFriends() {
// return friends;
// }
//
// public List<MetricElement> getAllFriendsOfAllFriends() {
// HashSet <MetricElement> hs=new HashSet();
// hs.add(this);
// for(int i=0;i<friends.size();i++){
// hs.add(friends.get(i));
// for(int j=0;j<friends.get(i).getAllFriends().size();j++)
// hs.add(friends.get(i).getAllFriends().get(j));
// }
// return new ArrayList(hs);
// }
//
// public MetricElement getClosestElemet(MetricElement q) {
// double min=this.calcDistance(q);
// int nummin=-1;
// for(int i=0;i<friends.size();i++){
// double temp=friends.get(i).calcDistance(q);
// if(temp<min){
// nummin=i;
// min=temp;
// }
//
// }
// if(nummin==-1)
// return this;
// else
// return friends.get(nummin);
// }
//
// public SearchResult getClosestElemetSearchResult(MetricElement q) {
// SearchResult s;
// TreeSet <EvaluatedElement> set = new TreeSet();
// for(int i=0;i<friends.size();i++){
// double temp=friends.get(i).calcDistance(q);
//
// set.add(new EvaluatedElement(temp, friends.get(i)));
//
// }
// return new SearchResult(set, null);
// }
//
// public synchronized void addFriend(MetricElement e) {
// if(!friends.contains(e))
// friends.add(e);
// }
//
// public synchronized void removeFriend(MetricElement e) {
// if(friends.contains(e))
// friends.remove(e);
// }
//
// public synchronized void removeAllFriends() {
// friends.clear();
// }
//
// }
//
// Path: src/main/java/org/latna/msw/MetricElementFactory.java
// public interface MetricElementFactory {
// /**
// *
// * @return List of Metric elements
// */
// public List <MetricElement> getElements();
// /**
// * Distinct implementation can have many configuration which may be incompatible
// * among themselves, therefore we use String to pass configuration to the factory
// * @param param configuration string for the factory
// */
// public void setParameterString(String param);
// }
// Path: src/main/java/org/latna/msw/documents/DocumentFileFactory.java
import org.latna.msw.MetricElement;
import org.latna.msw.MetricElementFactory;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.regex.MatchResult;
package org.latna.msw.documents;
/**
* Reads the file directory and creates list of Documents
* @author Alexander Ponomarenko [email protected]
*/
public class DocumentFileFactory implements MetricElementFactory {
public String testDataDirPath="C:/msw/MetricSpaceLibrary/dbs/documents/short";
private int maxDoc;
@Override
|
public List<MetricElement> getElements() {
|
aponom84/MetrizedSmallWorld
|
src/main/java/org/latna/msw/integervector/IntegerVectorFactory.java
|
// Path: src/main/java/org/latna/msw/MetricElement.java
// public abstract class MetricElement {
// private final List<MetricElement> friends;
//
// public MetricElement() {
// friends = Collections.synchronizedList(new ArrayList());
// }
//
// /**
// * Calculate metric between current object and another.
// * @param gme any element for whose metric can be calculated. Any element from domain set.
// * @return distance value
// */
// public abstract double calcDistance(MetricElement gme);
//
// public synchronized List<MetricElement> getAllFriends() {
// return friends;
// }
//
// public List<MetricElement> getAllFriendsOfAllFriends() {
// HashSet <MetricElement> hs=new HashSet();
// hs.add(this);
// for(int i=0;i<friends.size();i++){
// hs.add(friends.get(i));
// for(int j=0;j<friends.get(i).getAllFriends().size();j++)
// hs.add(friends.get(i).getAllFriends().get(j));
// }
// return new ArrayList(hs);
// }
//
// public MetricElement getClosestElemet(MetricElement q) {
// double min=this.calcDistance(q);
// int nummin=-1;
// for(int i=0;i<friends.size();i++){
// double temp=friends.get(i).calcDistance(q);
// if(temp<min){
// nummin=i;
// min=temp;
// }
//
// }
// if(nummin==-1)
// return this;
// else
// return friends.get(nummin);
// }
//
// public SearchResult getClosestElemetSearchResult(MetricElement q) {
// SearchResult s;
// TreeSet <EvaluatedElement> set = new TreeSet();
// for(int i=0;i<friends.size();i++){
// double temp=friends.get(i).calcDistance(q);
//
// set.add(new EvaluatedElement(temp, friends.get(i)));
//
// }
// return new SearchResult(set, null);
// }
//
// public synchronized void addFriend(MetricElement e) {
// if(!friends.contains(e))
// friends.add(e);
// }
//
// public synchronized void removeFriend(MetricElement e) {
// if(friends.contains(e))
// friends.remove(e);
// }
//
// public synchronized void removeAllFriends() {
// friends.clear();
// }
//
// }
//
// Path: src/main/java/org/latna/msw/MetricElementFactory.java
// public interface MetricElementFactory {
// /**
// *
// * @return List of Metric elements
// */
// public List <MetricElement> getElements();
// /**
// * Distinct implementation can have many configuration which may be incompatible
// * among themselves, therefore we use String to pass configuration to the factory
// * @param param configuration string for the factory
// */
// public void setParameterString(String param);
// }
|
import org.latna.msw.MetricElement;
import org.latna.msw.MetricElementFactory;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
|
package org.latna.msw.integervector;
/**
*
* @author aponom
*/
public class IntegerVectorFactory implements MetricElementFactory {
private int dimension;
private int n; //number of elements
|
// Path: src/main/java/org/latna/msw/MetricElement.java
// public abstract class MetricElement {
// private final List<MetricElement> friends;
//
// public MetricElement() {
// friends = Collections.synchronizedList(new ArrayList());
// }
//
// /**
// * Calculate metric between current object and another.
// * @param gme any element for whose metric can be calculated. Any element from domain set.
// * @return distance value
// */
// public abstract double calcDistance(MetricElement gme);
//
// public synchronized List<MetricElement> getAllFriends() {
// return friends;
// }
//
// public List<MetricElement> getAllFriendsOfAllFriends() {
// HashSet <MetricElement> hs=new HashSet();
// hs.add(this);
// for(int i=0;i<friends.size();i++){
// hs.add(friends.get(i));
// for(int j=0;j<friends.get(i).getAllFriends().size();j++)
// hs.add(friends.get(i).getAllFriends().get(j));
// }
// return new ArrayList(hs);
// }
//
// public MetricElement getClosestElemet(MetricElement q) {
// double min=this.calcDistance(q);
// int nummin=-1;
// for(int i=0;i<friends.size();i++){
// double temp=friends.get(i).calcDistance(q);
// if(temp<min){
// nummin=i;
// min=temp;
// }
//
// }
// if(nummin==-1)
// return this;
// else
// return friends.get(nummin);
// }
//
// public SearchResult getClosestElemetSearchResult(MetricElement q) {
// SearchResult s;
// TreeSet <EvaluatedElement> set = new TreeSet();
// for(int i=0;i<friends.size();i++){
// double temp=friends.get(i).calcDistance(q);
//
// set.add(new EvaluatedElement(temp, friends.get(i)));
//
// }
// return new SearchResult(set, null);
// }
//
// public synchronized void addFriend(MetricElement e) {
// if(!friends.contains(e))
// friends.add(e);
// }
//
// public synchronized void removeFriend(MetricElement e) {
// if(friends.contains(e))
// friends.remove(e);
// }
//
// public synchronized void removeAllFriends() {
// friends.clear();
// }
//
// }
//
// Path: src/main/java/org/latna/msw/MetricElementFactory.java
// public interface MetricElementFactory {
// /**
// *
// * @return List of Metric elements
// */
// public List <MetricElement> getElements();
// /**
// * Distinct implementation can have many configuration which may be incompatible
// * among themselves, therefore we use String to pass configuration to the factory
// * @param param configuration string for the factory
// */
// public void setParameterString(String param);
// }
// Path: src/main/java/org/latna/msw/integervector/IntegerVectorFactory.java
import org.latna.msw.MetricElement;
import org.latna.msw.MetricElementFactory;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
package org.latna.msw.integervector;
/**
*
* @author aponom
*/
public class IntegerVectorFactory implements MetricElementFactory {
private int dimension;
private int n; //number of elements
|
private List <MetricElement> allElements;
|
aponom84/MetrizedSmallWorld
|
src/main/java/org/latna/msw/wikisparse/WikiSparseFactory.java
|
// Path: src/main/java/org/latna/msw/MetricElement.java
// public abstract class MetricElement {
// private final List<MetricElement> friends;
//
// public MetricElement() {
// friends = Collections.synchronizedList(new ArrayList());
// }
//
// /**
// * Calculate metric between current object and another.
// * @param gme any element for whose metric can be calculated. Any element from domain set.
// * @return distance value
// */
// public abstract double calcDistance(MetricElement gme);
//
// public synchronized List<MetricElement> getAllFriends() {
// return friends;
// }
//
// public List<MetricElement> getAllFriendsOfAllFriends() {
// HashSet <MetricElement> hs=new HashSet();
// hs.add(this);
// for(int i=0;i<friends.size();i++){
// hs.add(friends.get(i));
// for(int j=0;j<friends.get(i).getAllFriends().size();j++)
// hs.add(friends.get(i).getAllFriends().get(j));
// }
// return new ArrayList(hs);
// }
//
// public MetricElement getClosestElemet(MetricElement q) {
// double min=this.calcDistance(q);
// int nummin=-1;
// for(int i=0;i<friends.size();i++){
// double temp=friends.get(i).calcDistance(q);
// if(temp<min){
// nummin=i;
// min=temp;
// }
//
// }
// if(nummin==-1)
// return this;
// else
// return friends.get(nummin);
// }
//
// public SearchResult getClosestElemetSearchResult(MetricElement q) {
// SearchResult s;
// TreeSet <EvaluatedElement> set = new TreeSet();
// for(int i=0;i<friends.size();i++){
// double temp=friends.get(i).calcDistance(q);
//
// set.add(new EvaluatedElement(temp, friends.get(i)));
//
// }
// return new SearchResult(set, null);
// }
//
// public synchronized void addFriend(MetricElement e) {
// if(!friends.contains(e))
// friends.add(e);
// }
//
// public synchronized void removeFriend(MetricElement e) {
// if(friends.contains(e))
// friends.remove(e);
// }
//
// public synchronized void removeAllFriends() {
// friends.clear();
// }
//
// }
//
// Path: src/main/java/org/latna/msw/MetricElementFactory.java
// public interface MetricElementFactory {
// /**
// *
// * @return List of Metric elements
// */
// public List <MetricElement> getElements();
// /**
// * Distinct implementation can have many configuration which may be incompatible
// * among themselves, therefore we use String to pass configuration to the factory
// * @param param configuration string for the factory
// */
// public void setParameterString(String param);
// }
//
// Path: src/main/java/org/latna/msw/documents/Document.java
// public class Document extends MetricElement {
// private Map <String, Double> termVector;
// String id;
//
// public Document(String id) {
// super();
// termVector = new HashMap();
// this.id = id;
// }
//
// public void addTerm(String termId, double value) {
// termVector.put(termId, value);
// }
//
// @Override
// public double calcDistance(MetricElement gme) {
// double res = 0;
// if (!(gme instanceof Document)) {
// throw new Error("You are trying calculate distance for the non-Document type object");
// }
// Document otherDoc = (Document) gme;
// Document doc1;
// Document doc2;
//
// if (otherDoc.termVector.size() < this.termVector.size()) {
// doc1 = otherDoc;
// doc2 = this;
// } else {
// doc1 = this;
// doc2 = otherDoc;
// }
//
// for ( Entry <String, Double> i : doc1.termVector.entrySet()) {
// if (doc2.termVector.containsKey(i.getKey()) ) {
// res = res + i.getValue()*doc2.termVector.get(i.getKey());
// }
// }
//
// res = res / ( doc1.getVectorLenght() * doc2.getVectorLenght() );
// res = java.lang.Math.acos(res);
// return res;
// }
//
// private double getVectorLenght() {
// double res = 0;
//
// for (Double d: termVector.values())
// res = res + d*d;
//
// return Math.sqrt(res);
// }
//
// public boolean equals(Object o) {
// Document otherDocument = (Document) o ;
// return otherDocument.termVector.equals(this.termVector);
// }
//
// }
|
import org.latna.msw.MetricElement;
import org.latna.msw.MetricElementFactory;
import org.latna.msw.documents.Document;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.Scanner;
|
package org.latna.msw.wikisparse;
public class WikiSparseFactory {
public String inputFilePath="G:\\WikiData\\wikipedia.txt";
private int maxDoc;
private Scanner globalScanner = null;
public WikiSparseFactory(String inputFilePath) {
if (!inputFilePath.isEmpty())
this.inputFilePath = inputFilePath;
try {
globalScanner = new Scanner(new File(this.inputFilePath));
} catch (FileNotFoundException ex) {
System.out.println(ex);
}
}
|
// Path: src/main/java/org/latna/msw/MetricElement.java
// public abstract class MetricElement {
// private final List<MetricElement> friends;
//
// public MetricElement() {
// friends = Collections.synchronizedList(new ArrayList());
// }
//
// /**
// * Calculate metric between current object and another.
// * @param gme any element for whose metric can be calculated. Any element from domain set.
// * @return distance value
// */
// public abstract double calcDistance(MetricElement gme);
//
// public synchronized List<MetricElement> getAllFriends() {
// return friends;
// }
//
// public List<MetricElement> getAllFriendsOfAllFriends() {
// HashSet <MetricElement> hs=new HashSet();
// hs.add(this);
// for(int i=0;i<friends.size();i++){
// hs.add(friends.get(i));
// for(int j=0;j<friends.get(i).getAllFriends().size();j++)
// hs.add(friends.get(i).getAllFriends().get(j));
// }
// return new ArrayList(hs);
// }
//
// public MetricElement getClosestElemet(MetricElement q) {
// double min=this.calcDistance(q);
// int nummin=-1;
// for(int i=0;i<friends.size();i++){
// double temp=friends.get(i).calcDistance(q);
// if(temp<min){
// nummin=i;
// min=temp;
// }
//
// }
// if(nummin==-1)
// return this;
// else
// return friends.get(nummin);
// }
//
// public SearchResult getClosestElemetSearchResult(MetricElement q) {
// SearchResult s;
// TreeSet <EvaluatedElement> set = new TreeSet();
// for(int i=0;i<friends.size();i++){
// double temp=friends.get(i).calcDistance(q);
//
// set.add(new EvaluatedElement(temp, friends.get(i)));
//
// }
// return new SearchResult(set, null);
// }
//
// public synchronized void addFriend(MetricElement e) {
// if(!friends.contains(e))
// friends.add(e);
// }
//
// public synchronized void removeFriend(MetricElement e) {
// if(friends.contains(e))
// friends.remove(e);
// }
//
// public synchronized void removeAllFriends() {
// friends.clear();
// }
//
// }
//
// Path: src/main/java/org/latna/msw/MetricElementFactory.java
// public interface MetricElementFactory {
// /**
// *
// * @return List of Metric elements
// */
// public List <MetricElement> getElements();
// /**
// * Distinct implementation can have many configuration which may be incompatible
// * among themselves, therefore we use String to pass configuration to the factory
// * @param param configuration string for the factory
// */
// public void setParameterString(String param);
// }
//
// Path: src/main/java/org/latna/msw/documents/Document.java
// public class Document extends MetricElement {
// private Map <String, Double> termVector;
// String id;
//
// public Document(String id) {
// super();
// termVector = new HashMap();
// this.id = id;
// }
//
// public void addTerm(String termId, double value) {
// termVector.put(termId, value);
// }
//
// @Override
// public double calcDistance(MetricElement gme) {
// double res = 0;
// if (!(gme instanceof Document)) {
// throw new Error("You are trying calculate distance for the non-Document type object");
// }
// Document otherDoc = (Document) gme;
// Document doc1;
// Document doc2;
//
// if (otherDoc.termVector.size() < this.termVector.size()) {
// doc1 = otherDoc;
// doc2 = this;
// } else {
// doc1 = this;
// doc2 = otherDoc;
// }
//
// for ( Entry <String, Double> i : doc1.termVector.entrySet()) {
// if (doc2.termVector.containsKey(i.getKey()) ) {
// res = res + i.getValue()*doc2.termVector.get(i.getKey());
// }
// }
//
// res = res / ( doc1.getVectorLenght() * doc2.getVectorLenght() );
// res = java.lang.Math.acos(res);
// return res;
// }
//
// private double getVectorLenght() {
// double res = 0;
//
// for (Double d: termVector.values())
// res = res + d*d;
//
// return Math.sqrt(res);
// }
//
// public boolean equals(Object o) {
// Document otherDocument = (Document) o ;
// return otherDocument.termVector.equals(this.termVector);
// }
//
// }
// Path: src/main/java/org/latna/msw/wikisparse/WikiSparseFactory.java
import org.latna.msw.MetricElement;
import org.latna.msw.MetricElementFactory;
import org.latna.msw.documents.Document;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.Scanner;
package org.latna.msw.wikisparse;
public class WikiSparseFactory {
public String inputFilePath="G:\\WikiData\\wikipedia.txt";
private int maxDoc;
private Scanner globalScanner = null;
public WikiSparseFactory(String inputFilePath) {
if (!inputFilePath.isEmpty())
this.inputFilePath = inputFilePath;
try {
globalScanner = new Scanner(new File(this.inputFilePath));
} catch (FileNotFoundException ex) {
System.out.println(ex);
}
}
|
public MetricElement getElement() {
|
aponom84/MetrizedSmallWorld
|
src/main/java/org/latna/msw/TestLib.java
|
// Path: src/main/java/org/latna/msw/euclidian/EuclidianFactory.java
// public class EuclidianFactory implements MetricElementFactory, Supplier<MetricElement> {
//
// private int dimension;
// private int n; //number of elements
// private List <MetricElement> allElements;
// private static Random random = new Random();
//
// public List<MetricElement> getElements() {
// allElements = new ArrayList(n);
//
// for (int i=0; i < n; i++) {
// double x[] = new double[dimension];
// for (int j=0; j < dimension; j++) {
// x[j] = random.nextDouble();
// }
//
// allElements.add(new Euclidean(x));
// }
// return allElements;
// }
//
// public void setParameterString(String param) {
// throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
// }
//
// /*
//
// * Create factory and generate list with n uniformaly distributed elements
// * @param dimension
// * @param n - number of elements
// * @param seed - random seed
// */
// public EuclidianFactory(int dimension, int n) {
// this.dimension = dimension;
// this.n = n;
// }
//
// public static MetricElement getRandomElement(int dimension) {
// double x[] = new double[dimension];
// for (int j=0; j < dimension; j++) {
// x[j] = random.nextDouble();
// }
// return new Euclidean(x);
// }
//
// public EuclidianFactory(int dimension, int n, double standardDeviation) {
// this.dimension = dimension;
// this.n = n;
//
// RandomEngine engine = new DRand();
// Normal normal = new Normal(0, standardDeviation, engine);
//
// allElements = new ArrayList(n);
//
// for (int i=0; i < n; i++) {
// double x[] = new double[dimension];
// for (int j=0; j < dimension; j++) {
// x[j] = normal.nextDouble();
// }
//
// allElements.add(new Euclidean(x));
// }
// }
//
//
// public int getDimension() {
// return dimension;
// }
//
// @Override
// public MetricElement get() {
// double x[] = new double[dimension];
// for (int j=0; j < dimension; j++) {
// x[j] = random.nextDouble();
// }
// return new Euclidean(x);
// }
// }
|
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Random;
import java.util.Set;
import java.util.TreeSet;
import java.util.Vector;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Stream;
import org.latna.msw.euclidian.EuclidianFactory;
|
fw.append(msg);
fw.flush();
}
public static Vector <Integer> getShortestPathDistribution(List<MetricElement> allElements) {
Vector <Integer> spDistribution = new Vector <Integer> ();
//allElements.parallelStream().forEach(s->{
allElements.stream().forEach(s->{
Map <MetricElement, Integer> sp = getShortestPathValueMap(allElements, s);
//synchronized (spDistribution) {
for (Integer v: sp.values()) {
spDistribution.add(v, spDistribution.get(v) + 1);
// }
}
});
return spDistribution;
};
/*
public static Object getRandomElement(List allElements) {
if (allElements.size() == 0) return null;
return allElements.get(random.nextInt(allElements.size()));
}
*/
/**
* returns <query, List of search results>
*/
|
// Path: src/main/java/org/latna/msw/euclidian/EuclidianFactory.java
// public class EuclidianFactory implements MetricElementFactory, Supplier<MetricElement> {
//
// private int dimension;
// private int n; //number of elements
// private List <MetricElement> allElements;
// private static Random random = new Random();
//
// public List<MetricElement> getElements() {
// allElements = new ArrayList(n);
//
// for (int i=0; i < n; i++) {
// double x[] = new double[dimension];
// for (int j=0; j < dimension; j++) {
// x[j] = random.nextDouble();
// }
//
// allElements.add(new Euclidean(x));
// }
// return allElements;
// }
//
// public void setParameterString(String param) {
// throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
// }
//
// /*
//
// * Create factory and generate list with n uniformaly distributed elements
// * @param dimension
// * @param n - number of elements
// * @param seed - random seed
// */
// public EuclidianFactory(int dimension, int n) {
// this.dimension = dimension;
// this.n = n;
// }
//
// public static MetricElement getRandomElement(int dimension) {
// double x[] = new double[dimension];
// for (int j=0; j < dimension; j++) {
// x[j] = random.nextDouble();
// }
// return new Euclidean(x);
// }
//
// public EuclidianFactory(int dimension, int n, double standardDeviation) {
// this.dimension = dimension;
// this.n = n;
//
// RandomEngine engine = new DRand();
// Normal normal = new Normal(0, standardDeviation, engine);
//
// allElements = new ArrayList(n);
//
// for (int i=0; i < n; i++) {
// double x[] = new double[dimension];
// for (int j=0; j < dimension; j++) {
// x[j] = normal.nextDouble();
// }
//
// allElements.add(new Euclidean(x));
// }
// }
//
//
// public int getDimension() {
// return dimension;
// }
//
// @Override
// public MetricElement get() {
// double x[] = new double[dimension];
// for (int j=0; j < dimension; j++) {
// x[j] = random.nextDouble();
// }
// return new Euclidean(x);
// }
// }
// Path: src/main/java/org/latna/msw/TestLib.java
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Random;
import java.util.Set;
import java.util.TreeSet;
import java.util.Vector;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Stream;
import org.latna.msw.euclidian.EuclidianFactory;
fw.append(msg);
fw.flush();
}
public static Vector <Integer> getShortestPathDistribution(List<MetricElement> allElements) {
Vector <Integer> spDistribution = new Vector <Integer> ();
//allElements.parallelStream().forEach(s->{
allElements.stream().forEach(s->{
Map <MetricElement, Integer> sp = getShortestPathValueMap(allElements, s);
//synchronized (spDistribution) {
for (Integer v: sp.values()) {
spDistribution.add(v, spDistribution.get(v) + 1);
// }
}
});
return spDistribution;
};
/*
public static Object getRandomElement(List allElements) {
if (allElements.size() == 0) return null;
return allElements.get(random.nextInt(allElements.size()));
}
*/
/**
* returns <query, List of search results>
*/
|
public static Map <MetricElement, List<EvaluationResult>> evaluateSearchAlgorithm(List<MetricElement> allElements, EuclidianFactory testQueryFactory, int numberOfQueries, int numberOfTries) {
|
aponom84/MetrizedSmallWorld
|
src/main/java/org/latna/msw/SearchAttemptsTestTrec3.java
|
// Path: src/main/java/org/latna/msw/documents/DocumentFileFactory.java
// public class DocumentFileFactory implements MetricElementFactory {
// public String testDataDirPath="C:/msw/MetricSpaceLibrary/dbs/documents/short";
// private int maxDoc;
//
// @Override
// public List<MetricElement> getElements() {
// List <MetricElement> docList = new ArrayList();
// File dir = new File(testDataDirPath);
// int i = 0;
// for (File file: dir.listFiles() ) {
// if (i > maxDoc) break;
//
// Scanner sc = null;
// try {
// sc = new Scanner(file);
// Document newDoc = new Document(file.getName());
//
// while (sc.hasNext()) {
// String termId = sc.next();
// String d = sc.next();
// double value = new Double(d);
//
// newDoc.addTerm(termId, value);
// }
// docList.add(newDoc);
// } catch (FileNotFoundException ex) {
// System.out.println(ex);
// } finally {
// sc.close();
// }
// i++;
// }
// System.out.println(i+ " documents readed");
// return docList;
// }
// /**
// * DocumentFileFactory get two parameters: [dir="filePath"] - path to directory
// * which contains set of documents presented by frequence term vector and
// * [maxDoc=d+] - the restriction on the number returned documents.
// * if you want do not restrict the number of documents set maxDoc=0
// * @param param
// */
// @Override
// public void setParameterString(String param) {
// Scanner s = new Scanner(new StringReader(param));
// s.findInLine("dir=(.+); maxDoc=(\\d+)");
// MatchResult matchResult = s.match();
//
// for (int i=1; i<=matchResult.groupCount(); i++)
// System.out.println(matchResult.group(i));
//
// s.close();
//
// testDataDirPath = matchResult.group(1);
// maxDoc = Integer.valueOf(matchResult.group(2));
//
// if (maxDoc == 0) maxDoc = Integer.MAX_VALUE;
//
// }
//
// }
|
import org.latna.msw.documents.DocumentFileFactory;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.TreeSet;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
|
package org.latna.msw;
/**
* This is a simple example of building MetrizedSmallWorld over the set of
* document objects from the trec-3 collection.
* Any document or query is represented by term frequency vector.
* The test is divided into the three stages.
*
* The first stage - reading data set to the memory (documents and queries),
* configuring algorithms and building the data structure.
*
* The second stage - to obtain the true nearest neighbor element for every
* query by the use sequentially scan
*
* The third stage - a search in metric data structure with several number
* of attempts, validate the search result.
*/
public class SearchAttemptsTestTrec3 {
/**
* Scans input string and runs the test
* @param args the command line arguments
*/
public static void main(String[] args) {
/*
int nn = 7; //number of nearest neighbors used in construction algorithm to approximate voronoi neighbor
int k = 5; //number of k-closest elements for the knn search
int initAttempts = 5; //number of search attempts used during the contruction of the structure
int minAttempts = 1 ; //minimum number of attempts used during the test search
int maxAttempts = 10; //maximum number of attempts
// int dataBaseSize = 1000;
int dataBaseSize = 0; the restriction on the number of elements in the data structure. To set no restriction set value = 0
int querySetSize = 50; the restriction on the number of quleries. To set no restriction set value = 0
int testSeqSize = 30; //number elements in the random selected subset used to verify accuracy of the search.
String dataPath = "C:/msw/MetricSpaceLibrary/dbs/documents/short"; //Path to directory documents from Trec-3 collection. See Metric Space Library
String queryPath = "C:/msw/MetricSpaceLibrary/dbs/documents/shortQueries"; //Path to queries
*/
int nn = Integer.valueOf(args[0]);
int k = Integer.valueOf(args[1]);
int initAttempts = Integer.valueOf(args[2]);
int minAttempts = Integer.valueOf(args[3]);
int maxAttempts = Integer.valueOf(args[4]);
int dataBaseSize = Integer.valueOf(args[5]);
int querySetSize = Integer.valueOf(args[6]);
int testSeqSize = Integer.valueOf(args[7]);
String dataPath = args[8];
String queryPath = args[9];
System.out.println("nn=" + nn + " k=" + k + " initAttemps="+initAttempts + " minAttempts=" + minAttempts + " maxAttempts=" +
maxAttempts + " dataBaseSize=" + dataBaseSize + " querySetSize=" + querySetSize + " testSeqSize=" + testSeqSize);
|
// Path: src/main/java/org/latna/msw/documents/DocumentFileFactory.java
// public class DocumentFileFactory implements MetricElementFactory {
// public String testDataDirPath="C:/msw/MetricSpaceLibrary/dbs/documents/short";
// private int maxDoc;
//
// @Override
// public List<MetricElement> getElements() {
// List <MetricElement> docList = new ArrayList();
// File dir = new File(testDataDirPath);
// int i = 0;
// for (File file: dir.listFiles() ) {
// if (i > maxDoc) break;
//
// Scanner sc = null;
// try {
// sc = new Scanner(file);
// Document newDoc = new Document(file.getName());
//
// while (sc.hasNext()) {
// String termId = sc.next();
// String d = sc.next();
// double value = new Double(d);
//
// newDoc.addTerm(termId, value);
// }
// docList.add(newDoc);
// } catch (FileNotFoundException ex) {
// System.out.println(ex);
// } finally {
// sc.close();
// }
// i++;
// }
// System.out.println(i+ " documents readed");
// return docList;
// }
// /**
// * DocumentFileFactory get two parameters: [dir="filePath"] - path to directory
// * which contains set of documents presented by frequence term vector and
// * [maxDoc=d+] - the restriction on the number returned documents.
// * if you want do not restrict the number of documents set maxDoc=0
// * @param param
// */
// @Override
// public void setParameterString(String param) {
// Scanner s = new Scanner(new StringReader(param));
// s.findInLine("dir=(.+); maxDoc=(\\d+)");
// MatchResult matchResult = s.match();
//
// for (int i=1; i<=matchResult.groupCount(); i++)
// System.out.println(matchResult.group(i));
//
// s.close();
//
// testDataDirPath = matchResult.group(1);
// maxDoc = Integer.valueOf(matchResult.group(2));
//
// if (maxDoc == 0) maxDoc = Integer.MAX_VALUE;
//
// }
//
// }
// Path: src/main/java/org/latna/msw/SearchAttemptsTestTrec3.java
import org.latna.msw.documents.DocumentFileFactory;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.TreeSet;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
package org.latna.msw;
/**
* This is a simple example of building MetrizedSmallWorld over the set of
* document objects from the trec-3 collection.
* Any document or query is represented by term frequency vector.
* The test is divided into the three stages.
*
* The first stage - reading data set to the memory (documents and queries),
* configuring algorithms and building the data structure.
*
* The second stage - to obtain the true nearest neighbor element for every
* query by the use sequentially scan
*
* The third stage - a search in metric data structure with several number
* of attempts, validate the search result.
*/
public class SearchAttemptsTestTrec3 {
/**
* Scans input string and runs the test
* @param args the command line arguments
*/
public static void main(String[] args) {
/*
int nn = 7; //number of nearest neighbors used in construction algorithm to approximate voronoi neighbor
int k = 5; //number of k-closest elements for the knn search
int initAttempts = 5; //number of search attempts used during the contruction of the structure
int minAttempts = 1 ; //minimum number of attempts used during the test search
int maxAttempts = 10; //maximum number of attempts
// int dataBaseSize = 1000;
int dataBaseSize = 0; the restriction on the number of elements in the data structure. To set no restriction set value = 0
int querySetSize = 50; the restriction on the number of quleries. To set no restriction set value = 0
int testSeqSize = 30; //number elements in the random selected subset used to verify accuracy of the search.
String dataPath = "C:/msw/MetricSpaceLibrary/dbs/documents/short"; //Path to directory documents from Trec-3 collection. See Metric Space Library
String queryPath = "C:/msw/MetricSpaceLibrary/dbs/documents/shortQueries"; //Path to queries
*/
int nn = Integer.valueOf(args[0]);
int k = Integer.valueOf(args[1]);
int initAttempts = Integer.valueOf(args[2]);
int minAttempts = Integer.valueOf(args[3]);
int maxAttempts = Integer.valueOf(args[4]);
int dataBaseSize = Integer.valueOf(args[5]);
int querySetSize = Integer.valueOf(args[6]);
int testSeqSize = Integer.valueOf(args[7]);
String dataPath = args[8];
String queryPath = args[9];
System.out.println("nn=" + nn + " k=" + k + " initAttemps="+initAttempts + " minAttempts=" + minAttempts + " maxAttempts=" +
maxAttempts + " dataBaseSize=" + dataBaseSize + " querySetSize=" + querySetSize + " testSeqSize=" + testSeqSize);
|
MetricElementFactory elementFactory= new DocumentFileFactory();
|
aponom84/MetrizedSmallWorld
|
src/main/java/org/latna/msw/singleAttribute/SingleAttributeElementFactory.java
|
// Path: src/main/java/org/latna/msw/MetricElement.java
// public abstract class MetricElement {
// private final List<MetricElement> friends;
//
// public MetricElement() {
// friends = Collections.synchronizedList(new ArrayList());
// }
//
// /**
// * Calculate metric between current object and another.
// * @param gme any element for whose metric can be calculated. Any element from domain set.
// * @return distance value
// */
// public abstract double calcDistance(MetricElement gme);
//
// public synchronized List<MetricElement> getAllFriends() {
// return friends;
// }
//
// public List<MetricElement> getAllFriendsOfAllFriends() {
// HashSet <MetricElement> hs=new HashSet();
// hs.add(this);
// for(int i=0;i<friends.size();i++){
// hs.add(friends.get(i));
// for(int j=0;j<friends.get(i).getAllFriends().size();j++)
// hs.add(friends.get(i).getAllFriends().get(j));
// }
// return new ArrayList(hs);
// }
//
// public MetricElement getClosestElemet(MetricElement q) {
// double min=this.calcDistance(q);
// int nummin=-1;
// for(int i=0;i<friends.size();i++){
// double temp=friends.get(i).calcDistance(q);
// if(temp<min){
// nummin=i;
// min=temp;
// }
//
// }
// if(nummin==-1)
// return this;
// else
// return friends.get(nummin);
// }
//
// public SearchResult getClosestElemetSearchResult(MetricElement q) {
// SearchResult s;
// TreeSet <EvaluatedElement> set = new TreeSet();
// for(int i=0;i<friends.size();i++){
// double temp=friends.get(i).calcDistance(q);
//
// set.add(new EvaluatedElement(temp, friends.get(i)));
//
// }
// return new SearchResult(set, null);
// }
//
// public synchronized void addFriend(MetricElement e) {
// if(!friends.contains(e))
// friends.add(e);
// }
//
// public synchronized void removeFriend(MetricElement e) {
// if(friends.contains(e))
// friends.remove(e);
// }
//
// public synchronized void removeAllFriends() {
// friends.clear();
// }
//
// }
//
// Path: src/main/java/org/latna/msw/MetricElementFactory.java
// public interface MetricElementFactory {
// /**
// *
// * @return List of Metric elements
// */
// public List <MetricElement> getElements();
// /**
// * Distinct implementation can have many configuration which may be incompatible
// * among themselves, therefore we use String to pass configuration to the factory
// * @param param configuration string for the factory
// */
// public void setParameterString(String param);
// }
|
import cern.jet.random.Normal;
import cern.jet.random.engine.DRand;
import cern.jet.random.engine.RandomEngine;
import org.latna.msw.MetricElement;
import org.latna.msw.MetricElementFactory;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
|
package org.latna.msw.singleAttribute;
/**
* Factory of elements which has only one attribute.
* @author aponom
*/
public class SingleAttributeElementFactory implements MetricElementFactory {
public enum DistributionType {UNIFORM, GAUSSIAN, EXPONENTIAL, LOGNORM, POWER_LAW};
private int n; //number of elements
|
// Path: src/main/java/org/latna/msw/MetricElement.java
// public abstract class MetricElement {
// private final List<MetricElement> friends;
//
// public MetricElement() {
// friends = Collections.synchronizedList(new ArrayList());
// }
//
// /**
// * Calculate metric between current object and another.
// * @param gme any element for whose metric can be calculated. Any element from domain set.
// * @return distance value
// */
// public abstract double calcDistance(MetricElement gme);
//
// public synchronized List<MetricElement> getAllFriends() {
// return friends;
// }
//
// public List<MetricElement> getAllFriendsOfAllFriends() {
// HashSet <MetricElement> hs=new HashSet();
// hs.add(this);
// for(int i=0;i<friends.size();i++){
// hs.add(friends.get(i));
// for(int j=0;j<friends.get(i).getAllFriends().size();j++)
// hs.add(friends.get(i).getAllFriends().get(j));
// }
// return new ArrayList(hs);
// }
//
// public MetricElement getClosestElemet(MetricElement q) {
// double min=this.calcDistance(q);
// int nummin=-1;
// for(int i=0;i<friends.size();i++){
// double temp=friends.get(i).calcDistance(q);
// if(temp<min){
// nummin=i;
// min=temp;
// }
//
// }
// if(nummin==-1)
// return this;
// else
// return friends.get(nummin);
// }
//
// public SearchResult getClosestElemetSearchResult(MetricElement q) {
// SearchResult s;
// TreeSet <EvaluatedElement> set = new TreeSet();
// for(int i=0;i<friends.size();i++){
// double temp=friends.get(i).calcDistance(q);
//
// set.add(new EvaluatedElement(temp, friends.get(i)));
//
// }
// return new SearchResult(set, null);
// }
//
// public synchronized void addFriend(MetricElement e) {
// if(!friends.contains(e))
// friends.add(e);
// }
//
// public synchronized void removeFriend(MetricElement e) {
// if(friends.contains(e))
// friends.remove(e);
// }
//
// public synchronized void removeAllFriends() {
// friends.clear();
// }
//
// }
//
// Path: src/main/java/org/latna/msw/MetricElementFactory.java
// public interface MetricElementFactory {
// /**
// *
// * @return List of Metric elements
// */
// public List <MetricElement> getElements();
// /**
// * Distinct implementation can have many configuration which may be incompatible
// * among themselves, therefore we use String to pass configuration to the factory
// * @param param configuration string for the factory
// */
// public void setParameterString(String param);
// }
// Path: src/main/java/org/latna/msw/singleAttribute/SingleAttributeElementFactory.java
import cern.jet.random.Normal;
import cern.jet.random.engine.DRand;
import cern.jet.random.engine.RandomEngine;
import org.latna.msw.MetricElement;
import org.latna.msw.MetricElementFactory;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
package org.latna.msw.singleAttribute;
/**
* Factory of elements which has only one attribute.
* @author aponom
*/
public class SingleAttributeElementFactory implements MetricElementFactory {
public enum DistributionType {UNIFORM, GAUSSIAN, EXPONENTIAL, LOGNORM, POWER_LAW};
private int n; //number of elements
|
private List <MetricElement> allElements;
|
DeveloperPaul123/SimpleBluetoothLibrary
|
btutillib/src/main/java/com/devpaul/bluetoothutillib/utils/BluetoothService.java
|
// Path: btutillib/src/main/java/com/devpaul/bluetoothutillib/handlers/BluetoothHandler.java
// public class BluetoothHandler extends Handler {
// public static final int MESSAGE_READ = 121;
// public static final int MESSAGE_WAIT_FOR_CONNECTION = 143;
// public static final int MESSAGE_CONNECTION_MADE = 155;
// public static final int MESSAGE_A2DP_PROXY_RECEIVED = 157;
// public SimpleBluetoothListener mListener;
// public Activity mActivity;
// public ProgressDialog dialog;
// public boolean shouldShowSnackbars;
//
// /**
// * Bluetooth Handler class for handling messages from the bluetooth device.
// * @param listener listener for simple bluetooth.
// * @param context reference context.
// */
// public BluetoothHandler(SimpleBluetoothListener listener, Context context) {
// this.mListener = listener;
// if(context instanceof Activity) {
// this.mActivity = (Activity) context;
// }
// dialog = new ProgressDialog(context);
// }
//
// public void setShowSnackbars(boolean show) {
// this.shouldShowSnackbars = show;
// }
// }
|
import android.app.NotificationManager;
import android.app.Service;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import com.devpaul.bluetoothutillib.handlers.BluetoothHandler;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.util.UUID;
|
package com.devpaul.bluetoothutillib.utils;
/**
* Created by Paul T.
*
* Bluetooth service class so you can connect to bluetooth devices persistently in an app
* background.
*/
public class BluetoothService extends Service {
/**
* Callback for the service.
*/
public interface BluetoothServiceCallback {
public void onDeviceConnected(BluetoothDevice device);
}
/**
* Local binder
*/
private LocalBinder mLocalBinder = new LocalBinder();
/**
* Bluetooth device.
*/
private BluetoothDevice device;
/**
* BluetoothAdapter instance for the service.
*/
private BluetoothAdapter adapter;
/**
* The connect device thread for connecting to a device.
*/
private ConnectDeviceThread connectDeviceThread;
/**
* Connected thread for when handling when the device is connected.
*/
private ConnectedThread connectedThread;
/**
* Bluetooth socket holder for the created socket.
*/
private BluetoothSocket bluetoothSocket;
/**
* Instance of a callback.
*/
private BluetoothServiceCallback callback;
/**
* Notification Manager for if the service is sticky.
*/
private NotificationManager notificationManager;
/**
* Handler for bluetooth.
*/
|
// Path: btutillib/src/main/java/com/devpaul/bluetoothutillib/handlers/BluetoothHandler.java
// public class BluetoothHandler extends Handler {
// public static final int MESSAGE_READ = 121;
// public static final int MESSAGE_WAIT_FOR_CONNECTION = 143;
// public static final int MESSAGE_CONNECTION_MADE = 155;
// public static final int MESSAGE_A2DP_PROXY_RECEIVED = 157;
// public SimpleBluetoothListener mListener;
// public Activity mActivity;
// public ProgressDialog dialog;
// public boolean shouldShowSnackbars;
//
// /**
// * Bluetooth Handler class for handling messages from the bluetooth device.
// * @param listener listener for simple bluetooth.
// * @param context reference context.
// */
// public BluetoothHandler(SimpleBluetoothListener listener, Context context) {
// this.mListener = listener;
// if(context instanceof Activity) {
// this.mActivity = (Activity) context;
// }
// dialog = new ProgressDialog(context);
// }
//
// public void setShowSnackbars(boolean show) {
// this.shouldShowSnackbars = show;
// }
// }
// Path: btutillib/src/main/java/com/devpaul/bluetoothutillib/utils/BluetoothService.java
import android.app.NotificationManager;
import android.app.Service;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import com.devpaul.bluetoothutillib.handlers.BluetoothHandler;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.util.UUID;
package com.devpaul.bluetoothutillib.utils;
/**
* Created by Paul T.
*
* Bluetooth service class so you can connect to bluetooth devices persistently in an app
* background.
*/
public class BluetoothService extends Service {
/**
* Callback for the service.
*/
public interface BluetoothServiceCallback {
public void onDeviceConnected(BluetoothDevice device);
}
/**
* Local binder
*/
private LocalBinder mLocalBinder = new LocalBinder();
/**
* Bluetooth device.
*/
private BluetoothDevice device;
/**
* BluetoothAdapter instance for the service.
*/
private BluetoothAdapter adapter;
/**
* The connect device thread for connecting to a device.
*/
private ConnectDeviceThread connectDeviceThread;
/**
* Connected thread for when handling when the device is connected.
*/
private ConnectedThread connectedThread;
/**
* Bluetooth socket holder for the created socket.
*/
private BluetoothSocket bluetoothSocket;
/**
* Instance of a callback.
*/
private BluetoothServiceCallback callback;
/**
* Notification Manager for if the service is sticky.
*/
private NotificationManager notificationManager;
/**
* Handler for bluetooth.
*/
|
private BluetoothHandler bluetoothHandler;
|
DeveloperPaul123/SimpleBluetoothLibrary
|
app/src/main/java/com/devpaul/bluetoothutilitydemo/TestActivity.java
|
// Path: btutillib/src/main/java/com/devpaul/bluetoothutillib/abstracts/BaseBluetoothActivity.java
// public abstract class BaseBluetoothActivity extends Activity {
//
// /**
// * Must be overriden witha simple bluetooth listener.
// * @return a SimpleBluetoothListener. Now you don't have to override all the methods!
// */
// public abstract SimpleBluetoothListener getSimpleBluetoothListener();
//
// /**
// * The {@code SimpleBluetooth} object for this activity.
// */
// private SimpleBluetooth simpleBluetooth;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// simpleBluetooth = new SimpleBluetooth(this, getSimpleBluetoothListener());
// if(simpleBluetooth.initializeSimpleBluetooth()) {
// onBluetoothEnabled();
// }
// super.onCreate(savedInstanceState);
// }
//
// @Override
// protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// if(resultCode == RESULT_OK && requestCode == BluetoothUtility.REQUEST_BLUETOOTH) {
// onBluetoothEnabled();
// } else if(resultCode == RESULT_OK && requestCode == BluetoothUtility.REQUEST_BLUETOOTH_SCAN) {
// String macAddress = data.getStringExtra(DeviceDialog.DEVICE_DIALOG_DEVICE_ADDRESS_EXTRA);
// onDeviceSelected(macAddress);
// } else if(resultCode == RESULT_OK && requestCode == BluetoothUtility.REQUEST_MAKE_DEVICE_DISCOVERABLE) {
// // device is discoverable now.
// }
// super.onActivityResult(requestCode, resultCode, data);
// }
//
// /**
// * This is always called by the activity and indicates that bluetooth is now enabled.
// * By default the Activity will request for a scan of nearby devices.
// */
// public void onBluetoothEnabled() {
// requestScan();
// }
//
// /**
// * This method is called after you call {#requestScan} and a device is selected from the list.
// * By default, the activity will attempt to connect to the device.
// * @param macAddress, the macAddress of the selected device.
// */
// public void onDeviceSelected(String macAddress) {
// simpleBluetooth.connectToBluetoothDevice(macAddress);
// }
//
// /**
// * Sends data to the currently connected device.
// * @param data the string to send to the device.
// */
// public void sendData(String data) {
// simpleBluetooth.sendData(data);
// }
//
// /**
// * Call this to request a scan and connect to a device.
// */
// public void requestScan() {
// simpleBluetooth.scan(BluetoothUtility.REQUEST_BLUETOOTH_SCAN);
// }
//
// @Override
// protected void onDestroy() {
// super.onDestroy();
// simpleBluetooth.endSimpleBluetooth();
// }
//
// public SimpleBluetooth getSimpleBluetooth() {
// return this.simpleBluetooth;
// }
//
// }
//
// Path: btutillib/src/main/java/com/devpaul/bluetoothutillib/utils/SimpleBluetoothListener.java
// public abstract class SimpleBluetoothListener {
//
// public SimpleBluetoothListener() {
// super();
// }
//
// @Override
// protected final Object clone() throws CloneNotSupportedException {
// return super.clone();
// }
//
// @Override
// public final boolean equals(Object o) {
// return super.equals(o);
// }
//
// @Override
// protected final void finalize() throws Throwable {
// super.finalize();
// }
//
// @Override
// public final int hashCode() {
// return super.hashCode();
// }
//
// @Override
// public final String toString() {
// return super.toString();
// }
//
// /**
// * Called when bluetooth data is receieved.
// * @param bytes the raw byte buffer
// * @param data the data as a string.
// */
// public void onBluetoothDataReceived(byte[] bytes, String data) {
//
// }
//
// /**
// * Called when a device is connected.
// * @param device
// */
// public void onDeviceConnected(BluetoothDevice device) {
//
// }
//
// /**
// * Called when a device is disconnected.
// * @param device
// */
// public void onDeviceDisconnected(BluetoothDevice device) {
//
// }
//
// /**
// * Called when discovery (scanning) is started.
// */
// public void onDiscoveryStarted() {
//
// }
//
// /**
// * Called when discovery is finished.
// */
// public void onDiscoveryFinished() {
//
// }
//
// /**
// * Called when a device is paired.
// * @param device the paired device.
// */
// public void onDevicePaired(BluetoothDevice device) {
//
// }
//
// /**
// * Called when a device is unpaired.
// * @param device the unpaired device.
// */
// public void onDeviceUnpaired(BluetoothDevice device) {
//
// }
//
// /**
// * Called when a request is made to connect to an A2dp device.
// * @param bluetoothA2dp the a2dp device.
// */
// public void onBluetoothA2DPRequested(BluetoothA2dp bluetoothA2dp) {
//
// }
// }
|
import android.bluetooth.BluetoothDevice;
import android.os.Bundle;
import android.widget.Toast;
import com.devpaul.bluetoothutillib.abstracts.BaseBluetoothActivity;
import com.devpaul.bluetoothutillib.utils.SimpleBluetoothListener;
|
package com.devpaul.bluetoothutilitydemo;
/**
* Created by Pauly D on 3/18/2015.
*/
public class TestActivity extends BaseBluetoothActivity {
@Override
|
// Path: btutillib/src/main/java/com/devpaul/bluetoothutillib/abstracts/BaseBluetoothActivity.java
// public abstract class BaseBluetoothActivity extends Activity {
//
// /**
// * Must be overriden witha simple bluetooth listener.
// * @return a SimpleBluetoothListener. Now you don't have to override all the methods!
// */
// public abstract SimpleBluetoothListener getSimpleBluetoothListener();
//
// /**
// * The {@code SimpleBluetooth} object for this activity.
// */
// private SimpleBluetooth simpleBluetooth;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// simpleBluetooth = new SimpleBluetooth(this, getSimpleBluetoothListener());
// if(simpleBluetooth.initializeSimpleBluetooth()) {
// onBluetoothEnabled();
// }
// super.onCreate(savedInstanceState);
// }
//
// @Override
// protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// if(resultCode == RESULT_OK && requestCode == BluetoothUtility.REQUEST_BLUETOOTH) {
// onBluetoothEnabled();
// } else if(resultCode == RESULT_OK && requestCode == BluetoothUtility.REQUEST_BLUETOOTH_SCAN) {
// String macAddress = data.getStringExtra(DeviceDialog.DEVICE_DIALOG_DEVICE_ADDRESS_EXTRA);
// onDeviceSelected(macAddress);
// } else if(resultCode == RESULT_OK && requestCode == BluetoothUtility.REQUEST_MAKE_DEVICE_DISCOVERABLE) {
// // device is discoverable now.
// }
// super.onActivityResult(requestCode, resultCode, data);
// }
//
// /**
// * This is always called by the activity and indicates that bluetooth is now enabled.
// * By default the Activity will request for a scan of nearby devices.
// */
// public void onBluetoothEnabled() {
// requestScan();
// }
//
// /**
// * This method is called after you call {#requestScan} and a device is selected from the list.
// * By default, the activity will attempt to connect to the device.
// * @param macAddress, the macAddress of the selected device.
// */
// public void onDeviceSelected(String macAddress) {
// simpleBluetooth.connectToBluetoothDevice(macAddress);
// }
//
// /**
// * Sends data to the currently connected device.
// * @param data the string to send to the device.
// */
// public void sendData(String data) {
// simpleBluetooth.sendData(data);
// }
//
// /**
// * Call this to request a scan and connect to a device.
// */
// public void requestScan() {
// simpleBluetooth.scan(BluetoothUtility.REQUEST_BLUETOOTH_SCAN);
// }
//
// @Override
// protected void onDestroy() {
// super.onDestroy();
// simpleBluetooth.endSimpleBluetooth();
// }
//
// public SimpleBluetooth getSimpleBluetooth() {
// return this.simpleBluetooth;
// }
//
// }
//
// Path: btutillib/src/main/java/com/devpaul/bluetoothutillib/utils/SimpleBluetoothListener.java
// public abstract class SimpleBluetoothListener {
//
// public SimpleBluetoothListener() {
// super();
// }
//
// @Override
// protected final Object clone() throws CloneNotSupportedException {
// return super.clone();
// }
//
// @Override
// public final boolean equals(Object o) {
// return super.equals(o);
// }
//
// @Override
// protected final void finalize() throws Throwable {
// super.finalize();
// }
//
// @Override
// public final int hashCode() {
// return super.hashCode();
// }
//
// @Override
// public final String toString() {
// return super.toString();
// }
//
// /**
// * Called when bluetooth data is receieved.
// * @param bytes the raw byte buffer
// * @param data the data as a string.
// */
// public void onBluetoothDataReceived(byte[] bytes, String data) {
//
// }
//
// /**
// * Called when a device is connected.
// * @param device
// */
// public void onDeviceConnected(BluetoothDevice device) {
//
// }
//
// /**
// * Called when a device is disconnected.
// * @param device
// */
// public void onDeviceDisconnected(BluetoothDevice device) {
//
// }
//
// /**
// * Called when discovery (scanning) is started.
// */
// public void onDiscoveryStarted() {
//
// }
//
// /**
// * Called when discovery is finished.
// */
// public void onDiscoveryFinished() {
//
// }
//
// /**
// * Called when a device is paired.
// * @param device the paired device.
// */
// public void onDevicePaired(BluetoothDevice device) {
//
// }
//
// /**
// * Called when a device is unpaired.
// * @param device the unpaired device.
// */
// public void onDeviceUnpaired(BluetoothDevice device) {
//
// }
//
// /**
// * Called when a request is made to connect to an A2dp device.
// * @param bluetoothA2dp the a2dp device.
// */
// public void onBluetoothA2DPRequested(BluetoothA2dp bluetoothA2dp) {
//
// }
// }
// Path: app/src/main/java/com/devpaul/bluetoothutilitydemo/TestActivity.java
import android.bluetooth.BluetoothDevice;
import android.os.Bundle;
import android.widget.Toast;
import com.devpaul.bluetoothutillib.abstracts.BaseBluetoothActivity;
import com.devpaul.bluetoothutillib.utils.SimpleBluetoothListener;
package com.devpaul.bluetoothutilitydemo;
/**
* Created by Pauly D on 3/18/2015.
*/
public class TestActivity extends BaseBluetoothActivity {
@Override
|
public SimpleBluetoothListener getSimpleBluetoothListener() {
|
DeveloperPaul123/SimpleBluetoothLibrary
|
btutillib/src/main/java/com/devpaul/bluetoothutillib/handlers/BluetoothHandler.java
|
// Path: btutillib/src/main/java/com/devpaul/bluetoothutillib/utils/SimpleBluetoothListener.java
// public abstract class SimpleBluetoothListener {
//
// public SimpleBluetoothListener() {
// super();
// }
//
// @Override
// protected final Object clone() throws CloneNotSupportedException {
// return super.clone();
// }
//
// @Override
// public final boolean equals(Object o) {
// return super.equals(o);
// }
//
// @Override
// protected final void finalize() throws Throwable {
// super.finalize();
// }
//
// @Override
// public final int hashCode() {
// return super.hashCode();
// }
//
// @Override
// public final String toString() {
// return super.toString();
// }
//
// /**
// * Called when bluetooth data is receieved.
// * @param bytes the raw byte buffer
// * @param data the data as a string.
// */
// public void onBluetoothDataReceived(byte[] bytes, String data) {
//
// }
//
// /**
// * Called when a device is connected.
// * @param device
// */
// public void onDeviceConnected(BluetoothDevice device) {
//
// }
//
// /**
// * Called when a device is disconnected.
// * @param device
// */
// public void onDeviceDisconnected(BluetoothDevice device) {
//
// }
//
// /**
// * Called when discovery (scanning) is started.
// */
// public void onDiscoveryStarted() {
//
// }
//
// /**
// * Called when discovery is finished.
// */
// public void onDiscoveryFinished() {
//
// }
//
// /**
// * Called when a device is paired.
// * @param device the paired device.
// */
// public void onDevicePaired(BluetoothDevice device) {
//
// }
//
// /**
// * Called when a device is unpaired.
// * @param device the unpaired device.
// */
// public void onDeviceUnpaired(BluetoothDevice device) {
//
// }
//
// /**
// * Called when a request is made to connect to an A2dp device.
// * @param bluetoothA2dp the a2dp device.
// */
// public void onBluetoothA2DPRequested(BluetoothA2dp bluetoothA2dp) {
//
// }
// }
|
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.os.Handler;
import com.devpaul.bluetoothutillib.utils.SimpleBluetoothListener;
|
package com.devpaul.bluetoothutillib.handlers;
/**
* Created by Paul Tsouchlos
* A handler for receiving messages from the bluetooth device.
*/
public class BluetoothHandler extends Handler {
public static final int MESSAGE_READ = 121;
public static final int MESSAGE_WAIT_FOR_CONNECTION = 143;
public static final int MESSAGE_CONNECTION_MADE = 155;
public static final int MESSAGE_A2DP_PROXY_RECEIVED = 157;
|
// Path: btutillib/src/main/java/com/devpaul/bluetoothutillib/utils/SimpleBluetoothListener.java
// public abstract class SimpleBluetoothListener {
//
// public SimpleBluetoothListener() {
// super();
// }
//
// @Override
// protected final Object clone() throws CloneNotSupportedException {
// return super.clone();
// }
//
// @Override
// public final boolean equals(Object o) {
// return super.equals(o);
// }
//
// @Override
// protected final void finalize() throws Throwable {
// super.finalize();
// }
//
// @Override
// public final int hashCode() {
// return super.hashCode();
// }
//
// @Override
// public final String toString() {
// return super.toString();
// }
//
// /**
// * Called when bluetooth data is receieved.
// * @param bytes the raw byte buffer
// * @param data the data as a string.
// */
// public void onBluetoothDataReceived(byte[] bytes, String data) {
//
// }
//
// /**
// * Called when a device is connected.
// * @param device
// */
// public void onDeviceConnected(BluetoothDevice device) {
//
// }
//
// /**
// * Called when a device is disconnected.
// * @param device
// */
// public void onDeviceDisconnected(BluetoothDevice device) {
//
// }
//
// /**
// * Called when discovery (scanning) is started.
// */
// public void onDiscoveryStarted() {
//
// }
//
// /**
// * Called when discovery is finished.
// */
// public void onDiscoveryFinished() {
//
// }
//
// /**
// * Called when a device is paired.
// * @param device the paired device.
// */
// public void onDevicePaired(BluetoothDevice device) {
//
// }
//
// /**
// * Called when a device is unpaired.
// * @param device the unpaired device.
// */
// public void onDeviceUnpaired(BluetoothDevice device) {
//
// }
//
// /**
// * Called when a request is made to connect to an A2dp device.
// * @param bluetoothA2dp the a2dp device.
// */
// public void onBluetoothA2DPRequested(BluetoothA2dp bluetoothA2dp) {
//
// }
// }
// Path: btutillib/src/main/java/com/devpaul/bluetoothutillib/handlers/BluetoothHandler.java
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.os.Handler;
import com.devpaul.bluetoothutillib.utils.SimpleBluetoothListener;
package com.devpaul.bluetoothutillib.handlers;
/**
* Created by Paul Tsouchlos
* A handler for receiving messages from the bluetooth device.
*/
public class BluetoothHandler extends Handler {
public static final int MESSAGE_READ = 121;
public static final int MESSAGE_WAIT_FOR_CONNECTION = 143;
public static final int MESSAGE_CONNECTION_MADE = 155;
public static final int MESSAGE_A2DP_PROXY_RECEIVED = 157;
|
public SimpleBluetoothListener mListener;
|
DeveloperPaul123/SimpleBluetoothLibrary
|
btutillib/src/main/java/com/devpaul/bluetoothutillib/utils/BluetoothUtility.java
|
// Path: btutillib/src/main/java/com/devpaul/bluetoothutillib/handlers/BluetoothHandler.java
// public class BluetoothHandler extends Handler {
// public static final int MESSAGE_READ = 121;
// public static final int MESSAGE_WAIT_FOR_CONNECTION = 143;
// public static final int MESSAGE_CONNECTION_MADE = 155;
// public static final int MESSAGE_A2DP_PROXY_RECEIVED = 157;
// public SimpleBluetoothListener mListener;
// public Activity mActivity;
// public ProgressDialog dialog;
// public boolean shouldShowSnackbars;
//
// /**
// * Bluetooth Handler class for handling messages from the bluetooth device.
// * @param listener listener for simple bluetooth.
// * @param context reference context.
// */
// public BluetoothHandler(SimpleBluetoothListener listener, Context context) {
// this.mListener = listener;
// if(context instanceof Activity) {
// this.mActivity = (Activity) context;
// }
// dialog = new ProgressDialog(context);
// }
//
// public void setShowSnackbars(boolean show) {
// this.shouldShowSnackbars = show;
// }
// }
|
import android.app.Activity;
import android.bluetooth.BluetoothA2dp;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothProfile;
import android.bluetooth.BluetoothServerSocket;
import android.bluetooth.BluetoothSocket;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.support.design.widget.Snackbar;
import android.util.Log;
import com.devpaul.bluetoothutillib.errordialogs.InvalidMacAddressDialog;
import com.devpaul.bluetoothutillib.handlers.BluetoothHandler;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Set;
import java.util.UUID;
|
package com.devpaul.bluetoothutillib.utils;
/**
* Created by Paul Tsouchlos
* Class that handles all bluetooth adapter stuff and connecting to devices, establishing sockets
* listening for connections and reading/writing data on the sockets.
*/
public class BluetoothUtility implements BluetoothProfile.ServiceListener {
/**
* Debug tag
*/
private static final String TAG = "BluetoothUtility";
/**
* {@code BluetoothAdapter} that handles bluetooth methods.
*/
private BluetoothAdapter bluetoothAdapter;
/**
* Context field.
*/
private Context mContext;
/**
* Current {@code BluetoothSocket}
*/
private BluetoothSocket bluetoothSocket;
/**
* Current {@code BluetoothDevice}
*/
private BluetoothDevice bluetoothDevice;
/**
* {@code UUID} for a normal device connection.
*/
private static final UUID NORMAL_UUID = UUID.fromString("00001101-0000-1000-8000-00805f9b34fb");
/**
* {@code UUID} for a server device connection.
*/
private static final UUID SERVER_UUID = UUID.fromString("03107005-0000-4000-8000-00805F9B34FB");
/**
* Name of the bluetooth server.
*/
private static final String SERVER_NAME = "bluetoothServer";
/*
Threads that handle all the connections and accepting of connections and what happens after
you're connected.
*/
/**
* {@code Thread} that handles a connected socket.
*/
private ConnectedThread connectedThread;
/**
* {@code Thread} that handles connecting to a device.
*/
private ConnectDeviceThread connectThread;
/**
* {@code Thread} that listens for an incoming connection.
*/
private AcceptThread acceptThread;
/**
* {@code Thread} that connects a device to an already set up bluetooth server.
*/
private ConnectDeviceToServerThread connectToServerThread;
/**
* {@code BluetoothHandler} that handles all the calls for a reading incoming data and other
* messages.
*/
|
// Path: btutillib/src/main/java/com/devpaul/bluetoothutillib/handlers/BluetoothHandler.java
// public class BluetoothHandler extends Handler {
// public static final int MESSAGE_READ = 121;
// public static final int MESSAGE_WAIT_FOR_CONNECTION = 143;
// public static final int MESSAGE_CONNECTION_MADE = 155;
// public static final int MESSAGE_A2DP_PROXY_RECEIVED = 157;
// public SimpleBluetoothListener mListener;
// public Activity mActivity;
// public ProgressDialog dialog;
// public boolean shouldShowSnackbars;
//
// /**
// * Bluetooth Handler class for handling messages from the bluetooth device.
// * @param listener listener for simple bluetooth.
// * @param context reference context.
// */
// public BluetoothHandler(SimpleBluetoothListener listener, Context context) {
// this.mListener = listener;
// if(context instanceof Activity) {
// this.mActivity = (Activity) context;
// }
// dialog = new ProgressDialog(context);
// }
//
// public void setShowSnackbars(boolean show) {
// this.shouldShowSnackbars = show;
// }
// }
// Path: btutillib/src/main/java/com/devpaul/bluetoothutillib/utils/BluetoothUtility.java
import android.app.Activity;
import android.bluetooth.BluetoothA2dp;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothProfile;
import android.bluetooth.BluetoothServerSocket;
import android.bluetooth.BluetoothSocket;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.support.design.widget.Snackbar;
import android.util.Log;
import com.devpaul.bluetoothutillib.errordialogs.InvalidMacAddressDialog;
import com.devpaul.bluetoothutillib.handlers.BluetoothHandler;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Set;
import java.util.UUID;
package com.devpaul.bluetoothutillib.utils;
/**
* Created by Paul Tsouchlos
* Class that handles all bluetooth adapter stuff and connecting to devices, establishing sockets
* listening for connections and reading/writing data on the sockets.
*/
public class BluetoothUtility implements BluetoothProfile.ServiceListener {
/**
* Debug tag
*/
private static final String TAG = "BluetoothUtility";
/**
* {@code BluetoothAdapter} that handles bluetooth methods.
*/
private BluetoothAdapter bluetoothAdapter;
/**
* Context field.
*/
private Context mContext;
/**
* Current {@code BluetoothSocket}
*/
private BluetoothSocket bluetoothSocket;
/**
* Current {@code BluetoothDevice}
*/
private BluetoothDevice bluetoothDevice;
/**
* {@code UUID} for a normal device connection.
*/
private static final UUID NORMAL_UUID = UUID.fromString("00001101-0000-1000-8000-00805f9b34fb");
/**
* {@code UUID} for a server device connection.
*/
private static final UUID SERVER_UUID = UUID.fromString("03107005-0000-4000-8000-00805F9B34FB");
/**
* Name of the bluetooth server.
*/
private static final String SERVER_NAME = "bluetoothServer";
/*
Threads that handle all the connections and accepting of connections and what happens after
you're connected.
*/
/**
* {@code Thread} that handles a connected socket.
*/
private ConnectedThread connectedThread;
/**
* {@code Thread} that handles connecting to a device.
*/
private ConnectDeviceThread connectThread;
/**
* {@code Thread} that listens for an incoming connection.
*/
private AcceptThread acceptThread;
/**
* {@code Thread} that connects a device to an already set up bluetooth server.
*/
private ConnectDeviceToServerThread connectToServerThread;
/**
* {@code BluetoothHandler} that handles all the calls for a reading incoming data and other
* messages.
*/
|
private BluetoothHandler bluetoothHandler;
|
krisjey/netty.book.kor
|
api-server/src/main/java/com/github/nettybook/ch9/service/UserInfo.java
|
// Path: api-server/src/main/java/com/github/nettybook/ch9/core/ApiRequestTemplate.java
// public abstract class ApiRequestTemplate implements ApiRequest {
// protected Logger logger;
//
// /**
// * API 요청 data
// */
// protected Map<String, String> reqData;
//
// /**
// * API 처리결과
// */
// protected JsonObject apiResult;
//
// /**
// * logger 생성<br/>
// * apiResult 객체 생성
// */
// public ApiRequestTemplate(Map<String, String> reqData) {
// this.logger = LogManager.getLogger(this.getClass());
// this.apiResult = new JsonObject();
// this.reqData = reqData;
//
// logger.info("request data : " + this.reqData);
// }
//
// public void executeService() {
// try {
// this.requestParamValidation();
//
// this.service();
// }
// catch (RequestParamException e) {
// logger.error(e);
// this.apiResult.addProperty("resultCode", "405");
// }
// catch (ServiceException e) {
// logger.error(e);
// this.apiResult.addProperty("resultCode", "501");
// }
// }
//
// public JsonObject getApiResult() {
// return this.apiResult;
// }
//
// @Override
// public void requestParamValidation() throws RequestParamException {
// if (getClass().getClasses().length == 0) {
// return;
// }
//
// // // TODO 이건 꼼수 바꿔야 하는데..
// // for (Object item :
// // this.getClass().getClasses()[0].getEnumConstants()) {
// // RequestParam param = (RequestParam) item;
// // if (param.isMandatory() && this.reqData.get(param.toString()) ==
// // null) {
// // throw new RequestParamException(item.toString() +
// // " is not present in request param.");
// // }
// // }
// }
//
// public final <T extends Enum<T>> T fromValue(Class<T> paramClass, String paramValue) {
// if (paramValue == null || paramClass == null) {
// throw new IllegalArgumentException("There is no value with name '" + paramValue + " in Enum "
// + paramClass.getClass().getName());
// }
//
// for (T param : paramClass.getEnumConstants()) {
// if (paramValue.equals(param.toString())) {
// return param;
// }
// }
//
// throw new IllegalArgumentException("There is no value with name '" + paramValue + " in Enum "
// + paramClass.getClass().getName());
// }
// }
//
// Path: api-server/src/main/java/com/github/nettybook/ch9/core/KeyMaker.java
// public interface KeyMaker {
// /**
// * 키 생성기로부터 만들어진 키를 가져온다.
// * @return 만들어진 키
// */
// public String getKey();
// }
//
// Path: api-server/src/main/java/com/github/nettybook/ch9/service/dao/TokenKey.java
// public class TokenKey implements KeyMaker {
// static final int SEED_MURMURHASH = 0x1234ABCD;
//
// private String email;
// private long issueDate;
//
// /**
// * 키 메이커 클래스를 위한 생성자.
// *
// * @param email
// * 키 생성을 위한 인덱스 값
// * @param issueDate
// */
// public TokenKey(String email, long issueDate) {
// this.email = email;
// this.issueDate = issueDate;
// }
//
// /*
// * (non-Javadoc)
// *
// * @see net.sf.redisbook.ch7.redislogger.KeyMaker#getKey()
// */
// @Override
// public String getKey() {
// String source = email + String.valueOf(issueDate);
//
// return Long.toString(MurmurHash.hash64A(source.getBytes(), SEED_MURMURHASH), 16);
// }
// }
|
import java.util.Map;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import redis.clients.jedis.Jedis;
import com.github.nettybook.ch9.core.ApiRequestTemplate;
import com.github.nettybook.ch9.core.KeyMaker;
import com.github.nettybook.ch9.service.dao.TokenKey;
import com.google.gson.JsonObject;
|
package com.github.nettybook.ch9.service;
@Service("users")
@Scope("prototype")
|
// Path: api-server/src/main/java/com/github/nettybook/ch9/core/ApiRequestTemplate.java
// public abstract class ApiRequestTemplate implements ApiRequest {
// protected Logger logger;
//
// /**
// * API 요청 data
// */
// protected Map<String, String> reqData;
//
// /**
// * API 처리결과
// */
// protected JsonObject apiResult;
//
// /**
// * logger 생성<br/>
// * apiResult 객체 생성
// */
// public ApiRequestTemplate(Map<String, String> reqData) {
// this.logger = LogManager.getLogger(this.getClass());
// this.apiResult = new JsonObject();
// this.reqData = reqData;
//
// logger.info("request data : " + this.reqData);
// }
//
// public void executeService() {
// try {
// this.requestParamValidation();
//
// this.service();
// }
// catch (RequestParamException e) {
// logger.error(e);
// this.apiResult.addProperty("resultCode", "405");
// }
// catch (ServiceException e) {
// logger.error(e);
// this.apiResult.addProperty("resultCode", "501");
// }
// }
//
// public JsonObject getApiResult() {
// return this.apiResult;
// }
//
// @Override
// public void requestParamValidation() throws RequestParamException {
// if (getClass().getClasses().length == 0) {
// return;
// }
//
// // // TODO 이건 꼼수 바꿔야 하는데..
// // for (Object item :
// // this.getClass().getClasses()[0].getEnumConstants()) {
// // RequestParam param = (RequestParam) item;
// // if (param.isMandatory() && this.reqData.get(param.toString()) ==
// // null) {
// // throw new RequestParamException(item.toString() +
// // " is not present in request param.");
// // }
// // }
// }
//
// public final <T extends Enum<T>> T fromValue(Class<T> paramClass, String paramValue) {
// if (paramValue == null || paramClass == null) {
// throw new IllegalArgumentException("There is no value with name '" + paramValue + " in Enum "
// + paramClass.getClass().getName());
// }
//
// for (T param : paramClass.getEnumConstants()) {
// if (paramValue.equals(param.toString())) {
// return param;
// }
// }
//
// throw new IllegalArgumentException("There is no value with name '" + paramValue + " in Enum "
// + paramClass.getClass().getName());
// }
// }
//
// Path: api-server/src/main/java/com/github/nettybook/ch9/core/KeyMaker.java
// public interface KeyMaker {
// /**
// * 키 생성기로부터 만들어진 키를 가져온다.
// * @return 만들어진 키
// */
// public String getKey();
// }
//
// Path: api-server/src/main/java/com/github/nettybook/ch9/service/dao/TokenKey.java
// public class TokenKey implements KeyMaker {
// static final int SEED_MURMURHASH = 0x1234ABCD;
//
// private String email;
// private long issueDate;
//
// /**
// * 키 메이커 클래스를 위한 생성자.
// *
// * @param email
// * 키 생성을 위한 인덱스 값
// * @param issueDate
// */
// public TokenKey(String email, long issueDate) {
// this.email = email;
// this.issueDate = issueDate;
// }
//
// /*
// * (non-Javadoc)
// *
// * @see net.sf.redisbook.ch7.redislogger.KeyMaker#getKey()
// */
// @Override
// public String getKey() {
// String source = email + String.valueOf(issueDate);
//
// return Long.toString(MurmurHash.hash64A(source.getBytes(), SEED_MURMURHASH), 16);
// }
// }
// Path: api-server/src/main/java/com/github/nettybook/ch9/service/UserInfo.java
import java.util.Map;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import redis.clients.jedis.Jedis;
import com.github.nettybook.ch9.core.ApiRequestTemplate;
import com.github.nettybook.ch9.core.KeyMaker;
import com.github.nettybook.ch9.service.dao.TokenKey;
import com.google.gson.JsonObject;
package com.github.nettybook.ch9.service;
@Service("users")
@Scope("prototype")
|
public class UserInfo extends ApiRequestTemplate {
|
krisjey/netty.book.kor
|
api-server/src/main/java/com/github/nettybook/ch9/core/ApiRequestTemplate.java
|
// Path: api-server/src/main/java/com/github/nettybook/ch9/service/RequestParamException.java
// public class RequestParamException extends Exception {
// private static final long serialVersionUID = -1583203227626153961L;
//
// /**
// * Constructs a new Request param exception with {@code null} as its detail
// * message. The cause is not initialized, and may subsequently be
// * initialized by a call to {@link #initCause}.
// */
// public RequestParamException() {
// super();
// }
//
// /**
// * Constructs a new Request param exception with the specified detail
// * message. The cause is not initialized, and may subsequently be
// * initialized by a call to {@link #initCause}.
// *
// * @param message
// * the detail message. The detail message is saved for later
// * retrieval by the {@link #getMessage()} method.
// */
// public RequestParamException(String message) {
// super(message);
// }
//
// /**
// * Constructs a new Request param exception with the specified detail
// * message and cause.
// * <p>
// * Note that the detail message associated with {@code cause} is <i>not</i>
// * automatically incorporated in this Request param exception's detail
// * message.
// *
// * @param message
// * the detail message (which is saved for later retrieval by the
// * {@link #getMessage()} method).
// * @param cause
// * the cause (which is saved for later retrieval by the
// * {@link #getCause()} method). (A <tt>null</tt> value is
// * permitted, and indicates that the cause is nonexistent or
// * unknown.)
// */
// public RequestParamException(String message, Throwable cause) {
// super(message, cause);
// }
//
// /**
// * Constructs a new Request param exception with the specified cause and a
// * detail message of <tt>(cause==null ? null : cause.toString())</tt> (which
// * typically contains the class and detail message of <tt>cause</tt>). This
// * constructor is useful for Request param exceptions that are little more
// * than wrappers for other throwables.
// *
// * @param cause
// * the cause (which is saved for later retrieval by the
// * {@link #getCause()} method). (A <tt>null</tt> value is
// * permitted, and indicates that the cause is nonexistent or
// * unknown.)
// */
// public RequestParamException(Throwable cause) {
// super(cause);
// }
//
// /**
// * Constructs a new Request param exception with the specified detail
// * message, cause, suppression enabled or disabled, and writable stack trace
// * enabled or disabled.
// *
// * @param message
// * the detail message.
// * @param cause
// * the cause. (A {@code null} value is permitted, and indicates
// * that the cause is nonexistent or unknown.)
// * @param enableSuppression
// * whether or not suppression is enabled or disabled
// * @param writableStackTrace
// * whether or not the stack trace should be writable
// */
// protected RequestParamException(String message, Throwable cause, boolean enableSuppression,
// boolean writableStackTrace) {
// super(message, cause, enableSuppression, writableStackTrace);
// }
// }
|
import java.util.Map;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.github.nettybook.ch9.service.RequestParamException;
import com.github.nettybook.ch9.service.ServiceException;
import com.google.gson.JsonObject;
|
package com.github.nettybook.ch9.core;
public abstract class ApiRequestTemplate implements ApiRequest {
protected Logger logger;
/**
* API 요청 data
*/
protected Map<String, String> reqData;
/**
* API 처리결과
*/
protected JsonObject apiResult;
/**
* logger 생성<br/>
* apiResult 객체 생성
*/
public ApiRequestTemplate(Map<String, String> reqData) {
this.logger = LogManager.getLogger(this.getClass());
this.apiResult = new JsonObject();
this.reqData = reqData;
logger.info("request data : " + this.reqData);
}
public void executeService() {
try {
this.requestParamValidation();
this.service();
}
|
// Path: api-server/src/main/java/com/github/nettybook/ch9/service/RequestParamException.java
// public class RequestParamException extends Exception {
// private static final long serialVersionUID = -1583203227626153961L;
//
// /**
// * Constructs a new Request param exception with {@code null} as its detail
// * message. The cause is not initialized, and may subsequently be
// * initialized by a call to {@link #initCause}.
// */
// public RequestParamException() {
// super();
// }
//
// /**
// * Constructs a new Request param exception with the specified detail
// * message. The cause is not initialized, and may subsequently be
// * initialized by a call to {@link #initCause}.
// *
// * @param message
// * the detail message. The detail message is saved for later
// * retrieval by the {@link #getMessage()} method.
// */
// public RequestParamException(String message) {
// super(message);
// }
//
// /**
// * Constructs a new Request param exception with the specified detail
// * message and cause.
// * <p>
// * Note that the detail message associated with {@code cause} is <i>not</i>
// * automatically incorporated in this Request param exception's detail
// * message.
// *
// * @param message
// * the detail message (which is saved for later retrieval by the
// * {@link #getMessage()} method).
// * @param cause
// * the cause (which is saved for later retrieval by the
// * {@link #getCause()} method). (A <tt>null</tt> value is
// * permitted, and indicates that the cause is nonexistent or
// * unknown.)
// */
// public RequestParamException(String message, Throwable cause) {
// super(message, cause);
// }
//
// /**
// * Constructs a new Request param exception with the specified cause and a
// * detail message of <tt>(cause==null ? null : cause.toString())</tt> (which
// * typically contains the class and detail message of <tt>cause</tt>). This
// * constructor is useful for Request param exceptions that are little more
// * than wrappers for other throwables.
// *
// * @param cause
// * the cause (which is saved for later retrieval by the
// * {@link #getCause()} method). (A <tt>null</tt> value is
// * permitted, and indicates that the cause is nonexistent or
// * unknown.)
// */
// public RequestParamException(Throwable cause) {
// super(cause);
// }
//
// /**
// * Constructs a new Request param exception with the specified detail
// * message, cause, suppression enabled or disabled, and writable stack trace
// * enabled or disabled.
// *
// * @param message
// * the detail message.
// * @param cause
// * the cause. (A {@code null} value is permitted, and indicates
// * that the cause is nonexistent or unknown.)
// * @param enableSuppression
// * whether or not suppression is enabled or disabled
// * @param writableStackTrace
// * whether or not the stack trace should be writable
// */
// protected RequestParamException(String message, Throwable cause, boolean enableSuppression,
// boolean writableStackTrace) {
// super(message, cause, enableSuppression, writableStackTrace);
// }
// }
// Path: api-server/src/main/java/com/github/nettybook/ch9/core/ApiRequestTemplate.java
import java.util.Map;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.github.nettybook.ch9.service.RequestParamException;
import com.github.nettybook.ch9.service.ServiceException;
import com.google.gson.JsonObject;
package com.github.nettybook.ch9.core;
public abstract class ApiRequestTemplate implements ApiRequest {
protected Logger logger;
/**
* API 요청 data
*/
protected Map<String, String> reqData;
/**
* API 처리결과
*/
protected JsonObject apiResult;
/**
* logger 생성<br/>
* apiResult 객체 생성
*/
public ApiRequestTemplate(Map<String, String> reqData) {
this.logger = LogManager.getLogger(this.getClass());
this.apiResult = new JsonObject();
this.reqData = reqData;
logger.info("request data : " + this.reqData);
}
public void executeService() {
try {
this.requestParamValidation();
this.service();
}
|
catch (RequestParamException e) {
|
javyuan/jeesite-api
|
src/main/java/com/zlwh/hands/admin/modules/basis/service/CTelsmsService.java
|
// Path: src/main/java/com/zlwh/hands/admin/modules/basis/dao/CTelsmsDao.java
// @MyBatisDao
// public interface CTelsmsDao extends CrudDao<CTelsms> {
//
// }
//
// Path: src/main/java/com/zlwh/hands/admin/modules/basis/entity/CTelsms.java
// public class CTelsms extends DataEntity<CTelsms> {
//
// private static final long serialVersionUID = 1L;
// private String phone; // phone
// private String type; // 0:注册1:找回密码
// private String code; // code
// private String userId; // user_id
//
// public CTelsms() {
// super();
// }
//
// public CTelsms(String id){
// super(id);
// }
//
// @Length(min=0, max=15, message="phone长度必须介于 0 和 15 之间")
// public String getPhone() {
// return phone;
// }
//
// public void setPhone(String phone) {
// this.phone = phone;
// }
//
// @Length(min=0, max=1, message="0:注册1:找回密码长度必须介于 0 和 1 之间")
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// @Length(min=0, max=10, message="code长度必须介于 0 和 10 之间")
// public String getCode() {
// return code;
// }
//
// public void setCode(String code) {
// this.code = code;
// }
//
// public String getUserId() {
// return userId;
// }
//
// public void setUserId(String userId) {
// this.userId = userId;
// }
//
// }
|
import java.util.List;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.service.CrudService;
import com.thinkgem.jeesite.common.utils.StringUtils;
import com.zlwh.hands.admin.modules.basis.dao.CTelsmsDao;
import com.zlwh.hands.admin.modules.basis.entity.CTelsms;
|
/**
* Copyright © 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
*/
package com.zlwh.hands.admin.modules.basis.service;
/**
* 短信验证码Service
* @author yuanjifeng
* @version 2016-07-15
*/
@Service
@Transactional(readOnly = true)
|
// Path: src/main/java/com/zlwh/hands/admin/modules/basis/dao/CTelsmsDao.java
// @MyBatisDao
// public interface CTelsmsDao extends CrudDao<CTelsms> {
//
// }
//
// Path: src/main/java/com/zlwh/hands/admin/modules/basis/entity/CTelsms.java
// public class CTelsms extends DataEntity<CTelsms> {
//
// private static final long serialVersionUID = 1L;
// private String phone; // phone
// private String type; // 0:注册1:找回密码
// private String code; // code
// private String userId; // user_id
//
// public CTelsms() {
// super();
// }
//
// public CTelsms(String id){
// super(id);
// }
//
// @Length(min=0, max=15, message="phone长度必须介于 0 和 15 之间")
// public String getPhone() {
// return phone;
// }
//
// public void setPhone(String phone) {
// this.phone = phone;
// }
//
// @Length(min=0, max=1, message="0:注册1:找回密码长度必须介于 0 和 1 之间")
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// @Length(min=0, max=10, message="code长度必须介于 0 和 10 之间")
// public String getCode() {
// return code;
// }
//
// public void setCode(String code) {
// this.code = code;
// }
//
// public String getUserId() {
// return userId;
// }
//
// public void setUserId(String userId) {
// this.userId = userId;
// }
//
// }
// Path: src/main/java/com/zlwh/hands/admin/modules/basis/service/CTelsmsService.java
import java.util.List;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.service.CrudService;
import com.thinkgem.jeesite.common.utils.StringUtils;
import com.zlwh.hands.admin.modules.basis.dao.CTelsmsDao;
import com.zlwh.hands.admin.modules.basis.entity.CTelsms;
/**
* Copyright © 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
*/
package com.zlwh.hands.admin.modules.basis.service;
/**
* 短信验证码Service
* @author yuanjifeng
* @version 2016-07-15
*/
@Service
@Transactional(readOnly = true)
|
public class CTelsmsService extends CrudService<CTelsmsDao, CTelsms> {
|
javyuan/jeesite-api
|
src/main/java/com/zlwh/hands/admin/modules/basis/service/CTelsmsService.java
|
// Path: src/main/java/com/zlwh/hands/admin/modules/basis/dao/CTelsmsDao.java
// @MyBatisDao
// public interface CTelsmsDao extends CrudDao<CTelsms> {
//
// }
//
// Path: src/main/java/com/zlwh/hands/admin/modules/basis/entity/CTelsms.java
// public class CTelsms extends DataEntity<CTelsms> {
//
// private static final long serialVersionUID = 1L;
// private String phone; // phone
// private String type; // 0:注册1:找回密码
// private String code; // code
// private String userId; // user_id
//
// public CTelsms() {
// super();
// }
//
// public CTelsms(String id){
// super(id);
// }
//
// @Length(min=0, max=15, message="phone长度必须介于 0 和 15 之间")
// public String getPhone() {
// return phone;
// }
//
// public void setPhone(String phone) {
// this.phone = phone;
// }
//
// @Length(min=0, max=1, message="0:注册1:找回密码长度必须介于 0 和 1 之间")
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// @Length(min=0, max=10, message="code长度必须介于 0 和 10 之间")
// public String getCode() {
// return code;
// }
//
// public void setCode(String code) {
// this.code = code;
// }
//
// public String getUserId() {
// return userId;
// }
//
// public void setUserId(String userId) {
// this.userId = userId;
// }
//
// }
|
import java.util.List;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.service.CrudService;
import com.thinkgem.jeesite.common.utils.StringUtils;
import com.zlwh.hands.admin.modules.basis.dao.CTelsmsDao;
import com.zlwh.hands.admin.modules.basis.entity.CTelsms;
|
/**
* Copyright © 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
*/
package com.zlwh.hands.admin.modules.basis.service;
/**
* 短信验证码Service
* @author yuanjifeng
* @version 2016-07-15
*/
@Service
@Transactional(readOnly = true)
|
// Path: src/main/java/com/zlwh/hands/admin/modules/basis/dao/CTelsmsDao.java
// @MyBatisDao
// public interface CTelsmsDao extends CrudDao<CTelsms> {
//
// }
//
// Path: src/main/java/com/zlwh/hands/admin/modules/basis/entity/CTelsms.java
// public class CTelsms extends DataEntity<CTelsms> {
//
// private static final long serialVersionUID = 1L;
// private String phone; // phone
// private String type; // 0:注册1:找回密码
// private String code; // code
// private String userId; // user_id
//
// public CTelsms() {
// super();
// }
//
// public CTelsms(String id){
// super(id);
// }
//
// @Length(min=0, max=15, message="phone长度必须介于 0 和 15 之间")
// public String getPhone() {
// return phone;
// }
//
// public void setPhone(String phone) {
// this.phone = phone;
// }
//
// @Length(min=0, max=1, message="0:注册1:找回密码长度必须介于 0 和 1 之间")
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// @Length(min=0, max=10, message="code长度必须介于 0 和 10 之间")
// public String getCode() {
// return code;
// }
//
// public void setCode(String code) {
// this.code = code;
// }
//
// public String getUserId() {
// return userId;
// }
//
// public void setUserId(String userId) {
// this.userId = userId;
// }
//
// }
// Path: src/main/java/com/zlwh/hands/admin/modules/basis/service/CTelsmsService.java
import java.util.List;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.service.CrudService;
import com.thinkgem.jeesite.common.utils.StringUtils;
import com.zlwh.hands.admin.modules.basis.dao.CTelsmsDao;
import com.zlwh.hands.admin.modules.basis.entity.CTelsms;
/**
* Copyright © 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
*/
package com.zlwh.hands.admin.modules.basis.service;
/**
* 短信验证码Service
* @author yuanjifeng
* @version 2016-07-15
*/
@Service
@Transactional(readOnly = true)
|
public class CTelsmsService extends CrudService<CTelsmsDao, CTelsms> {
|
javyuan/jeesite-api
|
src/main/java/com/zlwh/hands/api/interceptor/LogInterceptor.java
|
// Path: src/main/java/com/zlwh/hands/api/common/utils/LogUtils.java
// public class LogUtils {
//
// private static CLogDao logDao = SpringContextHolder.getBean(CLogDao.class);
// private static Map<String,String[]> uriLogTypeMapping = new HashMap<String,String[]>();
// static{
// uriLogTypeMapping.put("/hands/api/user/1.0/register", new String[]{"0","注册"});
// uriLogTypeMapping.put("/hands/api/user/1.0/login", new String[]{"1","登录"});
// uriLogTypeMapping.put("/hands/api/user/1.0/logout", new String[]{"2","退出"});
// uriLogTypeMapping.put("/hands/api/user/1.0/resetPassword", new String[]{"3","重置密码"});
// uriLogTypeMapping.put("/hands/api/user/1.0/modifyPhone", new String[]{"4","更换手机号"});
// }
//
// /**
// * 保存日志
// */
// public static void saveLog(HttpServletRequest request, Object handler, Exception ex){
// CLog log = new CLog();
// String[] logType = uriLogTypeMapping.get(request.getRequestURI());
// if (logType != null) {
// log.setType(logType[0]);
// log.setTitle(logType[1]);
// }
// log.setUserToken(request.getParameter("userToken"));
// log.setRemoteAddr(StringUtils.getRemoteAddr(request));
// log.setUserAgent(request.getHeader("user-agent"));
// log.setRequestUri(request.getRequestURI());
// log.setParams(request.getParameterMap());
// log.setMethod(request.getMethod());
// log.setCreateTime(new Date());
// // 异步保存日志
// new SaveLogThread(log, handler, ex).start();
// }
//
// /**
// * 保存日志线程
// */
// public static class SaveLogThread extends Thread{
//
// private CLog log;
// private Exception ex;
//
// public SaveLogThread(CLog log, Object handler, Exception ex){
// super(SaveLogThread.class.getSimpleName());
// this.log = log;
// this.ex = ex;
// }
//
// @Override
// public void run() {
// // 如果有异常,设置异常信息
// log.setException(Exceptions.getStackTraceAsString(ex));
// // 如果无标题并无异常日志,则不保存信息
// if (StringUtils.isBlank(log.getTitle()) && StringUtils.isBlank(log.getType())){
// return;
// }
// // 保存日志信息
// logDao.insert(log);
// }
// }
//
// }
|
import java.text.SimpleDateFormat;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.NamedThreadLocal;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import com.thinkgem.jeesite.common.utils.DateUtils;
import com.zlwh.hands.api.common.utils.LogUtils;
|
/**
* Copyright © 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
*/
package com.zlwh.hands.api.interceptor;
/**
* 日志拦截器
* @author ThinkGem
* @version 2014-8-19
*/
public class LogInterceptor implements HandlerInterceptor {
/**
* 日志对象
*/
protected Logger logger = LoggerFactory.getLogger(getClass());
private static final ThreadLocal<Long> startTimeThreadLocal = new NamedThreadLocal<Long>("ThreadLocal StartTime");
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response,
Object handler) throws Exception {
if (logger.isDebugEnabled()){
long beginTime = System.currentTimeMillis();//1、开始时间
startTimeThreadLocal.set(beginTime); //线程绑定变量(该数据只有当前请求的线程可见)
logger.debug("开始计时: {} URI: {}", new SimpleDateFormat("hh:mm:ss.SSS")
.format(beginTime), request.getRequestURI());
}
return true;
}
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
ModelAndView modelAndView) throws Exception {
if (modelAndView != null){
logger.info("ViewName: " + modelAndView.getViewName());
}
}
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response,
Object handler, Exception ex) throws Exception {
// 保存日志
|
// Path: src/main/java/com/zlwh/hands/api/common/utils/LogUtils.java
// public class LogUtils {
//
// private static CLogDao logDao = SpringContextHolder.getBean(CLogDao.class);
// private static Map<String,String[]> uriLogTypeMapping = new HashMap<String,String[]>();
// static{
// uriLogTypeMapping.put("/hands/api/user/1.0/register", new String[]{"0","注册"});
// uriLogTypeMapping.put("/hands/api/user/1.0/login", new String[]{"1","登录"});
// uriLogTypeMapping.put("/hands/api/user/1.0/logout", new String[]{"2","退出"});
// uriLogTypeMapping.put("/hands/api/user/1.0/resetPassword", new String[]{"3","重置密码"});
// uriLogTypeMapping.put("/hands/api/user/1.0/modifyPhone", new String[]{"4","更换手机号"});
// }
//
// /**
// * 保存日志
// */
// public static void saveLog(HttpServletRequest request, Object handler, Exception ex){
// CLog log = new CLog();
// String[] logType = uriLogTypeMapping.get(request.getRequestURI());
// if (logType != null) {
// log.setType(logType[0]);
// log.setTitle(logType[1]);
// }
// log.setUserToken(request.getParameter("userToken"));
// log.setRemoteAddr(StringUtils.getRemoteAddr(request));
// log.setUserAgent(request.getHeader("user-agent"));
// log.setRequestUri(request.getRequestURI());
// log.setParams(request.getParameterMap());
// log.setMethod(request.getMethod());
// log.setCreateTime(new Date());
// // 异步保存日志
// new SaveLogThread(log, handler, ex).start();
// }
//
// /**
// * 保存日志线程
// */
// public static class SaveLogThread extends Thread{
//
// private CLog log;
// private Exception ex;
//
// public SaveLogThread(CLog log, Object handler, Exception ex){
// super(SaveLogThread.class.getSimpleName());
// this.log = log;
// this.ex = ex;
// }
//
// @Override
// public void run() {
// // 如果有异常,设置异常信息
// log.setException(Exceptions.getStackTraceAsString(ex));
// // 如果无标题并无异常日志,则不保存信息
// if (StringUtils.isBlank(log.getTitle()) && StringUtils.isBlank(log.getType())){
// return;
// }
// // 保存日志信息
// logDao.insert(log);
// }
// }
//
// }
// Path: src/main/java/com/zlwh/hands/api/interceptor/LogInterceptor.java
import java.text.SimpleDateFormat;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.NamedThreadLocal;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import com.thinkgem.jeesite.common.utils.DateUtils;
import com.zlwh.hands.api.common.utils.LogUtils;
/**
* Copyright © 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
*/
package com.zlwh.hands.api.interceptor;
/**
* 日志拦截器
* @author ThinkGem
* @version 2014-8-19
*/
public class LogInterceptor implements HandlerInterceptor {
/**
* 日志对象
*/
protected Logger logger = LoggerFactory.getLogger(getClass());
private static final ThreadLocal<Long> startTimeThreadLocal = new NamedThreadLocal<Long>("ThreadLocal StartTime");
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response,
Object handler) throws Exception {
if (logger.isDebugEnabled()){
long beginTime = System.currentTimeMillis();//1、开始时间
startTimeThreadLocal.set(beginTime); //线程绑定变量(该数据只有当前请求的线程可见)
logger.debug("开始计时: {} URI: {}", new SimpleDateFormat("hh:mm:ss.SSS")
.format(beginTime), request.getRequestURI());
}
return true;
}
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
ModelAndView modelAndView) throws Exception {
if (modelAndView != null){
logger.info("ViewName: " + modelAndView.getViewName());
}
}
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response,
Object handler, Exception ex) throws Exception {
// 保存日志
|
LogUtils.saveLog(request, handler, ex);
|
javyuan/jeesite-api
|
src/main/java/com/zlwh/hands/admin/modules/basis/service/CArticleService.java
|
// Path: src/main/java/com/zlwh/hands/admin/modules/basis/entity/CArticle.java
// public class CArticle extends DataEntity<CArticle> {
//
// private static final long serialVersionUID = 1L;
//
// public static final String TYPE_GUAN_YU_WO_MEN = "0";
// public static final String TYPE_BAN_QUAN_XIE_YI = "1";
//
// private String type; // type
// private String title; // title
// private String imageUrl; // image_url
// private String content; // content
// private String subTitle; // sub_title
//
// public CArticle() {
// super();
// }
//
// public CArticle(String id){
// super(id);
// }
//
// @Length(min=0, max=1, message="type长度必须介于 0 和 1 之间")
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// @Length(min=0, max=255, message="title长度必须介于 0 和 255 之间")
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// @Length(min=0, max=500, message="image_url长度必须介于 0 和 500 之间")
// public String getImageUrl() {
// return imageUrl;
// }
//
// public void setImageUrl(String imageUrl) {
// this.imageUrl = imageUrl;
// }
//
// @Length(min=0, max=5000, message="content长度必须介于 0 和 5000 之间")
// public String getContent() {
// return content;
// }
//
// public void setContent(String content) {
// this.content = content;
// }
//
// @Length(min=0, max=255, message="sub_title长度必须介于 0 和 255 之间")
// public String getSubTitle() {
// return subTitle;
// }
//
// public void setSubTitle(String subTitle) {
// this.subTitle = subTitle;
// }
//
// }
//
// Path: src/main/java/com/zlwh/hands/admin/modules/basis/dao/CArticleDao.java
// @MyBatisDao
// public interface CArticleDao extends CrudDao<CArticle> {
//
// }
|
import java.util.List;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.service.CrudService;
import com.zlwh.hands.admin.modules.basis.entity.CArticle;
import com.zlwh.hands.admin.modules.basis.dao.CArticleDao;
|
/**
* Copyright © 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
*/
package com.zlwh.hands.admin.modules.basis.service;
/**
* 单表生成Service
* @author yuanjifeng
* @version 2016-05-26
*/
@Service
@Transactional(readOnly = true)
|
// Path: src/main/java/com/zlwh/hands/admin/modules/basis/entity/CArticle.java
// public class CArticle extends DataEntity<CArticle> {
//
// private static final long serialVersionUID = 1L;
//
// public static final String TYPE_GUAN_YU_WO_MEN = "0";
// public static final String TYPE_BAN_QUAN_XIE_YI = "1";
//
// private String type; // type
// private String title; // title
// private String imageUrl; // image_url
// private String content; // content
// private String subTitle; // sub_title
//
// public CArticle() {
// super();
// }
//
// public CArticle(String id){
// super(id);
// }
//
// @Length(min=0, max=1, message="type长度必须介于 0 和 1 之间")
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// @Length(min=0, max=255, message="title长度必须介于 0 和 255 之间")
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// @Length(min=0, max=500, message="image_url长度必须介于 0 和 500 之间")
// public String getImageUrl() {
// return imageUrl;
// }
//
// public void setImageUrl(String imageUrl) {
// this.imageUrl = imageUrl;
// }
//
// @Length(min=0, max=5000, message="content长度必须介于 0 和 5000 之间")
// public String getContent() {
// return content;
// }
//
// public void setContent(String content) {
// this.content = content;
// }
//
// @Length(min=0, max=255, message="sub_title长度必须介于 0 和 255 之间")
// public String getSubTitle() {
// return subTitle;
// }
//
// public void setSubTitle(String subTitle) {
// this.subTitle = subTitle;
// }
//
// }
//
// Path: src/main/java/com/zlwh/hands/admin/modules/basis/dao/CArticleDao.java
// @MyBatisDao
// public interface CArticleDao extends CrudDao<CArticle> {
//
// }
// Path: src/main/java/com/zlwh/hands/admin/modules/basis/service/CArticleService.java
import java.util.List;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.service.CrudService;
import com.zlwh.hands.admin.modules.basis.entity.CArticle;
import com.zlwh.hands.admin.modules.basis.dao.CArticleDao;
/**
* Copyright © 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
*/
package com.zlwh.hands.admin.modules.basis.service;
/**
* 单表生成Service
* @author yuanjifeng
* @version 2016-05-26
*/
@Service
@Transactional(readOnly = true)
|
public class CArticleService extends CrudService<CArticleDao, CArticle> {
|
javyuan/jeesite-api
|
src/main/java/com/zlwh/hands/admin/modules/basis/service/CArticleService.java
|
// Path: src/main/java/com/zlwh/hands/admin/modules/basis/entity/CArticle.java
// public class CArticle extends DataEntity<CArticle> {
//
// private static final long serialVersionUID = 1L;
//
// public static final String TYPE_GUAN_YU_WO_MEN = "0";
// public static final String TYPE_BAN_QUAN_XIE_YI = "1";
//
// private String type; // type
// private String title; // title
// private String imageUrl; // image_url
// private String content; // content
// private String subTitle; // sub_title
//
// public CArticle() {
// super();
// }
//
// public CArticle(String id){
// super(id);
// }
//
// @Length(min=0, max=1, message="type长度必须介于 0 和 1 之间")
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// @Length(min=0, max=255, message="title长度必须介于 0 和 255 之间")
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// @Length(min=0, max=500, message="image_url长度必须介于 0 和 500 之间")
// public String getImageUrl() {
// return imageUrl;
// }
//
// public void setImageUrl(String imageUrl) {
// this.imageUrl = imageUrl;
// }
//
// @Length(min=0, max=5000, message="content长度必须介于 0 和 5000 之间")
// public String getContent() {
// return content;
// }
//
// public void setContent(String content) {
// this.content = content;
// }
//
// @Length(min=0, max=255, message="sub_title长度必须介于 0 和 255 之间")
// public String getSubTitle() {
// return subTitle;
// }
//
// public void setSubTitle(String subTitle) {
// this.subTitle = subTitle;
// }
//
// }
//
// Path: src/main/java/com/zlwh/hands/admin/modules/basis/dao/CArticleDao.java
// @MyBatisDao
// public interface CArticleDao extends CrudDao<CArticle> {
//
// }
|
import java.util.List;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.service.CrudService;
import com.zlwh.hands.admin.modules.basis.entity.CArticle;
import com.zlwh.hands.admin.modules.basis.dao.CArticleDao;
|
/**
* Copyright © 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
*/
package com.zlwh.hands.admin.modules.basis.service;
/**
* 单表生成Service
* @author yuanjifeng
* @version 2016-05-26
*/
@Service
@Transactional(readOnly = true)
|
// Path: src/main/java/com/zlwh/hands/admin/modules/basis/entity/CArticle.java
// public class CArticle extends DataEntity<CArticle> {
//
// private static final long serialVersionUID = 1L;
//
// public static final String TYPE_GUAN_YU_WO_MEN = "0";
// public static final String TYPE_BAN_QUAN_XIE_YI = "1";
//
// private String type; // type
// private String title; // title
// private String imageUrl; // image_url
// private String content; // content
// private String subTitle; // sub_title
//
// public CArticle() {
// super();
// }
//
// public CArticle(String id){
// super(id);
// }
//
// @Length(min=0, max=1, message="type长度必须介于 0 和 1 之间")
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// @Length(min=0, max=255, message="title长度必须介于 0 和 255 之间")
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// @Length(min=0, max=500, message="image_url长度必须介于 0 和 500 之间")
// public String getImageUrl() {
// return imageUrl;
// }
//
// public void setImageUrl(String imageUrl) {
// this.imageUrl = imageUrl;
// }
//
// @Length(min=0, max=5000, message="content长度必须介于 0 和 5000 之间")
// public String getContent() {
// return content;
// }
//
// public void setContent(String content) {
// this.content = content;
// }
//
// @Length(min=0, max=255, message="sub_title长度必须介于 0 和 255 之间")
// public String getSubTitle() {
// return subTitle;
// }
//
// public void setSubTitle(String subTitle) {
// this.subTitle = subTitle;
// }
//
// }
//
// Path: src/main/java/com/zlwh/hands/admin/modules/basis/dao/CArticleDao.java
// @MyBatisDao
// public interface CArticleDao extends CrudDao<CArticle> {
//
// }
// Path: src/main/java/com/zlwh/hands/admin/modules/basis/service/CArticleService.java
import java.util.List;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.service.CrudService;
import com.zlwh.hands.admin.modules.basis.entity.CArticle;
import com.zlwh.hands.admin.modules.basis.dao.CArticleDao;
/**
* Copyright © 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
*/
package com.zlwh.hands.admin.modules.basis.service;
/**
* 单表生成Service
* @author yuanjifeng
* @version 2016-05-26
*/
@Service
@Transactional(readOnly = true)
|
public class CArticleService extends CrudService<CArticleDao, CArticle> {
|
javyuan/jeesite-api
|
src/main/java/com/zlwh/hands/admin/modules/user/service/CSessionService.java
|
// Path: src/main/java/com/zlwh/hands/admin/modules/user/entity/CSession.java
// public class CSession extends DataEntity<CSession> {
//
// private static final long serialVersionUID = 1L;
// private String userId;
// private String deviceType;
// private String loginIp;
// private Date loginDate;
// private Date logoutDate;
// private String status;
//
// public CSession() {
// super();
// }
//
// public CSession(String id){
// super(id);
// }
//
// public String getUserId() {
// return userId;
// }
//
// public void setUserId(String userId) {
// this.userId = userId;
// }
//
// public String getDeviceType() {
// return deviceType;
// }
//
// public void setDeviceType(String deviceType) {
// this.deviceType = deviceType;
// }
//
// public String getLoginIp() {
// return loginIp;
// }
//
// public void setLoginIp(String loginIp) {
// this.loginIp = loginIp;
// }
//
// public Date getLoginDate() {
// return loginDate;
// }
//
// public void setLoginDate(Date loginDate) {
// this.loginDate = loginDate;
// }
//
// public Date getLogoutDate() {
// return logoutDate;
// }
//
// public void setLogoutDate(Date logoutDate) {
// this.logoutDate = logoutDate;
// }
//
// public String getStatus() {
// return status;
// }
//
// public void setStatus(String status) {
// this.status = status;
// }
//
// }
//
// Path: src/main/java/com/zlwh/hands/admin/modules/user/dao/CSessionDao.java
// @MyBatisDao
// public interface CSessionDao extends CrudDao<CSession> {
//
// }
|
import java.util.List;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.service.CrudService;
import com.zlwh.hands.admin.modules.user.entity.CSession;
import com.zlwh.hands.admin.modules.user.dao.CSessionDao;
|
/**
* Copyright © 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
*/
package com.zlwh.hands.admin.modules.user.service;
/**
* 客户端会话Service
* @author yuanjifeng
* @version 2016-05-30
*/
@Service
@Transactional(readOnly = true)
|
// Path: src/main/java/com/zlwh/hands/admin/modules/user/entity/CSession.java
// public class CSession extends DataEntity<CSession> {
//
// private static final long serialVersionUID = 1L;
// private String userId;
// private String deviceType;
// private String loginIp;
// private Date loginDate;
// private Date logoutDate;
// private String status;
//
// public CSession() {
// super();
// }
//
// public CSession(String id){
// super(id);
// }
//
// public String getUserId() {
// return userId;
// }
//
// public void setUserId(String userId) {
// this.userId = userId;
// }
//
// public String getDeviceType() {
// return deviceType;
// }
//
// public void setDeviceType(String deviceType) {
// this.deviceType = deviceType;
// }
//
// public String getLoginIp() {
// return loginIp;
// }
//
// public void setLoginIp(String loginIp) {
// this.loginIp = loginIp;
// }
//
// public Date getLoginDate() {
// return loginDate;
// }
//
// public void setLoginDate(Date loginDate) {
// this.loginDate = loginDate;
// }
//
// public Date getLogoutDate() {
// return logoutDate;
// }
//
// public void setLogoutDate(Date logoutDate) {
// this.logoutDate = logoutDate;
// }
//
// public String getStatus() {
// return status;
// }
//
// public void setStatus(String status) {
// this.status = status;
// }
//
// }
//
// Path: src/main/java/com/zlwh/hands/admin/modules/user/dao/CSessionDao.java
// @MyBatisDao
// public interface CSessionDao extends CrudDao<CSession> {
//
// }
// Path: src/main/java/com/zlwh/hands/admin/modules/user/service/CSessionService.java
import java.util.List;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.service.CrudService;
import com.zlwh.hands.admin.modules.user.entity.CSession;
import com.zlwh.hands.admin.modules.user.dao.CSessionDao;
/**
* Copyright © 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
*/
package com.zlwh.hands.admin.modules.user.service;
/**
* 客户端会话Service
* @author yuanjifeng
* @version 2016-05-30
*/
@Service
@Transactional(readOnly = true)
|
public class CSessionService extends CrudService<CSessionDao, CSession> {
|
javyuan/jeesite-api
|
src/main/java/com/zlwh/hands/admin/modules/user/service/CSessionService.java
|
// Path: src/main/java/com/zlwh/hands/admin/modules/user/entity/CSession.java
// public class CSession extends DataEntity<CSession> {
//
// private static final long serialVersionUID = 1L;
// private String userId;
// private String deviceType;
// private String loginIp;
// private Date loginDate;
// private Date logoutDate;
// private String status;
//
// public CSession() {
// super();
// }
//
// public CSession(String id){
// super(id);
// }
//
// public String getUserId() {
// return userId;
// }
//
// public void setUserId(String userId) {
// this.userId = userId;
// }
//
// public String getDeviceType() {
// return deviceType;
// }
//
// public void setDeviceType(String deviceType) {
// this.deviceType = deviceType;
// }
//
// public String getLoginIp() {
// return loginIp;
// }
//
// public void setLoginIp(String loginIp) {
// this.loginIp = loginIp;
// }
//
// public Date getLoginDate() {
// return loginDate;
// }
//
// public void setLoginDate(Date loginDate) {
// this.loginDate = loginDate;
// }
//
// public Date getLogoutDate() {
// return logoutDate;
// }
//
// public void setLogoutDate(Date logoutDate) {
// this.logoutDate = logoutDate;
// }
//
// public String getStatus() {
// return status;
// }
//
// public void setStatus(String status) {
// this.status = status;
// }
//
// }
//
// Path: src/main/java/com/zlwh/hands/admin/modules/user/dao/CSessionDao.java
// @MyBatisDao
// public interface CSessionDao extends CrudDao<CSession> {
//
// }
|
import java.util.List;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.service.CrudService;
import com.zlwh.hands.admin.modules.user.entity.CSession;
import com.zlwh.hands.admin.modules.user.dao.CSessionDao;
|
/**
* Copyright © 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
*/
package com.zlwh.hands.admin.modules.user.service;
/**
* 客户端会话Service
* @author yuanjifeng
* @version 2016-05-30
*/
@Service
@Transactional(readOnly = true)
|
// Path: src/main/java/com/zlwh/hands/admin/modules/user/entity/CSession.java
// public class CSession extends DataEntity<CSession> {
//
// private static final long serialVersionUID = 1L;
// private String userId;
// private String deviceType;
// private String loginIp;
// private Date loginDate;
// private Date logoutDate;
// private String status;
//
// public CSession() {
// super();
// }
//
// public CSession(String id){
// super(id);
// }
//
// public String getUserId() {
// return userId;
// }
//
// public void setUserId(String userId) {
// this.userId = userId;
// }
//
// public String getDeviceType() {
// return deviceType;
// }
//
// public void setDeviceType(String deviceType) {
// this.deviceType = deviceType;
// }
//
// public String getLoginIp() {
// return loginIp;
// }
//
// public void setLoginIp(String loginIp) {
// this.loginIp = loginIp;
// }
//
// public Date getLoginDate() {
// return loginDate;
// }
//
// public void setLoginDate(Date loginDate) {
// this.loginDate = loginDate;
// }
//
// public Date getLogoutDate() {
// return logoutDate;
// }
//
// public void setLogoutDate(Date logoutDate) {
// this.logoutDate = logoutDate;
// }
//
// public String getStatus() {
// return status;
// }
//
// public void setStatus(String status) {
// this.status = status;
// }
//
// }
//
// Path: src/main/java/com/zlwh/hands/admin/modules/user/dao/CSessionDao.java
// @MyBatisDao
// public interface CSessionDao extends CrudDao<CSession> {
//
// }
// Path: src/main/java/com/zlwh/hands/admin/modules/user/service/CSessionService.java
import java.util.List;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.service.CrudService;
import com.zlwh.hands.admin.modules.user.entity.CSession;
import com.zlwh.hands.admin.modules.user.dao.CSessionDao;
/**
* Copyright © 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
*/
package com.zlwh.hands.admin.modules.user.service;
/**
* 客户端会话Service
* @author yuanjifeng
* @version 2016-05-30
*/
@Service
@Transactional(readOnly = true)
|
public class CSessionService extends CrudService<CSessionDao, CSession> {
|
javyuan/jeesite-api
|
src/main/java/com/zlwh/hands/api/common/utils/TokenUtils.java
|
// Path: src/main/java/com/zlwh/hands/api/common/Constants.java
// public class Constants {
//
// //用户类型
// public static final String USER_TYPE_GUEST = "0";
// public static final String USER_TYPE_USER = "1";
// public static final String USER_TYPE_THIRDPARTY = "2";
//
// //用户状态
// public static final String USER_STATUS_NORMAL = "0";
// public static final String USER_STATUS_LOCK = "1";
//
// //会话状态
// public static final String SESSION_STATUS_LOGIN = "0";
// public static final String SESSION_STATUS_LOGOUT = "1";
// public static final String SESSION_STATUS_KICKOUT = "2";
// public static final String SESSION_STATUS_EXPIRE = "3";
//
// //设备类型
// public static final String DEVICE_TYPE_IPHONE = "0";
// public static final String DEVICE_TYPE_IPAD = "1";
// public static final String DEVICE_TYPE_IWATCH = "2";
// public static final String DEVICE_TYPE_ANDROID = "5";
// public static final String DEVICE_TYPE_ANDROID_PAD = "6";
// public static final String DEVICE_TYPE_ANDROID_WATCH = "7";
//
// //错误码
// public static final String ERRORCODE_INVALID_PARAM = "1000";
// public static final String ERRORCODE_AUTHENTICODE_TOO_FREQUENTLY = "1001";
// public static final String ERRORCODE_INVALID_PHONE_NUM = "1002";
// public static final String ERRORCODE_USER_EXIST = "1003";
// public static final String ERRORCODE_SIMPLE_PASSWORD = "1004";
// public static final String ERRORCODE_INVALID_AUTHENTICODE = "1005";
// public static final String ERRORCODE_INVALID_DEVICE_TYPE = "1006";
// public static final String ERRORCODE_INVALID_USERNAME_PASSWORD = "1007";
// public static final String ERRORCODE_USER_LOCKED = "1008";
// public static final String ERRORCODE_INVALID_TOKEN = "1009";
// public static final String ERRORCODE_NOT_LOGIN = "1010";
// public static final String ERRORCODE_SESSION_KICKOUT = "1011";
// public static final String ERRORCODE_SESSION_LOGOUT = "1012";
// public static final String ERRORCODE_SESSION_EXPIRE = "1013";
//
// }
//
// Path: src/main/java/com/zlwh/hands/api/common/UserToken.java
// public class UserToken implements Serializable{
//
// private static final long serialVersionUID = -2910636802113452789L;
// private String userId;
// private String sessionId;
// private String userType;
// private String loginName;
// private Long loginTime;
//
// public UserToken(String userId,String sessionId,String userType,String loginName,Long loginTime) {
// this.userId = userId;
// this.sessionId = sessionId;
// this.userType = userType;
// this.loginName = loginName;
// this.loginTime = loginTime;
// }
//
// public UserToken(String userId,String userType) {
// this(userId,null,userType,null,null);
// }
//
// public UserToken(String userId,String sessionId,String userType,Long loginTime) {
// this(userId,sessionId,userType,null,loginTime);
// }
//
// public String getUserId() {
// return userId;
// }
//
// public String getSessionId() {
// return sessionId;
// }
//
// public String getUserType() {
// return userType;
// }
//
// public String getLoginName() {
// return loginName;
// }
//
// public Long getLoginTime() {
// return loginTime;
// }
// }
|
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.InvalidSessionException;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.thinkgem.jeesite.common.security.Cryptos;
import com.thinkgem.jeesite.common.utils.StringUtils;
import com.zlwh.hands.api.common.Constants;
import com.zlwh.hands.api.common.UserToken;
|
package com.zlwh.hands.api.common.utils;
/**
*
* UserToken工具类
*
* 用户第一次访问时创建Token,该用户被标识为匿名用户
* 用户登录时生成新的Token,该用户被标识为登录用户
*
* @author yuanjifeng
*
*/
public class TokenUtils {
private static final Logger logger = LoggerFactory.getLogger(TokenUtils.class);
private static final String ENCRYPT_KEY = "59FF4BEDF5155319CE6F39815653C60A";
private static final String SEPARATE = ":";
private static final String SESSION_KEY = "CUSERTOKEN";
/**
* 加密Token
* ${userId}:${sessionId}:${userType}:${loginName}:${loginTime}
*
*/
|
// Path: src/main/java/com/zlwh/hands/api/common/Constants.java
// public class Constants {
//
// //用户类型
// public static final String USER_TYPE_GUEST = "0";
// public static final String USER_TYPE_USER = "1";
// public static final String USER_TYPE_THIRDPARTY = "2";
//
// //用户状态
// public static final String USER_STATUS_NORMAL = "0";
// public static final String USER_STATUS_LOCK = "1";
//
// //会话状态
// public static final String SESSION_STATUS_LOGIN = "0";
// public static final String SESSION_STATUS_LOGOUT = "1";
// public static final String SESSION_STATUS_KICKOUT = "2";
// public static final String SESSION_STATUS_EXPIRE = "3";
//
// //设备类型
// public static final String DEVICE_TYPE_IPHONE = "0";
// public static final String DEVICE_TYPE_IPAD = "1";
// public static final String DEVICE_TYPE_IWATCH = "2";
// public static final String DEVICE_TYPE_ANDROID = "5";
// public static final String DEVICE_TYPE_ANDROID_PAD = "6";
// public static final String DEVICE_TYPE_ANDROID_WATCH = "7";
//
// //错误码
// public static final String ERRORCODE_INVALID_PARAM = "1000";
// public static final String ERRORCODE_AUTHENTICODE_TOO_FREQUENTLY = "1001";
// public static final String ERRORCODE_INVALID_PHONE_NUM = "1002";
// public static final String ERRORCODE_USER_EXIST = "1003";
// public static final String ERRORCODE_SIMPLE_PASSWORD = "1004";
// public static final String ERRORCODE_INVALID_AUTHENTICODE = "1005";
// public static final String ERRORCODE_INVALID_DEVICE_TYPE = "1006";
// public static final String ERRORCODE_INVALID_USERNAME_PASSWORD = "1007";
// public static final String ERRORCODE_USER_LOCKED = "1008";
// public static final String ERRORCODE_INVALID_TOKEN = "1009";
// public static final String ERRORCODE_NOT_LOGIN = "1010";
// public static final String ERRORCODE_SESSION_KICKOUT = "1011";
// public static final String ERRORCODE_SESSION_LOGOUT = "1012";
// public static final String ERRORCODE_SESSION_EXPIRE = "1013";
//
// }
//
// Path: src/main/java/com/zlwh/hands/api/common/UserToken.java
// public class UserToken implements Serializable{
//
// private static final long serialVersionUID = -2910636802113452789L;
// private String userId;
// private String sessionId;
// private String userType;
// private String loginName;
// private Long loginTime;
//
// public UserToken(String userId,String sessionId,String userType,String loginName,Long loginTime) {
// this.userId = userId;
// this.sessionId = sessionId;
// this.userType = userType;
// this.loginName = loginName;
// this.loginTime = loginTime;
// }
//
// public UserToken(String userId,String userType) {
// this(userId,null,userType,null,null);
// }
//
// public UserToken(String userId,String sessionId,String userType,Long loginTime) {
// this(userId,sessionId,userType,null,loginTime);
// }
//
// public String getUserId() {
// return userId;
// }
//
// public String getSessionId() {
// return sessionId;
// }
//
// public String getUserType() {
// return userType;
// }
//
// public String getLoginName() {
// return loginName;
// }
//
// public Long getLoginTime() {
// return loginTime;
// }
// }
// Path: src/main/java/com/zlwh/hands/api/common/utils/TokenUtils.java
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.InvalidSessionException;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.thinkgem.jeesite.common.security.Cryptos;
import com.thinkgem.jeesite.common.utils.StringUtils;
import com.zlwh.hands.api.common.Constants;
import com.zlwh.hands.api.common.UserToken;
package com.zlwh.hands.api.common.utils;
/**
*
* UserToken工具类
*
* 用户第一次访问时创建Token,该用户被标识为匿名用户
* 用户登录时生成新的Token,该用户被标识为登录用户
*
* @author yuanjifeng
*
*/
public class TokenUtils {
private static final Logger logger = LoggerFactory.getLogger(TokenUtils.class);
private static final String ENCRYPT_KEY = "59FF4BEDF5155319CE6F39815653C60A";
private static final String SEPARATE = ":";
private static final String SESSION_KEY = "CUSERTOKEN";
/**
* 加密Token
* ${userId}:${sessionId}:${userType}:${loginName}:${loginTime}
*
*/
|
public static String encryptToken(UserToken ut) {
|
javyuan/jeesite-api
|
src/main/java/com/zlwh/hands/api/common/utils/TokenUtils.java
|
// Path: src/main/java/com/zlwh/hands/api/common/Constants.java
// public class Constants {
//
// //用户类型
// public static final String USER_TYPE_GUEST = "0";
// public static final String USER_TYPE_USER = "1";
// public static final String USER_TYPE_THIRDPARTY = "2";
//
// //用户状态
// public static final String USER_STATUS_NORMAL = "0";
// public static final String USER_STATUS_LOCK = "1";
//
// //会话状态
// public static final String SESSION_STATUS_LOGIN = "0";
// public static final String SESSION_STATUS_LOGOUT = "1";
// public static final String SESSION_STATUS_KICKOUT = "2";
// public static final String SESSION_STATUS_EXPIRE = "3";
//
// //设备类型
// public static final String DEVICE_TYPE_IPHONE = "0";
// public static final String DEVICE_TYPE_IPAD = "1";
// public static final String DEVICE_TYPE_IWATCH = "2";
// public static final String DEVICE_TYPE_ANDROID = "5";
// public static final String DEVICE_TYPE_ANDROID_PAD = "6";
// public static final String DEVICE_TYPE_ANDROID_WATCH = "7";
//
// //错误码
// public static final String ERRORCODE_INVALID_PARAM = "1000";
// public static final String ERRORCODE_AUTHENTICODE_TOO_FREQUENTLY = "1001";
// public static final String ERRORCODE_INVALID_PHONE_NUM = "1002";
// public static final String ERRORCODE_USER_EXIST = "1003";
// public static final String ERRORCODE_SIMPLE_PASSWORD = "1004";
// public static final String ERRORCODE_INVALID_AUTHENTICODE = "1005";
// public static final String ERRORCODE_INVALID_DEVICE_TYPE = "1006";
// public static final String ERRORCODE_INVALID_USERNAME_PASSWORD = "1007";
// public static final String ERRORCODE_USER_LOCKED = "1008";
// public static final String ERRORCODE_INVALID_TOKEN = "1009";
// public static final String ERRORCODE_NOT_LOGIN = "1010";
// public static final String ERRORCODE_SESSION_KICKOUT = "1011";
// public static final String ERRORCODE_SESSION_LOGOUT = "1012";
// public static final String ERRORCODE_SESSION_EXPIRE = "1013";
//
// }
//
// Path: src/main/java/com/zlwh/hands/api/common/UserToken.java
// public class UserToken implements Serializable{
//
// private static final long serialVersionUID = -2910636802113452789L;
// private String userId;
// private String sessionId;
// private String userType;
// private String loginName;
// private Long loginTime;
//
// public UserToken(String userId,String sessionId,String userType,String loginName,Long loginTime) {
// this.userId = userId;
// this.sessionId = sessionId;
// this.userType = userType;
// this.loginName = loginName;
// this.loginTime = loginTime;
// }
//
// public UserToken(String userId,String userType) {
// this(userId,null,userType,null,null);
// }
//
// public UserToken(String userId,String sessionId,String userType,Long loginTime) {
// this(userId,sessionId,userType,null,loginTime);
// }
//
// public String getUserId() {
// return userId;
// }
//
// public String getSessionId() {
// return sessionId;
// }
//
// public String getUserType() {
// return userType;
// }
//
// public String getLoginName() {
// return loginName;
// }
//
// public Long getLoginTime() {
// return loginTime;
// }
// }
|
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.InvalidSessionException;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.thinkgem.jeesite.common.security.Cryptos;
import com.thinkgem.jeesite.common.utils.StringUtils;
import com.zlwh.hands.api.common.Constants;
import com.zlwh.hands.api.common.UserToken;
|
}
StringBuilder tokenStr = new StringBuilder();
tokenStr.append(ut.getUserId());
tokenStr.append(SEPARATE);
tokenStr.append(ut.getSessionId() == null ? "":ut.getSessionId());
tokenStr.append(SEPARATE);
tokenStr.append(ut.getUserType());
tokenStr.append(SEPARATE);
tokenStr.append(ut.getLoginName() == null ? "":ut.getLoginName());
tokenStr.append(SEPARATE);
tokenStr.append(ut.getLoginTime() == null ? "":ut.getLoginTime());
logger.info("original token string :"+tokenStr);
return Cryptos.aesEncrypt(tokenStr.toString(), ENCRYPT_KEY);
}
/**
* 解密Token
*/
public static UserToken decryptToken(String encrypt) {
if (encrypt == null) {
return null;
}
String[] tmpArray = null;
try {
String tokenStr = Cryptos.aesDecrypt(encrypt, ENCRYPT_KEY);
tmpArray = tokenStr.split(SEPARATE);
} catch (Exception e) {
return null;
}
String userType = tmpArray[2];
|
// Path: src/main/java/com/zlwh/hands/api/common/Constants.java
// public class Constants {
//
// //用户类型
// public static final String USER_TYPE_GUEST = "0";
// public static final String USER_TYPE_USER = "1";
// public static final String USER_TYPE_THIRDPARTY = "2";
//
// //用户状态
// public static final String USER_STATUS_NORMAL = "0";
// public static final String USER_STATUS_LOCK = "1";
//
// //会话状态
// public static final String SESSION_STATUS_LOGIN = "0";
// public static final String SESSION_STATUS_LOGOUT = "1";
// public static final String SESSION_STATUS_KICKOUT = "2";
// public static final String SESSION_STATUS_EXPIRE = "3";
//
// //设备类型
// public static final String DEVICE_TYPE_IPHONE = "0";
// public static final String DEVICE_TYPE_IPAD = "1";
// public static final String DEVICE_TYPE_IWATCH = "2";
// public static final String DEVICE_TYPE_ANDROID = "5";
// public static final String DEVICE_TYPE_ANDROID_PAD = "6";
// public static final String DEVICE_TYPE_ANDROID_WATCH = "7";
//
// //错误码
// public static final String ERRORCODE_INVALID_PARAM = "1000";
// public static final String ERRORCODE_AUTHENTICODE_TOO_FREQUENTLY = "1001";
// public static final String ERRORCODE_INVALID_PHONE_NUM = "1002";
// public static final String ERRORCODE_USER_EXIST = "1003";
// public static final String ERRORCODE_SIMPLE_PASSWORD = "1004";
// public static final String ERRORCODE_INVALID_AUTHENTICODE = "1005";
// public static final String ERRORCODE_INVALID_DEVICE_TYPE = "1006";
// public static final String ERRORCODE_INVALID_USERNAME_PASSWORD = "1007";
// public static final String ERRORCODE_USER_LOCKED = "1008";
// public static final String ERRORCODE_INVALID_TOKEN = "1009";
// public static final String ERRORCODE_NOT_LOGIN = "1010";
// public static final String ERRORCODE_SESSION_KICKOUT = "1011";
// public static final String ERRORCODE_SESSION_LOGOUT = "1012";
// public static final String ERRORCODE_SESSION_EXPIRE = "1013";
//
// }
//
// Path: src/main/java/com/zlwh/hands/api/common/UserToken.java
// public class UserToken implements Serializable{
//
// private static final long serialVersionUID = -2910636802113452789L;
// private String userId;
// private String sessionId;
// private String userType;
// private String loginName;
// private Long loginTime;
//
// public UserToken(String userId,String sessionId,String userType,String loginName,Long loginTime) {
// this.userId = userId;
// this.sessionId = sessionId;
// this.userType = userType;
// this.loginName = loginName;
// this.loginTime = loginTime;
// }
//
// public UserToken(String userId,String userType) {
// this(userId,null,userType,null,null);
// }
//
// public UserToken(String userId,String sessionId,String userType,Long loginTime) {
// this(userId,sessionId,userType,null,loginTime);
// }
//
// public String getUserId() {
// return userId;
// }
//
// public String getSessionId() {
// return sessionId;
// }
//
// public String getUserType() {
// return userType;
// }
//
// public String getLoginName() {
// return loginName;
// }
//
// public Long getLoginTime() {
// return loginTime;
// }
// }
// Path: src/main/java/com/zlwh/hands/api/common/utils/TokenUtils.java
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.InvalidSessionException;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.thinkgem.jeesite.common.security.Cryptos;
import com.thinkgem.jeesite.common.utils.StringUtils;
import com.zlwh.hands.api.common.Constants;
import com.zlwh.hands.api.common.UserToken;
}
StringBuilder tokenStr = new StringBuilder();
tokenStr.append(ut.getUserId());
tokenStr.append(SEPARATE);
tokenStr.append(ut.getSessionId() == null ? "":ut.getSessionId());
tokenStr.append(SEPARATE);
tokenStr.append(ut.getUserType());
tokenStr.append(SEPARATE);
tokenStr.append(ut.getLoginName() == null ? "":ut.getLoginName());
tokenStr.append(SEPARATE);
tokenStr.append(ut.getLoginTime() == null ? "":ut.getLoginTime());
logger.info("original token string :"+tokenStr);
return Cryptos.aesEncrypt(tokenStr.toString(), ENCRYPT_KEY);
}
/**
* 解密Token
*/
public static UserToken decryptToken(String encrypt) {
if (encrypt == null) {
return null;
}
String[] tmpArray = null;
try {
String tokenStr = Cryptos.aesDecrypt(encrypt, ENCRYPT_KEY);
tmpArray = tokenStr.split(SEPARATE);
} catch (Exception e) {
return null;
}
String userType = tmpArray[2];
|
if (Constants.USER_TYPE_GUEST.equals(userType)) {
|
javyuan/jeesite-api
|
src/main/java/com/zlwh/hands/admin/modules/sys/service/SysSequenceService.java
|
// Path: src/main/java/com/zlwh/hands/admin/modules/sys/entity/SysSequence.java
// public class SysSequence extends DataEntity<SysSequence> {
//
// private static final long serialVersionUID = 1L;
// private String name; // name
// private String currentValue; // current_value
// private String increment; // increment
//
// public SysSequence() {
// super();
// }
//
// public SysSequence(String id){
// super(id);
// }
//
// @Length(min=1, max=128, message="name长度必须介于 1 和 128 之间")
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// @Length(min=1, max=11, message="current_value长度必须介于 1 和 11 之间")
// public String getCurrentValue() {
// return currentValue;
// }
//
// public void setCurrentValue(String currentValue) {
// this.currentValue = currentValue;
// }
//
// @Length(min=1, max=11, message="increment长度必须介于 1 和 11 之间")
// public String getIncrement() {
// return increment;
// }
//
// public void setIncrement(String increment) {
// this.increment = increment;
// }
//
// }
//
// Path: src/main/java/com/zlwh/hands/admin/modules/sys/dao/SysSequenceDao.java
// @MyBatisDao
// public interface SysSequenceDao extends CrudDao<SysSequence> {
//
// String getNextVal(SysSequence sysSequence);
//
// String getCurrentVal(SysSequence sysSequence);
//
// }
|
import java.util.List;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.service.CrudService;
import com.zlwh.hands.admin.modules.sys.entity.SysSequence;
import com.zlwh.hands.admin.modules.sys.dao.SysSequenceDao;
|
/**
* Copyright © 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
*/
package com.zlwh.hands.admin.modules.sys.service;
/**
* 数据库序列Service
* @author yuanjifeng
* @version 2016-06-07
*/
@Service
@Transactional(readOnly = true)
|
// Path: src/main/java/com/zlwh/hands/admin/modules/sys/entity/SysSequence.java
// public class SysSequence extends DataEntity<SysSequence> {
//
// private static final long serialVersionUID = 1L;
// private String name; // name
// private String currentValue; // current_value
// private String increment; // increment
//
// public SysSequence() {
// super();
// }
//
// public SysSequence(String id){
// super(id);
// }
//
// @Length(min=1, max=128, message="name长度必须介于 1 和 128 之间")
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// @Length(min=1, max=11, message="current_value长度必须介于 1 和 11 之间")
// public String getCurrentValue() {
// return currentValue;
// }
//
// public void setCurrentValue(String currentValue) {
// this.currentValue = currentValue;
// }
//
// @Length(min=1, max=11, message="increment长度必须介于 1 和 11 之间")
// public String getIncrement() {
// return increment;
// }
//
// public void setIncrement(String increment) {
// this.increment = increment;
// }
//
// }
//
// Path: src/main/java/com/zlwh/hands/admin/modules/sys/dao/SysSequenceDao.java
// @MyBatisDao
// public interface SysSequenceDao extends CrudDao<SysSequence> {
//
// String getNextVal(SysSequence sysSequence);
//
// String getCurrentVal(SysSequence sysSequence);
//
// }
// Path: src/main/java/com/zlwh/hands/admin/modules/sys/service/SysSequenceService.java
import java.util.List;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.service.CrudService;
import com.zlwh.hands.admin.modules.sys.entity.SysSequence;
import com.zlwh.hands.admin.modules.sys.dao.SysSequenceDao;
/**
* Copyright © 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
*/
package com.zlwh.hands.admin.modules.sys.service;
/**
* 数据库序列Service
* @author yuanjifeng
* @version 2016-06-07
*/
@Service
@Transactional(readOnly = true)
|
public class SysSequenceService extends CrudService<SysSequenceDao, SysSequence> {
|
javyuan/jeesite-api
|
src/main/java/com/zlwh/hands/admin/modules/sys/service/SysSequenceService.java
|
// Path: src/main/java/com/zlwh/hands/admin/modules/sys/entity/SysSequence.java
// public class SysSequence extends DataEntity<SysSequence> {
//
// private static final long serialVersionUID = 1L;
// private String name; // name
// private String currentValue; // current_value
// private String increment; // increment
//
// public SysSequence() {
// super();
// }
//
// public SysSequence(String id){
// super(id);
// }
//
// @Length(min=1, max=128, message="name长度必须介于 1 和 128 之间")
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// @Length(min=1, max=11, message="current_value长度必须介于 1 和 11 之间")
// public String getCurrentValue() {
// return currentValue;
// }
//
// public void setCurrentValue(String currentValue) {
// this.currentValue = currentValue;
// }
//
// @Length(min=1, max=11, message="increment长度必须介于 1 和 11 之间")
// public String getIncrement() {
// return increment;
// }
//
// public void setIncrement(String increment) {
// this.increment = increment;
// }
//
// }
//
// Path: src/main/java/com/zlwh/hands/admin/modules/sys/dao/SysSequenceDao.java
// @MyBatisDao
// public interface SysSequenceDao extends CrudDao<SysSequence> {
//
// String getNextVal(SysSequence sysSequence);
//
// String getCurrentVal(SysSequence sysSequence);
//
// }
|
import java.util.List;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.service.CrudService;
import com.zlwh.hands.admin.modules.sys.entity.SysSequence;
import com.zlwh.hands.admin.modules.sys.dao.SysSequenceDao;
|
/**
* Copyright © 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
*/
package com.zlwh.hands.admin.modules.sys.service;
/**
* 数据库序列Service
* @author yuanjifeng
* @version 2016-06-07
*/
@Service
@Transactional(readOnly = true)
|
// Path: src/main/java/com/zlwh/hands/admin/modules/sys/entity/SysSequence.java
// public class SysSequence extends DataEntity<SysSequence> {
//
// private static final long serialVersionUID = 1L;
// private String name; // name
// private String currentValue; // current_value
// private String increment; // increment
//
// public SysSequence() {
// super();
// }
//
// public SysSequence(String id){
// super(id);
// }
//
// @Length(min=1, max=128, message="name长度必须介于 1 和 128 之间")
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// @Length(min=1, max=11, message="current_value长度必须介于 1 和 11 之间")
// public String getCurrentValue() {
// return currentValue;
// }
//
// public void setCurrentValue(String currentValue) {
// this.currentValue = currentValue;
// }
//
// @Length(min=1, max=11, message="increment长度必须介于 1 和 11 之间")
// public String getIncrement() {
// return increment;
// }
//
// public void setIncrement(String increment) {
// this.increment = increment;
// }
//
// }
//
// Path: src/main/java/com/zlwh/hands/admin/modules/sys/dao/SysSequenceDao.java
// @MyBatisDao
// public interface SysSequenceDao extends CrudDao<SysSequence> {
//
// String getNextVal(SysSequence sysSequence);
//
// String getCurrentVal(SysSequence sysSequence);
//
// }
// Path: src/main/java/com/zlwh/hands/admin/modules/sys/service/SysSequenceService.java
import java.util.List;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.service.CrudService;
import com.zlwh.hands.admin.modules.sys.entity.SysSequence;
import com.zlwh.hands.admin.modules.sys.dao.SysSequenceDao;
/**
* Copyright © 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
*/
package com.zlwh.hands.admin.modules.sys.service;
/**
* 数据库序列Service
* @author yuanjifeng
* @version 2016-06-07
*/
@Service
@Transactional(readOnly = true)
|
public class SysSequenceService extends CrudService<SysSequenceDao, SysSequence> {
|
javyuan/jeesite-api
|
src/main/java/com/zlwh/hands/api/common/utils/SequenceUtils.java
|
// Path: src/main/java/com/zlwh/hands/admin/modules/sys/service/SysSequenceService.java
// @Service
// @Transactional(readOnly = true)
// public class SysSequenceService extends CrudService<SysSequenceDao, SysSequence> {
//
// private static final String DEFAULT_NAME = "default";
//
// public SysSequence get(String id) {
// return super.get(id);
// }
//
// public List<SysSequence> findList(SysSequence sysSequence) {
// return super.findList(sysSequence);
// }
//
// public Page<SysSequence> findPage(Page<SysSequence> page, SysSequence sysSequence) {
// return super.findPage(page, sysSequence);
// }
//
// @Transactional(readOnly = false)
// public void save(SysSequence sysSequence) {
// super.save(sysSequence);
// }
//
// @Transactional(readOnly = false)
// public void delete(SysSequence sysSequence) {
// super.delete(sysSequence);
// }
//
// public String getNextVal(String name) {
// SysSequence sysSequence = new SysSequence();
// sysSequence.setName(name);
// return dao.getNextVal(sysSequence);
// }
//
// public String getNextVal() {
// return getNextVal(DEFAULT_NAME);
// }
//
// public String getCurrentVal(String name){
// SysSequence sysSequence = new SysSequence();
// sysSequence.setName(name);
// return dao.getCurrentVal(sysSequence);
// }
//
// public String getCurrentVal(){
// return getCurrentVal(DEFAULT_NAME);
// }
// }
|
import com.thinkgem.jeesite.common.utils.SpringContextHolder;
import com.zlwh.hands.admin.modules.sys.service.SysSequenceService;
|
package com.zlwh.hands.api.common.utils;
/**
* 序列工具类
* @author yuanjifeng
*
*/
public class SequenceUtils {
/**
* 获取默认序列的当前值
*/
public static String getCurrentVal(){
|
// Path: src/main/java/com/zlwh/hands/admin/modules/sys/service/SysSequenceService.java
// @Service
// @Transactional(readOnly = true)
// public class SysSequenceService extends CrudService<SysSequenceDao, SysSequence> {
//
// private static final String DEFAULT_NAME = "default";
//
// public SysSequence get(String id) {
// return super.get(id);
// }
//
// public List<SysSequence> findList(SysSequence sysSequence) {
// return super.findList(sysSequence);
// }
//
// public Page<SysSequence> findPage(Page<SysSequence> page, SysSequence sysSequence) {
// return super.findPage(page, sysSequence);
// }
//
// @Transactional(readOnly = false)
// public void save(SysSequence sysSequence) {
// super.save(sysSequence);
// }
//
// @Transactional(readOnly = false)
// public void delete(SysSequence sysSequence) {
// super.delete(sysSequence);
// }
//
// public String getNextVal(String name) {
// SysSequence sysSequence = new SysSequence();
// sysSequence.setName(name);
// return dao.getNextVal(sysSequence);
// }
//
// public String getNextVal() {
// return getNextVal(DEFAULT_NAME);
// }
//
// public String getCurrentVal(String name){
// SysSequence sysSequence = new SysSequence();
// sysSequence.setName(name);
// return dao.getCurrentVal(sysSequence);
// }
//
// public String getCurrentVal(){
// return getCurrentVal(DEFAULT_NAME);
// }
// }
// Path: src/main/java/com/zlwh/hands/api/common/utils/SequenceUtils.java
import com.thinkgem.jeesite.common.utils.SpringContextHolder;
import com.zlwh.hands.admin.modules.sys.service.SysSequenceService;
package com.zlwh.hands.api.common.utils;
/**
* 序列工具类
* @author yuanjifeng
*
*/
public class SequenceUtils {
/**
* 获取默认序列的当前值
*/
public static String getCurrentVal(){
|
SysSequenceService service = SpringContextHolder.getBean(SysSequenceService.class);
|
Steppschuh/Java-Markdown-Generator
|
Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/DummyObject.java
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/table/TableRow.java
// public class TableRow<T extends Object> extends MarkdownElement {
//
// private List<T> columns;
//
// public TableRow() {
// this.columns = new ArrayList<>();
// }
//
// public TableRow(List<T> columns) {
// this.columns = columns;
// }
//
// @Override
// public String serialize() throws MarkdownSerializationException {
// StringBuilder sb = new StringBuilder();
// for (Object item : columns) {
// if (item == null) {
// throw new MarkdownSerializationException("Column is null");
// }
// if (item.toString().contains(Table.SEPARATOR)) {
// throw new MarkdownSerializationException("Column contains seperator char \"" + Table.SEPARATOR + "\"");
// }
// sb.append(Table.SEPARATOR);
// sb.append(StringUtil.surroundValueWith(item.toString(), " "));
// if (columns.indexOf(item) == columns.size() - 1) {
// sb.append(Table.SEPARATOR);
// }
// }
// return sb.toString();
// }
//
// public List<T> getColumns() {
// return columns;
// }
//
// public void setColumns(List<T> columns) {
// this.columns = columns;
// invalidateSerialized();
// }
//
// }
|
import net.steppschuh.markdowngenerator.table.TableRow;
import java.util.ArrayList;
import java.util.Arrays;
|
package net.steppschuh.markdowngenerator;
/**
* Created by steppschuh on 15/12/2016.
*/
public class DummyObject implements MarkdownSerializable {
private Object foo;
private String bar;
private int baz;
public DummyObject() {
this.foo = true;
this.bar = "qux";
this.baz = 1337;
}
public DummyObject(Object foo, String bar, int baz) {
this.foo = foo;
this.bar = bar;
this.baz = baz;
}
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/table/TableRow.java
// public class TableRow<T extends Object> extends MarkdownElement {
//
// private List<T> columns;
//
// public TableRow() {
// this.columns = new ArrayList<>();
// }
//
// public TableRow(List<T> columns) {
// this.columns = columns;
// }
//
// @Override
// public String serialize() throws MarkdownSerializationException {
// StringBuilder sb = new StringBuilder();
// for (Object item : columns) {
// if (item == null) {
// throw new MarkdownSerializationException("Column is null");
// }
// if (item.toString().contains(Table.SEPARATOR)) {
// throw new MarkdownSerializationException("Column contains seperator char \"" + Table.SEPARATOR + "\"");
// }
// sb.append(Table.SEPARATOR);
// sb.append(StringUtil.surroundValueWith(item.toString(), " "));
// if (columns.indexOf(item) == columns.size() - 1) {
// sb.append(Table.SEPARATOR);
// }
// }
// return sb.toString();
// }
//
// public List<T> getColumns() {
// return columns;
// }
//
// public void setColumns(List<T> columns) {
// this.columns = columns;
// invalidateSerialized();
// }
//
// }
// Path: Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/DummyObject.java
import net.steppschuh.markdowngenerator.table.TableRow;
import java.util.ArrayList;
import java.util.Arrays;
package net.steppschuh.markdowngenerator;
/**
* Created by steppschuh on 15/12/2016.
*/
public class DummyObject implements MarkdownSerializable {
private Object foo;
private String bar;
private int baz;
public DummyObject() {
this.foo = true;
this.bar = "qux";
this.baz = 1337;
}
public DummyObject(Object foo, String bar, int baz) {
this.foo = foo;
this.bar = bar;
this.baz = baz;
}
|
public TableRow toMarkdownTableRow() {
|
Steppschuh/Java-Markdown-Generator
|
Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/table/Table.java
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownElement.java
// public abstract class MarkdownElement implements MarkdownSerializable {
//
// private String serialized;
//
// /**
// * Attempts to generate a String representing this markdown element.
// *
// * @return Markdown as String
// * @throws MarkdownSerializationException If unable to generate a markdown String
// */
// public abstract String serialize() throws MarkdownSerializationException;
//
// /**
// * Returns the result of {@link MarkdownElement#getSerialized()} or the specified fallback if a
// * {@link MarkdownSerializationException} occurred.
// *
// * @param fallback String to return if serialization fails
// * @return Markdown as String or specified fallback
// */
// public String getSerialized(String fallback) {
// try {
// return getSerialized();
// } catch (MarkdownSerializationException e) {
// return fallback;
// }
// }
//
// /**
// * Calls {@link MarkdownElement#serialize()} or directly returns its last result from {@link
// * MarkdownElement#serialized}.
// *
// * @return Markdown as String
// * @throws MarkdownSerializationException If unable to generate a markdown String
// */
// public String getSerialized() throws MarkdownSerializationException {
// if (serialized == null) {
// serialized = serialize();
// }
// return serialized;
// }
//
// public void setSerialized(String serialized) {
// this.serialized = serialized;
// }
//
// /**
// * Sets {@link MarkdownElement#serialized} to null. The next call to {@link
// * MarkdownElement#getSerialized()} fill invoke a fresh serialization.
// */
// public void invalidateSerialized() {
// setSerialized(null);
// }
//
// @Override
// public MarkdownElement toMarkdownElement() throws MarkdownSerializationException {
// return this;
// }
//
// @Override
// public String toString() {
// return getSerialized(this.getClass().getSimpleName());
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/util/StringUtil.java
// public abstract class StringUtil {
//
// public static String fillUpAligned(String value, String fill, int length, int alignment) {
// switch (alignment) {
// case Table.ALIGN_RIGHT: {
// return fillUpRightAligned(value, fill, length);
// }
// case Table.ALIGN_CENTER: {
// return fillUpCenterAligned(value, fill, length);
// }
// default: {
// return fillUpLeftAligned(value, fill, length);
// }
// }
// }
//
// public static String fillUpLeftAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// while (value.length() < length) {
// value += fill;
// }
// return value;
// }
//
// public static String fillUpRightAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// while (value.length() < length) {
// value = fill + value;
// }
// return value;
// }
//
// public static String fillUpCenterAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// boolean left = true;
// while (value.length() < length) {
// if (left) {
// value = fillUpLeftAligned(value, fill, value.length() + 1);
// } else {
// value = fillUpRightAligned(value, fill, value.length() + 1);
// }
// left = !left;
// }
// return value;
// }
//
// public static String surroundValueWith(String value, String surrounding) {
// return surrounding + value + surrounding;
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/util/StringUtil.java
// public static String surroundValueWith(String value, String surrounding) {
// return surrounding + value + surrounding;
// }
|
import net.steppschuh.markdowngenerator.MarkdownElement;
import net.steppschuh.markdowngenerator.util.StringUtil;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static net.steppschuh.markdowngenerator.util.StringUtil.surroundValueWith;
|
public Table(List<TableRow> rows, List<Integer> alignments) {
this(rows);
this.alignments = alignments;
}
@Override
public String serialize() {
Map<Integer, Integer> columnWidths = getColumnWidths(rows, minimumColumnWidth);
StringBuilder sb = new StringBuilder();
String headerSeparator = generateHeaderSeparator(columnWidths, alignments);
boolean headerSeperatorAdded = !firstRowIsHeader;
if (!firstRowIsHeader) {
sb.append(headerSeparator).append(System.lineSeparator());
}
for (TableRow row : rows) {
for (int columnIndex = 0; columnIndex < columnWidths.size(); columnIndex++) {
sb.append(SEPARATOR);
String value = "";
if (row.getColumns().size() > columnIndex) {
Object valueObject = row.getColumns().get(columnIndex);
if (valueObject != null) {
value = valueObject.toString();
}
}
if (value.equals(trimmingIndicator)) {
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownElement.java
// public abstract class MarkdownElement implements MarkdownSerializable {
//
// private String serialized;
//
// /**
// * Attempts to generate a String representing this markdown element.
// *
// * @return Markdown as String
// * @throws MarkdownSerializationException If unable to generate a markdown String
// */
// public abstract String serialize() throws MarkdownSerializationException;
//
// /**
// * Returns the result of {@link MarkdownElement#getSerialized()} or the specified fallback if a
// * {@link MarkdownSerializationException} occurred.
// *
// * @param fallback String to return if serialization fails
// * @return Markdown as String or specified fallback
// */
// public String getSerialized(String fallback) {
// try {
// return getSerialized();
// } catch (MarkdownSerializationException e) {
// return fallback;
// }
// }
//
// /**
// * Calls {@link MarkdownElement#serialize()} or directly returns its last result from {@link
// * MarkdownElement#serialized}.
// *
// * @return Markdown as String
// * @throws MarkdownSerializationException If unable to generate a markdown String
// */
// public String getSerialized() throws MarkdownSerializationException {
// if (serialized == null) {
// serialized = serialize();
// }
// return serialized;
// }
//
// public void setSerialized(String serialized) {
// this.serialized = serialized;
// }
//
// /**
// * Sets {@link MarkdownElement#serialized} to null. The next call to {@link
// * MarkdownElement#getSerialized()} fill invoke a fresh serialization.
// */
// public void invalidateSerialized() {
// setSerialized(null);
// }
//
// @Override
// public MarkdownElement toMarkdownElement() throws MarkdownSerializationException {
// return this;
// }
//
// @Override
// public String toString() {
// return getSerialized(this.getClass().getSimpleName());
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/util/StringUtil.java
// public abstract class StringUtil {
//
// public static String fillUpAligned(String value, String fill, int length, int alignment) {
// switch (alignment) {
// case Table.ALIGN_RIGHT: {
// return fillUpRightAligned(value, fill, length);
// }
// case Table.ALIGN_CENTER: {
// return fillUpCenterAligned(value, fill, length);
// }
// default: {
// return fillUpLeftAligned(value, fill, length);
// }
// }
// }
//
// public static String fillUpLeftAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// while (value.length() < length) {
// value += fill;
// }
// return value;
// }
//
// public static String fillUpRightAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// while (value.length() < length) {
// value = fill + value;
// }
// return value;
// }
//
// public static String fillUpCenterAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// boolean left = true;
// while (value.length() < length) {
// if (left) {
// value = fillUpLeftAligned(value, fill, value.length() + 1);
// } else {
// value = fillUpRightAligned(value, fill, value.length() + 1);
// }
// left = !left;
// }
// return value;
// }
//
// public static String surroundValueWith(String value, String surrounding) {
// return surrounding + value + surrounding;
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/util/StringUtil.java
// public static String surroundValueWith(String value, String surrounding) {
// return surrounding + value + surrounding;
// }
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/table/Table.java
import net.steppschuh.markdowngenerator.MarkdownElement;
import net.steppschuh.markdowngenerator.util.StringUtil;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static net.steppschuh.markdowngenerator.util.StringUtil.surroundValueWith;
public Table(List<TableRow> rows, List<Integer> alignments) {
this(rows);
this.alignments = alignments;
}
@Override
public String serialize() {
Map<Integer, Integer> columnWidths = getColumnWidths(rows, minimumColumnWidth);
StringBuilder sb = new StringBuilder();
String headerSeparator = generateHeaderSeparator(columnWidths, alignments);
boolean headerSeperatorAdded = !firstRowIsHeader;
if (!firstRowIsHeader) {
sb.append(headerSeparator).append(System.lineSeparator());
}
for (TableRow row : rows) {
for (int columnIndex = 0; columnIndex < columnWidths.size(); columnIndex++) {
sb.append(SEPARATOR);
String value = "";
if (row.getColumns().size() > columnIndex) {
Object valueObject = row.getColumns().get(columnIndex);
if (valueObject != null) {
value = valueObject.toString();
}
}
if (value.equals(trimmingIndicator)) {
|
value = StringUtil.fillUpLeftAligned(value, trimmingIndicator, columnWidths.get(columnIndex));
|
Steppschuh/Java-Markdown-Generator
|
Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/table/Table.java
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownElement.java
// public abstract class MarkdownElement implements MarkdownSerializable {
//
// private String serialized;
//
// /**
// * Attempts to generate a String representing this markdown element.
// *
// * @return Markdown as String
// * @throws MarkdownSerializationException If unable to generate a markdown String
// */
// public abstract String serialize() throws MarkdownSerializationException;
//
// /**
// * Returns the result of {@link MarkdownElement#getSerialized()} or the specified fallback if a
// * {@link MarkdownSerializationException} occurred.
// *
// * @param fallback String to return if serialization fails
// * @return Markdown as String or specified fallback
// */
// public String getSerialized(String fallback) {
// try {
// return getSerialized();
// } catch (MarkdownSerializationException e) {
// return fallback;
// }
// }
//
// /**
// * Calls {@link MarkdownElement#serialize()} or directly returns its last result from {@link
// * MarkdownElement#serialized}.
// *
// * @return Markdown as String
// * @throws MarkdownSerializationException If unable to generate a markdown String
// */
// public String getSerialized() throws MarkdownSerializationException {
// if (serialized == null) {
// serialized = serialize();
// }
// return serialized;
// }
//
// public void setSerialized(String serialized) {
// this.serialized = serialized;
// }
//
// /**
// * Sets {@link MarkdownElement#serialized} to null. The next call to {@link
// * MarkdownElement#getSerialized()} fill invoke a fresh serialization.
// */
// public void invalidateSerialized() {
// setSerialized(null);
// }
//
// @Override
// public MarkdownElement toMarkdownElement() throws MarkdownSerializationException {
// return this;
// }
//
// @Override
// public String toString() {
// return getSerialized(this.getClass().getSimpleName());
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/util/StringUtil.java
// public abstract class StringUtil {
//
// public static String fillUpAligned(String value, String fill, int length, int alignment) {
// switch (alignment) {
// case Table.ALIGN_RIGHT: {
// return fillUpRightAligned(value, fill, length);
// }
// case Table.ALIGN_CENTER: {
// return fillUpCenterAligned(value, fill, length);
// }
// default: {
// return fillUpLeftAligned(value, fill, length);
// }
// }
// }
//
// public static String fillUpLeftAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// while (value.length() < length) {
// value += fill;
// }
// return value;
// }
//
// public static String fillUpRightAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// while (value.length() < length) {
// value = fill + value;
// }
// return value;
// }
//
// public static String fillUpCenterAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// boolean left = true;
// while (value.length() < length) {
// if (left) {
// value = fillUpLeftAligned(value, fill, value.length() + 1);
// } else {
// value = fillUpRightAligned(value, fill, value.length() + 1);
// }
// left = !left;
// }
// return value;
// }
//
// public static String surroundValueWith(String value, String surrounding) {
// return surrounding + value + surrounding;
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/util/StringUtil.java
// public static String surroundValueWith(String value, String surrounding) {
// return surrounding + value + surrounding;
// }
|
import net.steppschuh.markdowngenerator.MarkdownElement;
import net.steppschuh.markdowngenerator.util.StringUtil;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static net.steppschuh.markdowngenerator.util.StringUtil.surroundValueWith;
|
this(rows);
this.alignments = alignments;
}
@Override
public String serialize() {
Map<Integer, Integer> columnWidths = getColumnWidths(rows, minimumColumnWidth);
StringBuilder sb = new StringBuilder();
String headerSeparator = generateHeaderSeparator(columnWidths, alignments);
boolean headerSeperatorAdded = !firstRowIsHeader;
if (!firstRowIsHeader) {
sb.append(headerSeparator).append(System.lineSeparator());
}
for (TableRow row : rows) {
for (int columnIndex = 0; columnIndex < columnWidths.size(); columnIndex++) {
sb.append(SEPARATOR);
String value = "";
if (row.getColumns().size() > columnIndex) {
Object valueObject = row.getColumns().get(columnIndex);
if (valueObject != null) {
value = valueObject.toString();
}
}
if (value.equals(trimmingIndicator)) {
value = StringUtil.fillUpLeftAligned(value, trimmingIndicator, columnWidths.get(columnIndex));
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownElement.java
// public abstract class MarkdownElement implements MarkdownSerializable {
//
// private String serialized;
//
// /**
// * Attempts to generate a String representing this markdown element.
// *
// * @return Markdown as String
// * @throws MarkdownSerializationException If unable to generate a markdown String
// */
// public abstract String serialize() throws MarkdownSerializationException;
//
// /**
// * Returns the result of {@link MarkdownElement#getSerialized()} or the specified fallback if a
// * {@link MarkdownSerializationException} occurred.
// *
// * @param fallback String to return if serialization fails
// * @return Markdown as String or specified fallback
// */
// public String getSerialized(String fallback) {
// try {
// return getSerialized();
// } catch (MarkdownSerializationException e) {
// return fallback;
// }
// }
//
// /**
// * Calls {@link MarkdownElement#serialize()} or directly returns its last result from {@link
// * MarkdownElement#serialized}.
// *
// * @return Markdown as String
// * @throws MarkdownSerializationException If unable to generate a markdown String
// */
// public String getSerialized() throws MarkdownSerializationException {
// if (serialized == null) {
// serialized = serialize();
// }
// return serialized;
// }
//
// public void setSerialized(String serialized) {
// this.serialized = serialized;
// }
//
// /**
// * Sets {@link MarkdownElement#serialized} to null. The next call to {@link
// * MarkdownElement#getSerialized()} fill invoke a fresh serialization.
// */
// public void invalidateSerialized() {
// setSerialized(null);
// }
//
// @Override
// public MarkdownElement toMarkdownElement() throws MarkdownSerializationException {
// return this;
// }
//
// @Override
// public String toString() {
// return getSerialized(this.getClass().getSimpleName());
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/util/StringUtil.java
// public abstract class StringUtil {
//
// public static String fillUpAligned(String value, String fill, int length, int alignment) {
// switch (alignment) {
// case Table.ALIGN_RIGHT: {
// return fillUpRightAligned(value, fill, length);
// }
// case Table.ALIGN_CENTER: {
// return fillUpCenterAligned(value, fill, length);
// }
// default: {
// return fillUpLeftAligned(value, fill, length);
// }
// }
// }
//
// public static String fillUpLeftAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// while (value.length() < length) {
// value += fill;
// }
// return value;
// }
//
// public static String fillUpRightAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// while (value.length() < length) {
// value = fill + value;
// }
// return value;
// }
//
// public static String fillUpCenterAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// boolean left = true;
// while (value.length() < length) {
// if (left) {
// value = fillUpLeftAligned(value, fill, value.length() + 1);
// } else {
// value = fillUpRightAligned(value, fill, value.length() + 1);
// }
// left = !left;
// }
// return value;
// }
//
// public static String surroundValueWith(String value, String surrounding) {
// return surrounding + value + surrounding;
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/util/StringUtil.java
// public static String surroundValueWith(String value, String surrounding) {
// return surrounding + value + surrounding;
// }
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/table/Table.java
import net.steppschuh.markdowngenerator.MarkdownElement;
import net.steppschuh.markdowngenerator.util.StringUtil;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static net.steppschuh.markdowngenerator.util.StringUtil.surroundValueWith;
this(rows);
this.alignments = alignments;
}
@Override
public String serialize() {
Map<Integer, Integer> columnWidths = getColumnWidths(rows, minimumColumnWidth);
StringBuilder sb = new StringBuilder();
String headerSeparator = generateHeaderSeparator(columnWidths, alignments);
boolean headerSeperatorAdded = !firstRowIsHeader;
if (!firstRowIsHeader) {
sb.append(headerSeparator).append(System.lineSeparator());
}
for (TableRow row : rows) {
for (int columnIndex = 0; columnIndex < columnWidths.size(); columnIndex++) {
sb.append(SEPARATOR);
String value = "";
if (row.getColumns().size() > columnIndex) {
Object valueObject = row.getColumns().get(columnIndex);
if (valueObject != null) {
value = valueObject.toString();
}
}
if (value.equals(trimmingIndicator)) {
value = StringUtil.fillUpLeftAligned(value, trimmingIndicator, columnWidths.get(columnIndex));
|
value = surroundValueWith(value, WHITESPACE);
|
Steppschuh/Java-Markdown-Generator
|
Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/text/QuoteTest.java
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/quote/Quote.java
// public class Quote extends Text {
//
// public Quote(Object value) {
// super(value);
// }
//
// @Override
// public String serialize() throws MarkdownSerializationException {
// if (value == null) {
// throw new MarkdownSerializationException("Value is null");
// }
// StringBuilder sb = new StringBuilder();
// String lines[] = value.toString().split("\\r?\\n");
// for (int lineIndex = 0; lineIndex < lines.length; lineIndex++) {
// sb.append("> ").append(lines[lineIndex]);
// if (lineIndex < lines.length - 1) {
// sb.append(System.lineSeparator());
// }
// }
// return sb.toString();
// }
//
// }
|
import net.steppschuh.markdowngenerator.text.quote.Quote;
import org.junit.Test;
|
package net.steppschuh.markdowngenerator.text;
/**
* Created by steppschuh on 15/12/2016.
*/
public class QuoteTest {
@Test
public void example1() throws Exception {
String quote = "I am a blockquote.\nI may contain multiple lines.";
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/quote/Quote.java
// public class Quote extends Text {
//
// public Quote(Object value) {
// super(value);
// }
//
// @Override
// public String serialize() throws MarkdownSerializationException {
// if (value == null) {
// throw new MarkdownSerializationException("Value is null");
// }
// StringBuilder sb = new StringBuilder();
// String lines[] = value.toString().split("\\r?\\n");
// for (int lineIndex = 0; lineIndex < lines.length; lineIndex++) {
// sb.append("> ").append(lines[lineIndex]);
// if (lineIndex < lines.length - 1) {
// sb.append(System.lineSeparator());
// }
// }
// return sb.toString();
// }
//
// }
// Path: Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/text/QuoteTest.java
import net.steppschuh.markdowngenerator.text.quote.Quote;
import org.junit.Test;
package net.steppschuh.markdowngenerator.text;
/**
* Created by steppschuh on 15/12/2016.
*/
public class QuoteTest {
@Test
public void example1() throws Exception {
String quote = "I am a blockquote.\nI may contain multiple lines.";
|
Text text = new Quote(quote);
|
Steppschuh/Java-Markdown-Generator
|
Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/text/HeadingTest.java
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/heading/Heading.java
// public class Heading extends Text {
//
// public static final int MINIMUM_LEVEL = 1;
// public static final int MAXIMUM_LEVEL = 6;
//
// public static final char UNDERLINE_CHAR_1 = '=';
// public static final char UNDERLINE_CHAR_2 = '-';
//
// private int level;
// boolean underlineStyle = true;
//
// public Heading(Object value) {
// super(value);
// this.level = MINIMUM_LEVEL;
// }
//
// public Heading(Object value, int level) {
// super(value);
// this.level = level;
// trimLevel();
// }
//
// @Override
// public String getPredecessor() {
// if (underlineStyle && level < 3) {
// return "";
// }
// return StringUtil.fillUpRightAligned("", "#", level) + " ";
// }
//
// @Override
// public String getSuccessor() {
// if (underlineStyle && level < 3) {
// char underlineChar = (level == 1) ? UNDERLINE_CHAR_1 : UNDERLINE_CHAR_2;
// return System.lineSeparator() + StringUtil.fillUpLeftAligned("", "" + underlineChar, value.toString().length());
// }
// return "";
// }
//
// private void trimLevel() {
// level = Math.min(MAXIMUM_LEVEL, Math.max(MINIMUM_LEVEL, level));
// }
//
// public int getLevel() {
// return level;
// }
//
// public void setLevel(int level) {
// this.level = level;
// trimLevel();
// invalidateSerialized();
// }
//
// public boolean isUnderlineStyle() {
// return underlineStyle;
// }
//
// public void setUnderlineStyle(boolean underlineStyle) {
// this.underlineStyle = underlineStyle;
// invalidateSerialized();
// }
//
// }
|
import net.steppschuh.markdowngenerator.text.heading.Heading;
import org.junit.Test;
|
package net.steppschuh.markdowngenerator.text;
/**
* Created by steppschuh on 16/12/2016.
*/
public class HeadingTest {
@Test
public void example1() throws Exception {
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/heading/Heading.java
// public class Heading extends Text {
//
// public static final int MINIMUM_LEVEL = 1;
// public static final int MAXIMUM_LEVEL = 6;
//
// public static final char UNDERLINE_CHAR_1 = '=';
// public static final char UNDERLINE_CHAR_2 = '-';
//
// private int level;
// boolean underlineStyle = true;
//
// public Heading(Object value) {
// super(value);
// this.level = MINIMUM_LEVEL;
// }
//
// public Heading(Object value, int level) {
// super(value);
// this.level = level;
// trimLevel();
// }
//
// @Override
// public String getPredecessor() {
// if (underlineStyle && level < 3) {
// return "";
// }
// return StringUtil.fillUpRightAligned("", "#", level) + " ";
// }
//
// @Override
// public String getSuccessor() {
// if (underlineStyle && level < 3) {
// char underlineChar = (level == 1) ? UNDERLINE_CHAR_1 : UNDERLINE_CHAR_2;
// return System.lineSeparator() + StringUtil.fillUpLeftAligned("", "" + underlineChar, value.toString().length());
// }
// return "";
// }
//
// private void trimLevel() {
// level = Math.min(MAXIMUM_LEVEL, Math.max(MINIMUM_LEVEL, level));
// }
//
// public int getLevel() {
// return level;
// }
//
// public void setLevel(int level) {
// this.level = level;
// trimLevel();
// invalidateSerialized();
// }
//
// public boolean isUnderlineStyle() {
// return underlineStyle;
// }
//
// public void setUnderlineStyle(boolean underlineStyle) {
// this.underlineStyle = underlineStyle;
// invalidateSerialized();
// }
//
// }
// Path: Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/text/HeadingTest.java
import net.steppschuh.markdowngenerator.text.heading.Heading;
import org.junit.Test;
package net.steppschuh.markdowngenerator.text;
/**
* Created by steppschuh on 16/12/2016.
*/
public class HeadingTest {
@Test
public void example1() throws Exception {
|
Text text = new Heading("I am a heading");
|
Steppschuh/Java-Markdown-Generator
|
Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/list/UnorderedList.java
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownElement.java
// public abstract class MarkdownElement implements MarkdownSerializable {
//
// private String serialized;
//
// /**
// * Attempts to generate a String representing this markdown element.
// *
// * @return Markdown as String
// * @throws MarkdownSerializationException If unable to generate a markdown String
// */
// public abstract String serialize() throws MarkdownSerializationException;
//
// /**
// * Returns the result of {@link MarkdownElement#getSerialized()} or the specified fallback if a
// * {@link MarkdownSerializationException} occurred.
// *
// * @param fallback String to return if serialization fails
// * @return Markdown as String or specified fallback
// */
// public String getSerialized(String fallback) {
// try {
// return getSerialized();
// } catch (MarkdownSerializationException e) {
// return fallback;
// }
// }
//
// /**
// * Calls {@link MarkdownElement#serialize()} or directly returns its last result from {@link
// * MarkdownElement#serialized}.
// *
// * @return Markdown as String
// * @throws MarkdownSerializationException If unable to generate a markdown String
// */
// public String getSerialized() throws MarkdownSerializationException {
// if (serialized == null) {
// serialized = serialize();
// }
// return serialized;
// }
//
// public void setSerialized(String serialized) {
// this.serialized = serialized;
// }
//
// /**
// * Sets {@link MarkdownElement#serialized} to null. The next call to {@link
// * MarkdownElement#getSerialized()} fill invoke a fresh serialization.
// */
// public void invalidateSerialized() {
// setSerialized(null);
// }
//
// @Override
// public MarkdownElement toMarkdownElement() throws MarkdownSerializationException {
// return this;
// }
//
// @Override
// public String toString() {
// return getSerialized(this.getClass().getSimpleName());
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownSerializationException.java
// public class MarkdownSerializationException extends Exception {
//
// public MarkdownSerializationException() {
// super();
// }
//
// public MarkdownSerializationException(String s) {
// super(s);
// }
//
// public MarkdownSerializationException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public MarkdownSerializationException(Throwable throwable) {
// super(throwable);
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/util/StringUtil.java
// public abstract class StringUtil {
//
// public static String fillUpAligned(String value, String fill, int length, int alignment) {
// switch (alignment) {
// case Table.ALIGN_RIGHT: {
// return fillUpRightAligned(value, fill, length);
// }
// case Table.ALIGN_CENTER: {
// return fillUpCenterAligned(value, fill, length);
// }
// default: {
// return fillUpLeftAligned(value, fill, length);
// }
// }
// }
//
// public static String fillUpLeftAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// while (value.length() < length) {
// value += fill;
// }
// return value;
// }
//
// public static String fillUpRightAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// while (value.length() < length) {
// value = fill + value;
// }
// return value;
// }
//
// public static String fillUpCenterAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// boolean left = true;
// while (value.length() < length) {
// if (left) {
// value = fillUpLeftAligned(value, fill, value.length() + 1);
// } else {
// value = fillUpRightAligned(value, fill, value.length() + 1);
// }
// left = !left;
// }
// return value;
// }
//
// public static String surroundValueWith(String value, String surrounding) {
// return surrounding + value + surrounding;
// }
//
// }
|
import net.steppschuh.markdowngenerator.MarkdownElement;
import net.steppschuh.markdowngenerator.MarkdownSerializationException;
import net.steppschuh.markdowngenerator.util.StringUtil;
import java.util.ArrayList;
import java.util.List;
|
package net.steppschuh.markdowngenerator.list;
public class UnorderedList<T extends Object> extends MarkdownElement {
protected List<T> items;
protected int indentationLevel = 0;
public UnorderedList() {
this.items = new ArrayList<>();
}
public UnorderedList(List<T> items) {
this.items = items;
}
@Override
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownElement.java
// public abstract class MarkdownElement implements MarkdownSerializable {
//
// private String serialized;
//
// /**
// * Attempts to generate a String representing this markdown element.
// *
// * @return Markdown as String
// * @throws MarkdownSerializationException If unable to generate a markdown String
// */
// public abstract String serialize() throws MarkdownSerializationException;
//
// /**
// * Returns the result of {@link MarkdownElement#getSerialized()} or the specified fallback if a
// * {@link MarkdownSerializationException} occurred.
// *
// * @param fallback String to return if serialization fails
// * @return Markdown as String or specified fallback
// */
// public String getSerialized(String fallback) {
// try {
// return getSerialized();
// } catch (MarkdownSerializationException e) {
// return fallback;
// }
// }
//
// /**
// * Calls {@link MarkdownElement#serialize()} or directly returns its last result from {@link
// * MarkdownElement#serialized}.
// *
// * @return Markdown as String
// * @throws MarkdownSerializationException If unable to generate a markdown String
// */
// public String getSerialized() throws MarkdownSerializationException {
// if (serialized == null) {
// serialized = serialize();
// }
// return serialized;
// }
//
// public void setSerialized(String serialized) {
// this.serialized = serialized;
// }
//
// /**
// * Sets {@link MarkdownElement#serialized} to null. The next call to {@link
// * MarkdownElement#getSerialized()} fill invoke a fresh serialization.
// */
// public void invalidateSerialized() {
// setSerialized(null);
// }
//
// @Override
// public MarkdownElement toMarkdownElement() throws MarkdownSerializationException {
// return this;
// }
//
// @Override
// public String toString() {
// return getSerialized(this.getClass().getSimpleName());
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownSerializationException.java
// public class MarkdownSerializationException extends Exception {
//
// public MarkdownSerializationException() {
// super();
// }
//
// public MarkdownSerializationException(String s) {
// super(s);
// }
//
// public MarkdownSerializationException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public MarkdownSerializationException(Throwable throwable) {
// super(throwable);
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/util/StringUtil.java
// public abstract class StringUtil {
//
// public static String fillUpAligned(String value, String fill, int length, int alignment) {
// switch (alignment) {
// case Table.ALIGN_RIGHT: {
// return fillUpRightAligned(value, fill, length);
// }
// case Table.ALIGN_CENTER: {
// return fillUpCenterAligned(value, fill, length);
// }
// default: {
// return fillUpLeftAligned(value, fill, length);
// }
// }
// }
//
// public static String fillUpLeftAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// while (value.length() < length) {
// value += fill;
// }
// return value;
// }
//
// public static String fillUpRightAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// while (value.length() < length) {
// value = fill + value;
// }
// return value;
// }
//
// public static String fillUpCenterAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// boolean left = true;
// while (value.length() < length) {
// if (left) {
// value = fillUpLeftAligned(value, fill, value.length() + 1);
// } else {
// value = fillUpRightAligned(value, fill, value.length() + 1);
// }
// left = !left;
// }
// return value;
// }
//
// public static String surroundValueWith(String value, String surrounding) {
// return surrounding + value + surrounding;
// }
//
// }
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/list/UnorderedList.java
import net.steppschuh.markdowngenerator.MarkdownElement;
import net.steppschuh.markdowngenerator.MarkdownSerializationException;
import net.steppschuh.markdowngenerator.util.StringUtil;
import java.util.ArrayList;
import java.util.List;
package net.steppschuh.markdowngenerator.list;
public class UnorderedList<T extends Object> extends MarkdownElement {
protected List<T> items;
protected int indentationLevel = 0;
public UnorderedList() {
this.items = new ArrayList<>();
}
public UnorderedList(List<T> items) {
this.items = items;
}
@Override
|
public String serialize() throws MarkdownSerializationException {
|
Steppschuh/Java-Markdown-Generator
|
Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/list/UnorderedList.java
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownElement.java
// public abstract class MarkdownElement implements MarkdownSerializable {
//
// private String serialized;
//
// /**
// * Attempts to generate a String representing this markdown element.
// *
// * @return Markdown as String
// * @throws MarkdownSerializationException If unable to generate a markdown String
// */
// public abstract String serialize() throws MarkdownSerializationException;
//
// /**
// * Returns the result of {@link MarkdownElement#getSerialized()} or the specified fallback if a
// * {@link MarkdownSerializationException} occurred.
// *
// * @param fallback String to return if serialization fails
// * @return Markdown as String or specified fallback
// */
// public String getSerialized(String fallback) {
// try {
// return getSerialized();
// } catch (MarkdownSerializationException e) {
// return fallback;
// }
// }
//
// /**
// * Calls {@link MarkdownElement#serialize()} or directly returns its last result from {@link
// * MarkdownElement#serialized}.
// *
// * @return Markdown as String
// * @throws MarkdownSerializationException If unable to generate a markdown String
// */
// public String getSerialized() throws MarkdownSerializationException {
// if (serialized == null) {
// serialized = serialize();
// }
// return serialized;
// }
//
// public void setSerialized(String serialized) {
// this.serialized = serialized;
// }
//
// /**
// * Sets {@link MarkdownElement#serialized} to null. The next call to {@link
// * MarkdownElement#getSerialized()} fill invoke a fresh serialization.
// */
// public void invalidateSerialized() {
// setSerialized(null);
// }
//
// @Override
// public MarkdownElement toMarkdownElement() throws MarkdownSerializationException {
// return this;
// }
//
// @Override
// public String toString() {
// return getSerialized(this.getClass().getSimpleName());
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownSerializationException.java
// public class MarkdownSerializationException extends Exception {
//
// public MarkdownSerializationException() {
// super();
// }
//
// public MarkdownSerializationException(String s) {
// super(s);
// }
//
// public MarkdownSerializationException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public MarkdownSerializationException(Throwable throwable) {
// super(throwable);
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/util/StringUtil.java
// public abstract class StringUtil {
//
// public static String fillUpAligned(String value, String fill, int length, int alignment) {
// switch (alignment) {
// case Table.ALIGN_RIGHT: {
// return fillUpRightAligned(value, fill, length);
// }
// case Table.ALIGN_CENTER: {
// return fillUpCenterAligned(value, fill, length);
// }
// default: {
// return fillUpLeftAligned(value, fill, length);
// }
// }
// }
//
// public static String fillUpLeftAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// while (value.length() < length) {
// value += fill;
// }
// return value;
// }
//
// public static String fillUpRightAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// while (value.length() < length) {
// value = fill + value;
// }
// return value;
// }
//
// public static String fillUpCenterAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// boolean left = true;
// while (value.length() < length) {
// if (left) {
// value = fillUpLeftAligned(value, fill, value.length() + 1);
// } else {
// value = fillUpRightAligned(value, fill, value.length() + 1);
// }
// left = !left;
// }
// return value;
// }
//
// public static String surroundValueWith(String value, String surrounding) {
// return surrounding + value + surrounding;
// }
//
// }
|
import net.steppschuh.markdowngenerator.MarkdownElement;
import net.steppschuh.markdowngenerator.MarkdownSerializationException;
import net.steppschuh.markdowngenerator.util.StringUtil;
import java.util.ArrayList;
import java.util.List;
|
package net.steppschuh.markdowngenerator.list;
public class UnorderedList<T extends Object> extends MarkdownElement {
protected List<T> items;
protected int indentationLevel = 0;
public UnorderedList() {
this.items = new ArrayList<>();
}
public UnorderedList(List<T> items) {
this.items = items;
}
@Override
public String serialize() throws MarkdownSerializationException {
StringBuilder sb = new StringBuilder();
for (int itemIndex = 0; itemIndex < items.size(); itemIndex++) {
T item = items.get(itemIndex);
if (itemIndex > 0) {
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownElement.java
// public abstract class MarkdownElement implements MarkdownSerializable {
//
// private String serialized;
//
// /**
// * Attempts to generate a String representing this markdown element.
// *
// * @return Markdown as String
// * @throws MarkdownSerializationException If unable to generate a markdown String
// */
// public abstract String serialize() throws MarkdownSerializationException;
//
// /**
// * Returns the result of {@link MarkdownElement#getSerialized()} or the specified fallback if a
// * {@link MarkdownSerializationException} occurred.
// *
// * @param fallback String to return if serialization fails
// * @return Markdown as String or specified fallback
// */
// public String getSerialized(String fallback) {
// try {
// return getSerialized();
// } catch (MarkdownSerializationException e) {
// return fallback;
// }
// }
//
// /**
// * Calls {@link MarkdownElement#serialize()} or directly returns its last result from {@link
// * MarkdownElement#serialized}.
// *
// * @return Markdown as String
// * @throws MarkdownSerializationException If unable to generate a markdown String
// */
// public String getSerialized() throws MarkdownSerializationException {
// if (serialized == null) {
// serialized = serialize();
// }
// return serialized;
// }
//
// public void setSerialized(String serialized) {
// this.serialized = serialized;
// }
//
// /**
// * Sets {@link MarkdownElement#serialized} to null. The next call to {@link
// * MarkdownElement#getSerialized()} fill invoke a fresh serialization.
// */
// public void invalidateSerialized() {
// setSerialized(null);
// }
//
// @Override
// public MarkdownElement toMarkdownElement() throws MarkdownSerializationException {
// return this;
// }
//
// @Override
// public String toString() {
// return getSerialized(this.getClass().getSimpleName());
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownSerializationException.java
// public class MarkdownSerializationException extends Exception {
//
// public MarkdownSerializationException() {
// super();
// }
//
// public MarkdownSerializationException(String s) {
// super(s);
// }
//
// public MarkdownSerializationException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public MarkdownSerializationException(Throwable throwable) {
// super(throwable);
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/util/StringUtil.java
// public abstract class StringUtil {
//
// public static String fillUpAligned(String value, String fill, int length, int alignment) {
// switch (alignment) {
// case Table.ALIGN_RIGHT: {
// return fillUpRightAligned(value, fill, length);
// }
// case Table.ALIGN_CENTER: {
// return fillUpCenterAligned(value, fill, length);
// }
// default: {
// return fillUpLeftAligned(value, fill, length);
// }
// }
// }
//
// public static String fillUpLeftAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// while (value.length() < length) {
// value += fill;
// }
// return value;
// }
//
// public static String fillUpRightAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// while (value.length() < length) {
// value = fill + value;
// }
// return value;
// }
//
// public static String fillUpCenterAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// boolean left = true;
// while (value.length() < length) {
// if (left) {
// value = fillUpLeftAligned(value, fill, value.length() + 1);
// } else {
// value = fillUpRightAligned(value, fill, value.length() + 1);
// }
// left = !left;
// }
// return value;
// }
//
// public static String surroundValueWith(String value, String surrounding) {
// return surrounding + value + surrounding;
// }
//
// }
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/list/UnorderedList.java
import net.steppschuh.markdowngenerator.MarkdownElement;
import net.steppschuh.markdowngenerator.MarkdownSerializationException;
import net.steppschuh.markdowngenerator.util.StringUtil;
import java.util.ArrayList;
import java.util.List;
package net.steppschuh.markdowngenerator.list;
public class UnorderedList<T extends Object> extends MarkdownElement {
protected List<T> items;
protected int indentationLevel = 0;
public UnorderedList() {
this.items = new ArrayList<>();
}
public UnorderedList(List<T> items) {
this.items = items;
}
@Override
public String serialize() throws MarkdownSerializationException {
StringBuilder sb = new StringBuilder();
for (int itemIndex = 0; itemIndex < items.size(); itemIndex++) {
T item = items.get(itemIndex);
if (itemIndex > 0) {
|
sb.append(StringUtil.fillUpLeftAligned("", " ", indentationLevel * 2));
|
Steppschuh/Java-Markdown-Generator
|
Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/rule/HorizontalRule.java
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownElement.java
// public abstract class MarkdownElement implements MarkdownSerializable {
//
// private String serialized;
//
// /**
// * Attempts to generate a String representing this markdown element.
// *
// * @return Markdown as String
// * @throws MarkdownSerializationException If unable to generate a markdown String
// */
// public abstract String serialize() throws MarkdownSerializationException;
//
// /**
// * Returns the result of {@link MarkdownElement#getSerialized()} or the specified fallback if a
// * {@link MarkdownSerializationException} occurred.
// *
// * @param fallback String to return if serialization fails
// * @return Markdown as String or specified fallback
// */
// public String getSerialized(String fallback) {
// try {
// return getSerialized();
// } catch (MarkdownSerializationException e) {
// return fallback;
// }
// }
//
// /**
// * Calls {@link MarkdownElement#serialize()} or directly returns its last result from {@link
// * MarkdownElement#serialized}.
// *
// * @return Markdown as String
// * @throws MarkdownSerializationException If unable to generate a markdown String
// */
// public String getSerialized() throws MarkdownSerializationException {
// if (serialized == null) {
// serialized = serialize();
// }
// return serialized;
// }
//
// public void setSerialized(String serialized) {
// this.serialized = serialized;
// }
//
// /**
// * Sets {@link MarkdownElement#serialized} to null. The next call to {@link
// * MarkdownElement#getSerialized()} fill invoke a fresh serialization.
// */
// public void invalidateSerialized() {
// setSerialized(null);
// }
//
// @Override
// public MarkdownElement toMarkdownElement() throws MarkdownSerializationException {
// return this;
// }
//
// @Override
// public String toString() {
// return getSerialized(this.getClass().getSimpleName());
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownSerializationException.java
// public class MarkdownSerializationException extends Exception {
//
// public MarkdownSerializationException() {
// super();
// }
//
// public MarkdownSerializationException(String s) {
// super(s);
// }
//
// public MarkdownSerializationException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public MarkdownSerializationException(Throwable throwable) {
// super(throwable);
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/util/StringUtil.java
// public abstract class StringUtil {
//
// public static String fillUpAligned(String value, String fill, int length, int alignment) {
// switch (alignment) {
// case Table.ALIGN_RIGHT: {
// return fillUpRightAligned(value, fill, length);
// }
// case Table.ALIGN_CENTER: {
// return fillUpCenterAligned(value, fill, length);
// }
// default: {
// return fillUpLeftAligned(value, fill, length);
// }
// }
// }
//
// public static String fillUpLeftAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// while (value.length() < length) {
// value += fill;
// }
// return value;
// }
//
// public static String fillUpRightAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// while (value.length() < length) {
// value = fill + value;
// }
// return value;
// }
//
// public static String fillUpCenterAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// boolean left = true;
// while (value.length() < length) {
// if (left) {
// value = fillUpLeftAligned(value, fill, value.length() + 1);
// } else {
// value = fillUpRightAligned(value, fill, value.length() + 1);
// }
// left = !left;
// }
// return value;
// }
//
// public static String surroundValueWith(String value, String surrounding) {
// return surrounding + value + surrounding;
// }
//
// }
|
import net.steppschuh.markdowngenerator.MarkdownElement;
import net.steppschuh.markdowngenerator.MarkdownSerializationException;
import net.steppschuh.markdowngenerator.util.StringUtil;
|
package net.steppschuh.markdowngenerator.rule;
/**
* Created by steppschuh on 16/12/2016.
*/
public class HorizontalRule extends MarkdownElement {
public static final char HYPHEN = '-';
public static final char ASTERISK = '*';
public static final char UNDERSCORE = '_';
public static final int MINIMUM_LENGTH = 3;
private int length;
private char character = HYPHEN;
public HorizontalRule() {
this.length = MINIMUM_LENGTH;
}
public HorizontalRule(int length) {
this.length = Math.max(MINIMUM_LENGTH, length);
}
public HorizontalRule(int length, char character) {
this(length);
this.character = character;
}
@Override
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownElement.java
// public abstract class MarkdownElement implements MarkdownSerializable {
//
// private String serialized;
//
// /**
// * Attempts to generate a String representing this markdown element.
// *
// * @return Markdown as String
// * @throws MarkdownSerializationException If unable to generate a markdown String
// */
// public abstract String serialize() throws MarkdownSerializationException;
//
// /**
// * Returns the result of {@link MarkdownElement#getSerialized()} or the specified fallback if a
// * {@link MarkdownSerializationException} occurred.
// *
// * @param fallback String to return if serialization fails
// * @return Markdown as String or specified fallback
// */
// public String getSerialized(String fallback) {
// try {
// return getSerialized();
// } catch (MarkdownSerializationException e) {
// return fallback;
// }
// }
//
// /**
// * Calls {@link MarkdownElement#serialize()} or directly returns its last result from {@link
// * MarkdownElement#serialized}.
// *
// * @return Markdown as String
// * @throws MarkdownSerializationException If unable to generate a markdown String
// */
// public String getSerialized() throws MarkdownSerializationException {
// if (serialized == null) {
// serialized = serialize();
// }
// return serialized;
// }
//
// public void setSerialized(String serialized) {
// this.serialized = serialized;
// }
//
// /**
// * Sets {@link MarkdownElement#serialized} to null. The next call to {@link
// * MarkdownElement#getSerialized()} fill invoke a fresh serialization.
// */
// public void invalidateSerialized() {
// setSerialized(null);
// }
//
// @Override
// public MarkdownElement toMarkdownElement() throws MarkdownSerializationException {
// return this;
// }
//
// @Override
// public String toString() {
// return getSerialized(this.getClass().getSimpleName());
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownSerializationException.java
// public class MarkdownSerializationException extends Exception {
//
// public MarkdownSerializationException() {
// super();
// }
//
// public MarkdownSerializationException(String s) {
// super(s);
// }
//
// public MarkdownSerializationException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public MarkdownSerializationException(Throwable throwable) {
// super(throwable);
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/util/StringUtil.java
// public abstract class StringUtil {
//
// public static String fillUpAligned(String value, String fill, int length, int alignment) {
// switch (alignment) {
// case Table.ALIGN_RIGHT: {
// return fillUpRightAligned(value, fill, length);
// }
// case Table.ALIGN_CENTER: {
// return fillUpCenterAligned(value, fill, length);
// }
// default: {
// return fillUpLeftAligned(value, fill, length);
// }
// }
// }
//
// public static String fillUpLeftAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// while (value.length() < length) {
// value += fill;
// }
// return value;
// }
//
// public static String fillUpRightAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// while (value.length() < length) {
// value = fill + value;
// }
// return value;
// }
//
// public static String fillUpCenterAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// boolean left = true;
// while (value.length() < length) {
// if (left) {
// value = fillUpLeftAligned(value, fill, value.length() + 1);
// } else {
// value = fillUpRightAligned(value, fill, value.length() + 1);
// }
// left = !left;
// }
// return value;
// }
//
// public static String surroundValueWith(String value, String surrounding) {
// return surrounding + value + surrounding;
// }
//
// }
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/rule/HorizontalRule.java
import net.steppschuh.markdowngenerator.MarkdownElement;
import net.steppschuh.markdowngenerator.MarkdownSerializationException;
import net.steppschuh.markdowngenerator.util.StringUtil;
package net.steppschuh.markdowngenerator.rule;
/**
* Created by steppschuh on 16/12/2016.
*/
public class HorizontalRule extends MarkdownElement {
public static final char HYPHEN = '-';
public static final char ASTERISK = '*';
public static final char UNDERSCORE = '_';
public static final int MINIMUM_LENGTH = 3;
private int length;
private char character = HYPHEN;
public HorizontalRule() {
this.length = MINIMUM_LENGTH;
}
public HorizontalRule(int length) {
this.length = Math.max(MINIMUM_LENGTH, length);
}
public HorizontalRule(int length, char character) {
this(length);
this.character = character;
}
@Override
|
public String serialize() throws MarkdownSerializationException {
|
Steppschuh/Java-Markdown-Generator
|
Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/rule/HorizontalRule.java
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownElement.java
// public abstract class MarkdownElement implements MarkdownSerializable {
//
// private String serialized;
//
// /**
// * Attempts to generate a String representing this markdown element.
// *
// * @return Markdown as String
// * @throws MarkdownSerializationException If unable to generate a markdown String
// */
// public abstract String serialize() throws MarkdownSerializationException;
//
// /**
// * Returns the result of {@link MarkdownElement#getSerialized()} or the specified fallback if a
// * {@link MarkdownSerializationException} occurred.
// *
// * @param fallback String to return if serialization fails
// * @return Markdown as String or specified fallback
// */
// public String getSerialized(String fallback) {
// try {
// return getSerialized();
// } catch (MarkdownSerializationException e) {
// return fallback;
// }
// }
//
// /**
// * Calls {@link MarkdownElement#serialize()} or directly returns its last result from {@link
// * MarkdownElement#serialized}.
// *
// * @return Markdown as String
// * @throws MarkdownSerializationException If unable to generate a markdown String
// */
// public String getSerialized() throws MarkdownSerializationException {
// if (serialized == null) {
// serialized = serialize();
// }
// return serialized;
// }
//
// public void setSerialized(String serialized) {
// this.serialized = serialized;
// }
//
// /**
// * Sets {@link MarkdownElement#serialized} to null. The next call to {@link
// * MarkdownElement#getSerialized()} fill invoke a fresh serialization.
// */
// public void invalidateSerialized() {
// setSerialized(null);
// }
//
// @Override
// public MarkdownElement toMarkdownElement() throws MarkdownSerializationException {
// return this;
// }
//
// @Override
// public String toString() {
// return getSerialized(this.getClass().getSimpleName());
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownSerializationException.java
// public class MarkdownSerializationException extends Exception {
//
// public MarkdownSerializationException() {
// super();
// }
//
// public MarkdownSerializationException(String s) {
// super(s);
// }
//
// public MarkdownSerializationException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public MarkdownSerializationException(Throwable throwable) {
// super(throwable);
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/util/StringUtil.java
// public abstract class StringUtil {
//
// public static String fillUpAligned(String value, String fill, int length, int alignment) {
// switch (alignment) {
// case Table.ALIGN_RIGHT: {
// return fillUpRightAligned(value, fill, length);
// }
// case Table.ALIGN_CENTER: {
// return fillUpCenterAligned(value, fill, length);
// }
// default: {
// return fillUpLeftAligned(value, fill, length);
// }
// }
// }
//
// public static String fillUpLeftAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// while (value.length() < length) {
// value += fill;
// }
// return value;
// }
//
// public static String fillUpRightAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// while (value.length() < length) {
// value = fill + value;
// }
// return value;
// }
//
// public static String fillUpCenterAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// boolean left = true;
// while (value.length() < length) {
// if (left) {
// value = fillUpLeftAligned(value, fill, value.length() + 1);
// } else {
// value = fillUpRightAligned(value, fill, value.length() + 1);
// }
// left = !left;
// }
// return value;
// }
//
// public static String surroundValueWith(String value, String surrounding) {
// return surrounding + value + surrounding;
// }
//
// }
|
import net.steppschuh.markdowngenerator.MarkdownElement;
import net.steppschuh.markdowngenerator.MarkdownSerializationException;
import net.steppschuh.markdowngenerator.util.StringUtil;
|
package net.steppschuh.markdowngenerator.rule;
/**
* Created by steppschuh on 16/12/2016.
*/
public class HorizontalRule extends MarkdownElement {
public static final char HYPHEN = '-';
public static final char ASTERISK = '*';
public static final char UNDERSCORE = '_';
public static final int MINIMUM_LENGTH = 3;
private int length;
private char character = HYPHEN;
public HorizontalRule() {
this.length = MINIMUM_LENGTH;
}
public HorizontalRule(int length) {
this.length = Math.max(MINIMUM_LENGTH, length);
}
public HorizontalRule(int length, char character) {
this(length);
this.character = character;
}
@Override
public String serialize() throws MarkdownSerializationException {
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownElement.java
// public abstract class MarkdownElement implements MarkdownSerializable {
//
// private String serialized;
//
// /**
// * Attempts to generate a String representing this markdown element.
// *
// * @return Markdown as String
// * @throws MarkdownSerializationException If unable to generate a markdown String
// */
// public abstract String serialize() throws MarkdownSerializationException;
//
// /**
// * Returns the result of {@link MarkdownElement#getSerialized()} or the specified fallback if a
// * {@link MarkdownSerializationException} occurred.
// *
// * @param fallback String to return if serialization fails
// * @return Markdown as String or specified fallback
// */
// public String getSerialized(String fallback) {
// try {
// return getSerialized();
// } catch (MarkdownSerializationException e) {
// return fallback;
// }
// }
//
// /**
// * Calls {@link MarkdownElement#serialize()} or directly returns its last result from {@link
// * MarkdownElement#serialized}.
// *
// * @return Markdown as String
// * @throws MarkdownSerializationException If unable to generate a markdown String
// */
// public String getSerialized() throws MarkdownSerializationException {
// if (serialized == null) {
// serialized = serialize();
// }
// return serialized;
// }
//
// public void setSerialized(String serialized) {
// this.serialized = serialized;
// }
//
// /**
// * Sets {@link MarkdownElement#serialized} to null. The next call to {@link
// * MarkdownElement#getSerialized()} fill invoke a fresh serialization.
// */
// public void invalidateSerialized() {
// setSerialized(null);
// }
//
// @Override
// public MarkdownElement toMarkdownElement() throws MarkdownSerializationException {
// return this;
// }
//
// @Override
// public String toString() {
// return getSerialized(this.getClass().getSimpleName());
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownSerializationException.java
// public class MarkdownSerializationException extends Exception {
//
// public MarkdownSerializationException() {
// super();
// }
//
// public MarkdownSerializationException(String s) {
// super(s);
// }
//
// public MarkdownSerializationException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public MarkdownSerializationException(Throwable throwable) {
// super(throwable);
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/util/StringUtil.java
// public abstract class StringUtil {
//
// public static String fillUpAligned(String value, String fill, int length, int alignment) {
// switch (alignment) {
// case Table.ALIGN_RIGHT: {
// return fillUpRightAligned(value, fill, length);
// }
// case Table.ALIGN_CENTER: {
// return fillUpCenterAligned(value, fill, length);
// }
// default: {
// return fillUpLeftAligned(value, fill, length);
// }
// }
// }
//
// public static String fillUpLeftAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// while (value.length() < length) {
// value += fill;
// }
// return value;
// }
//
// public static String fillUpRightAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// while (value.length() < length) {
// value = fill + value;
// }
// return value;
// }
//
// public static String fillUpCenterAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// boolean left = true;
// while (value.length() < length) {
// if (left) {
// value = fillUpLeftAligned(value, fill, value.length() + 1);
// } else {
// value = fillUpRightAligned(value, fill, value.length() + 1);
// }
// left = !left;
// }
// return value;
// }
//
// public static String surroundValueWith(String value, String surrounding) {
// return surrounding + value + surrounding;
// }
//
// }
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/rule/HorizontalRule.java
import net.steppschuh.markdowngenerator.MarkdownElement;
import net.steppschuh.markdowngenerator.MarkdownSerializationException;
import net.steppschuh.markdowngenerator.util.StringUtil;
package net.steppschuh.markdowngenerator.rule;
/**
* Created by steppschuh on 16/12/2016.
*/
public class HorizontalRule extends MarkdownElement {
public static final char HYPHEN = '-';
public static final char ASTERISK = '*';
public static final char UNDERSCORE = '_';
public static final int MINIMUM_LENGTH = 3;
private int length;
private char character = HYPHEN;
public HorizontalRule() {
this.length = MINIMUM_LENGTH;
}
public HorizontalRule(int length) {
this.length = Math.max(MINIMUM_LENGTH, length);
}
public HorizontalRule(int length, char character) {
this(length);
this.character = character;
}
@Override
public String serialize() throws MarkdownSerializationException {
|
return StringUtil.fillUpLeftAligned("", "" + character, length);
|
Steppschuh/Java-Markdown-Generator
|
Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/text/code/CodeTest.java
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/Text.java
// public class Text extends MarkdownElement implements MarkdownCascadable {
//
// protected Object value;
//
// public Text(Object value) {
// this.value = value;
// }
//
// @Override
// public String serialize() throws MarkdownSerializationException {
// if (value == null) {
// throw new MarkdownSerializationException("Value is null");
// }
// return getPredecessor() + value.toString() + getSuccessor();
// }
//
// @Override
// public String getPredecessor() {
// return "";
// }
//
// @Override
// public String getSuccessor() {
// return getPredecessor();
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// invalidateSerialized();
// }
//
// }
|
import net.steppschuh.markdowngenerator.text.Text;
import org.junit.Test;
|
package net.steppschuh.markdowngenerator.text.code;
/**
* Created by steppschuh on 15/12/2016.
*/
public class CodeTest {
@Test
public void example1() throws Exception {
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/Text.java
// public class Text extends MarkdownElement implements MarkdownCascadable {
//
// protected Object value;
//
// public Text(Object value) {
// this.value = value;
// }
//
// @Override
// public String serialize() throws MarkdownSerializationException {
// if (value == null) {
// throw new MarkdownSerializationException("Value is null");
// }
// return getPredecessor() + value.toString() + getSuccessor();
// }
//
// @Override
// public String getPredecessor() {
// return "";
// }
//
// @Override
// public String getSuccessor() {
// return getPredecessor();
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// invalidateSerialized();
// }
//
// }
// Path: Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/text/code/CodeTest.java
import net.steppschuh.markdowngenerator.text.Text;
import org.junit.Test;
package net.steppschuh.markdowngenerator.text.code;
/**
* Created by steppschuh on 15/12/2016.
*/
public class CodeTest {
@Test
public void example1() throws Exception {
|
Text text = new Code("System.out.println(\"I am code\");");
|
Steppschuh/Java-Markdown-Generator
|
Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/MarkdownBuilderTest.java
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/list/ListBuilder.java
// public class ListBuilder extends MarkdownBuilder<ListBuilder, UnorderedList> {
//
// public ListBuilder() {
// super();
// }
//
// public ListBuilder(MarkdownBuilder parentBuilder) {
// super(parentBuilder);
// }
//
// @Override
// protected ListBuilder getBuilder() {
// return this;
// }
//
// @Override
// protected UnorderedList createMarkdownElement() {
// return new UnorderedList();
// }
//
// @Override
// public ListBuilder append(Object value) {
// markdownElement.getItems().add(value);
// return this;
// }
//
// @Override
// public ListBuilder append(MarkdownSerializable value) {
// if (value instanceof ListBuilder) {
// UnorderedList unorderedList = ((ListBuilder) value).markdownElement;
// unorderedList.incrementIndentationLevel();
// markdownElement.getItems().add(unorderedList);
// return this;
// }
// return super.append(value);
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/TextBuilder.java
// public class TextBuilder extends MarkdownBuilder<TextBuilder, Text> {
//
// public TextBuilder() {
// }
//
// public TextBuilder(MarkdownBuilder parentBuilder) {
// super(parentBuilder);
// }
//
// @Override
// protected TextBuilder getBuilder() {
// return this;
// }
//
// @Override
// protected Text createMarkdownElement() {
// return new Text("");
// }
//
// @Override
// public TextBuilder append(Object value) {
// StringBuilder sb = new StringBuilder();
// if (markdownElement.getValue() != null) {
// sb.append(markdownElement.getValue());
// }
// sb.append(value);
// markdownElement.setValue(sb);
// return this;
// }
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/code/CodeBlock.java
// public class CodeBlock extends Text {
//
// public static final String LANGUAGE_UNKNOWN = "";
// public static final String LANGUAGE_JAVA = "java";
// public static final String LANGUAGE_MARKDOWN = "markdown";
//
// private String language = LANGUAGE_UNKNOWN;
//
// public CodeBlock(Object value) {
// this(value, "");
// }
//
// public CodeBlock(Object value, String language) {
// super(value);
// this.language = language;
// }
//
// @Override
// public String getPredecessor() {
// return "```" + language + System.lineSeparator();
// }
//
// @Override
// public String getSuccessor() {
// return System.lineSeparator() + "```";
// }
//
// public String getLanguage() {
// return language;
// }
//
// public void setLanguage(String language) {
// this.language = language;
// invalidateSerialized();
// }
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/Markdown.java
// public static BoldText bold(String value) {
// return new BoldText(value);
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/Markdown.java
// public static ItalicText italic(String value) {
// return new ItalicText(value);
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/Markdown.java
// public static TaskListItem task(String value) {
// return new TaskListItem(value);
// }
|
import net.steppschuh.markdowngenerator.list.ListBuilder;
import net.steppschuh.markdowngenerator.text.TextBuilder;
import net.steppschuh.markdowngenerator.text.code.CodeBlock;
import org.junit.Test;
import static net.steppschuh.markdowngenerator.Markdown.bold;
import static net.steppschuh.markdowngenerator.Markdown.italic;
import static net.steppschuh.markdowngenerator.Markdown.task;
|
package net.steppschuh.markdowngenerator;
/**
* Created by steppschuh on 23/12/2016.
*/
public class MarkdownBuilderTest {
@Test
public void example1() throws Exception {
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/list/ListBuilder.java
// public class ListBuilder extends MarkdownBuilder<ListBuilder, UnorderedList> {
//
// public ListBuilder() {
// super();
// }
//
// public ListBuilder(MarkdownBuilder parentBuilder) {
// super(parentBuilder);
// }
//
// @Override
// protected ListBuilder getBuilder() {
// return this;
// }
//
// @Override
// protected UnorderedList createMarkdownElement() {
// return new UnorderedList();
// }
//
// @Override
// public ListBuilder append(Object value) {
// markdownElement.getItems().add(value);
// return this;
// }
//
// @Override
// public ListBuilder append(MarkdownSerializable value) {
// if (value instanceof ListBuilder) {
// UnorderedList unorderedList = ((ListBuilder) value).markdownElement;
// unorderedList.incrementIndentationLevel();
// markdownElement.getItems().add(unorderedList);
// return this;
// }
// return super.append(value);
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/TextBuilder.java
// public class TextBuilder extends MarkdownBuilder<TextBuilder, Text> {
//
// public TextBuilder() {
// }
//
// public TextBuilder(MarkdownBuilder parentBuilder) {
// super(parentBuilder);
// }
//
// @Override
// protected TextBuilder getBuilder() {
// return this;
// }
//
// @Override
// protected Text createMarkdownElement() {
// return new Text("");
// }
//
// @Override
// public TextBuilder append(Object value) {
// StringBuilder sb = new StringBuilder();
// if (markdownElement.getValue() != null) {
// sb.append(markdownElement.getValue());
// }
// sb.append(value);
// markdownElement.setValue(sb);
// return this;
// }
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/code/CodeBlock.java
// public class CodeBlock extends Text {
//
// public static final String LANGUAGE_UNKNOWN = "";
// public static final String LANGUAGE_JAVA = "java";
// public static final String LANGUAGE_MARKDOWN = "markdown";
//
// private String language = LANGUAGE_UNKNOWN;
//
// public CodeBlock(Object value) {
// this(value, "");
// }
//
// public CodeBlock(Object value, String language) {
// super(value);
// this.language = language;
// }
//
// @Override
// public String getPredecessor() {
// return "```" + language + System.lineSeparator();
// }
//
// @Override
// public String getSuccessor() {
// return System.lineSeparator() + "```";
// }
//
// public String getLanguage() {
// return language;
// }
//
// public void setLanguage(String language) {
// this.language = language;
// invalidateSerialized();
// }
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/Markdown.java
// public static BoldText bold(String value) {
// return new BoldText(value);
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/Markdown.java
// public static ItalicText italic(String value) {
// return new ItalicText(value);
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/Markdown.java
// public static TaskListItem task(String value) {
// return new TaskListItem(value);
// }
// Path: Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/MarkdownBuilderTest.java
import net.steppschuh.markdowngenerator.list.ListBuilder;
import net.steppschuh.markdowngenerator.text.TextBuilder;
import net.steppschuh.markdowngenerator.text.code.CodeBlock;
import org.junit.Test;
import static net.steppschuh.markdowngenerator.Markdown.bold;
import static net.steppschuh.markdowngenerator.Markdown.italic;
import static net.steppschuh.markdowngenerator.Markdown.task;
package net.steppschuh.markdowngenerator;
/**
* Created by steppschuh on 23/12/2016.
*/
public class MarkdownBuilderTest {
@Test
public void example1() throws Exception {
|
MarkdownBuilder builder = new TextBuilder()
|
Steppschuh/Java-Markdown-Generator
|
Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/MarkdownBuilderTest.java
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/list/ListBuilder.java
// public class ListBuilder extends MarkdownBuilder<ListBuilder, UnorderedList> {
//
// public ListBuilder() {
// super();
// }
//
// public ListBuilder(MarkdownBuilder parentBuilder) {
// super(parentBuilder);
// }
//
// @Override
// protected ListBuilder getBuilder() {
// return this;
// }
//
// @Override
// protected UnorderedList createMarkdownElement() {
// return new UnorderedList();
// }
//
// @Override
// public ListBuilder append(Object value) {
// markdownElement.getItems().add(value);
// return this;
// }
//
// @Override
// public ListBuilder append(MarkdownSerializable value) {
// if (value instanceof ListBuilder) {
// UnorderedList unorderedList = ((ListBuilder) value).markdownElement;
// unorderedList.incrementIndentationLevel();
// markdownElement.getItems().add(unorderedList);
// return this;
// }
// return super.append(value);
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/TextBuilder.java
// public class TextBuilder extends MarkdownBuilder<TextBuilder, Text> {
//
// public TextBuilder() {
// }
//
// public TextBuilder(MarkdownBuilder parentBuilder) {
// super(parentBuilder);
// }
//
// @Override
// protected TextBuilder getBuilder() {
// return this;
// }
//
// @Override
// protected Text createMarkdownElement() {
// return new Text("");
// }
//
// @Override
// public TextBuilder append(Object value) {
// StringBuilder sb = new StringBuilder();
// if (markdownElement.getValue() != null) {
// sb.append(markdownElement.getValue());
// }
// sb.append(value);
// markdownElement.setValue(sb);
// return this;
// }
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/code/CodeBlock.java
// public class CodeBlock extends Text {
//
// public static final String LANGUAGE_UNKNOWN = "";
// public static final String LANGUAGE_JAVA = "java";
// public static final String LANGUAGE_MARKDOWN = "markdown";
//
// private String language = LANGUAGE_UNKNOWN;
//
// public CodeBlock(Object value) {
// this(value, "");
// }
//
// public CodeBlock(Object value, String language) {
// super(value);
// this.language = language;
// }
//
// @Override
// public String getPredecessor() {
// return "```" + language + System.lineSeparator();
// }
//
// @Override
// public String getSuccessor() {
// return System.lineSeparator() + "```";
// }
//
// public String getLanguage() {
// return language;
// }
//
// public void setLanguage(String language) {
// this.language = language;
// invalidateSerialized();
// }
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/Markdown.java
// public static BoldText bold(String value) {
// return new BoldText(value);
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/Markdown.java
// public static ItalicText italic(String value) {
// return new ItalicText(value);
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/Markdown.java
// public static TaskListItem task(String value) {
// return new TaskListItem(value);
// }
|
import net.steppschuh.markdowngenerator.list.ListBuilder;
import net.steppschuh.markdowngenerator.text.TextBuilder;
import net.steppschuh.markdowngenerator.text.code.CodeBlock;
import org.junit.Test;
import static net.steppschuh.markdowngenerator.Markdown.bold;
import static net.steppschuh.markdowngenerator.Markdown.italic;
import static net.steppschuh.markdowngenerator.Markdown.task;
|
package net.steppschuh.markdowngenerator;
/**
* Created by steppschuh on 23/12/2016.
*/
public class MarkdownBuilderTest {
@Test
public void example1() throws Exception {
MarkdownBuilder builder = new TextBuilder()
.heading("Markdown Builder")
.append("Demonstrating: ")
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/list/ListBuilder.java
// public class ListBuilder extends MarkdownBuilder<ListBuilder, UnorderedList> {
//
// public ListBuilder() {
// super();
// }
//
// public ListBuilder(MarkdownBuilder parentBuilder) {
// super(parentBuilder);
// }
//
// @Override
// protected ListBuilder getBuilder() {
// return this;
// }
//
// @Override
// protected UnorderedList createMarkdownElement() {
// return new UnorderedList();
// }
//
// @Override
// public ListBuilder append(Object value) {
// markdownElement.getItems().add(value);
// return this;
// }
//
// @Override
// public ListBuilder append(MarkdownSerializable value) {
// if (value instanceof ListBuilder) {
// UnorderedList unorderedList = ((ListBuilder) value).markdownElement;
// unorderedList.incrementIndentationLevel();
// markdownElement.getItems().add(unorderedList);
// return this;
// }
// return super.append(value);
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/TextBuilder.java
// public class TextBuilder extends MarkdownBuilder<TextBuilder, Text> {
//
// public TextBuilder() {
// }
//
// public TextBuilder(MarkdownBuilder parentBuilder) {
// super(parentBuilder);
// }
//
// @Override
// protected TextBuilder getBuilder() {
// return this;
// }
//
// @Override
// protected Text createMarkdownElement() {
// return new Text("");
// }
//
// @Override
// public TextBuilder append(Object value) {
// StringBuilder sb = new StringBuilder();
// if (markdownElement.getValue() != null) {
// sb.append(markdownElement.getValue());
// }
// sb.append(value);
// markdownElement.setValue(sb);
// return this;
// }
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/code/CodeBlock.java
// public class CodeBlock extends Text {
//
// public static final String LANGUAGE_UNKNOWN = "";
// public static final String LANGUAGE_JAVA = "java";
// public static final String LANGUAGE_MARKDOWN = "markdown";
//
// private String language = LANGUAGE_UNKNOWN;
//
// public CodeBlock(Object value) {
// this(value, "");
// }
//
// public CodeBlock(Object value, String language) {
// super(value);
// this.language = language;
// }
//
// @Override
// public String getPredecessor() {
// return "```" + language + System.lineSeparator();
// }
//
// @Override
// public String getSuccessor() {
// return System.lineSeparator() + "```";
// }
//
// public String getLanguage() {
// return language;
// }
//
// public void setLanguage(String language) {
// this.language = language;
// invalidateSerialized();
// }
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/Markdown.java
// public static BoldText bold(String value) {
// return new BoldText(value);
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/Markdown.java
// public static ItalicText italic(String value) {
// return new ItalicText(value);
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/Markdown.java
// public static TaskListItem task(String value) {
// return new TaskListItem(value);
// }
// Path: Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/MarkdownBuilderTest.java
import net.steppschuh.markdowngenerator.list.ListBuilder;
import net.steppschuh.markdowngenerator.text.TextBuilder;
import net.steppschuh.markdowngenerator.text.code.CodeBlock;
import org.junit.Test;
import static net.steppschuh.markdowngenerator.Markdown.bold;
import static net.steppschuh.markdowngenerator.Markdown.italic;
import static net.steppschuh.markdowngenerator.Markdown.task;
package net.steppschuh.markdowngenerator;
/**
* Created by steppschuh on 23/12/2016.
*/
public class MarkdownBuilderTest {
@Test
public void example1() throws Exception {
MarkdownBuilder builder = new TextBuilder()
.heading("Markdown Builder")
.append("Demonstrating: ")
|
.append(bold("Bold Text"))
|
Steppschuh/Java-Markdown-Generator
|
Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/MarkdownBuilderTest.java
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/list/ListBuilder.java
// public class ListBuilder extends MarkdownBuilder<ListBuilder, UnorderedList> {
//
// public ListBuilder() {
// super();
// }
//
// public ListBuilder(MarkdownBuilder parentBuilder) {
// super(parentBuilder);
// }
//
// @Override
// protected ListBuilder getBuilder() {
// return this;
// }
//
// @Override
// protected UnorderedList createMarkdownElement() {
// return new UnorderedList();
// }
//
// @Override
// public ListBuilder append(Object value) {
// markdownElement.getItems().add(value);
// return this;
// }
//
// @Override
// public ListBuilder append(MarkdownSerializable value) {
// if (value instanceof ListBuilder) {
// UnorderedList unorderedList = ((ListBuilder) value).markdownElement;
// unorderedList.incrementIndentationLevel();
// markdownElement.getItems().add(unorderedList);
// return this;
// }
// return super.append(value);
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/TextBuilder.java
// public class TextBuilder extends MarkdownBuilder<TextBuilder, Text> {
//
// public TextBuilder() {
// }
//
// public TextBuilder(MarkdownBuilder parentBuilder) {
// super(parentBuilder);
// }
//
// @Override
// protected TextBuilder getBuilder() {
// return this;
// }
//
// @Override
// protected Text createMarkdownElement() {
// return new Text("");
// }
//
// @Override
// public TextBuilder append(Object value) {
// StringBuilder sb = new StringBuilder();
// if (markdownElement.getValue() != null) {
// sb.append(markdownElement.getValue());
// }
// sb.append(value);
// markdownElement.setValue(sb);
// return this;
// }
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/code/CodeBlock.java
// public class CodeBlock extends Text {
//
// public static final String LANGUAGE_UNKNOWN = "";
// public static final String LANGUAGE_JAVA = "java";
// public static final String LANGUAGE_MARKDOWN = "markdown";
//
// private String language = LANGUAGE_UNKNOWN;
//
// public CodeBlock(Object value) {
// this(value, "");
// }
//
// public CodeBlock(Object value, String language) {
// super(value);
// this.language = language;
// }
//
// @Override
// public String getPredecessor() {
// return "```" + language + System.lineSeparator();
// }
//
// @Override
// public String getSuccessor() {
// return System.lineSeparator() + "```";
// }
//
// public String getLanguage() {
// return language;
// }
//
// public void setLanguage(String language) {
// this.language = language;
// invalidateSerialized();
// }
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/Markdown.java
// public static BoldText bold(String value) {
// return new BoldText(value);
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/Markdown.java
// public static ItalicText italic(String value) {
// return new ItalicText(value);
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/Markdown.java
// public static TaskListItem task(String value) {
// return new TaskListItem(value);
// }
|
import net.steppschuh.markdowngenerator.list.ListBuilder;
import net.steppschuh.markdowngenerator.text.TextBuilder;
import net.steppschuh.markdowngenerator.text.code.CodeBlock;
import org.junit.Test;
import static net.steppschuh.markdowngenerator.Markdown.bold;
import static net.steppschuh.markdowngenerator.Markdown.italic;
import static net.steppschuh.markdowngenerator.Markdown.task;
|
package net.steppschuh.markdowngenerator;
/**
* Created by steppschuh on 23/12/2016.
*/
public class MarkdownBuilderTest {
@Test
public void example1() throws Exception {
MarkdownBuilder builder = new TextBuilder()
.heading("Markdown Builder")
.append("Demonstrating: ")
.append(bold("Bold Text"))
.newParagraph()
.beginList()
.append("I should be an item")
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/list/ListBuilder.java
// public class ListBuilder extends MarkdownBuilder<ListBuilder, UnorderedList> {
//
// public ListBuilder() {
// super();
// }
//
// public ListBuilder(MarkdownBuilder parentBuilder) {
// super(parentBuilder);
// }
//
// @Override
// protected ListBuilder getBuilder() {
// return this;
// }
//
// @Override
// protected UnorderedList createMarkdownElement() {
// return new UnorderedList();
// }
//
// @Override
// public ListBuilder append(Object value) {
// markdownElement.getItems().add(value);
// return this;
// }
//
// @Override
// public ListBuilder append(MarkdownSerializable value) {
// if (value instanceof ListBuilder) {
// UnorderedList unorderedList = ((ListBuilder) value).markdownElement;
// unorderedList.incrementIndentationLevel();
// markdownElement.getItems().add(unorderedList);
// return this;
// }
// return super.append(value);
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/TextBuilder.java
// public class TextBuilder extends MarkdownBuilder<TextBuilder, Text> {
//
// public TextBuilder() {
// }
//
// public TextBuilder(MarkdownBuilder parentBuilder) {
// super(parentBuilder);
// }
//
// @Override
// protected TextBuilder getBuilder() {
// return this;
// }
//
// @Override
// protected Text createMarkdownElement() {
// return new Text("");
// }
//
// @Override
// public TextBuilder append(Object value) {
// StringBuilder sb = new StringBuilder();
// if (markdownElement.getValue() != null) {
// sb.append(markdownElement.getValue());
// }
// sb.append(value);
// markdownElement.setValue(sb);
// return this;
// }
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/code/CodeBlock.java
// public class CodeBlock extends Text {
//
// public static final String LANGUAGE_UNKNOWN = "";
// public static final String LANGUAGE_JAVA = "java";
// public static final String LANGUAGE_MARKDOWN = "markdown";
//
// private String language = LANGUAGE_UNKNOWN;
//
// public CodeBlock(Object value) {
// this(value, "");
// }
//
// public CodeBlock(Object value, String language) {
// super(value);
// this.language = language;
// }
//
// @Override
// public String getPredecessor() {
// return "```" + language + System.lineSeparator();
// }
//
// @Override
// public String getSuccessor() {
// return System.lineSeparator() + "```";
// }
//
// public String getLanguage() {
// return language;
// }
//
// public void setLanguage(String language) {
// this.language = language;
// invalidateSerialized();
// }
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/Markdown.java
// public static BoldText bold(String value) {
// return new BoldText(value);
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/Markdown.java
// public static ItalicText italic(String value) {
// return new ItalicText(value);
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/Markdown.java
// public static TaskListItem task(String value) {
// return new TaskListItem(value);
// }
// Path: Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/MarkdownBuilderTest.java
import net.steppschuh.markdowngenerator.list.ListBuilder;
import net.steppschuh.markdowngenerator.text.TextBuilder;
import net.steppschuh.markdowngenerator.text.code.CodeBlock;
import org.junit.Test;
import static net.steppschuh.markdowngenerator.Markdown.bold;
import static net.steppschuh.markdowngenerator.Markdown.italic;
import static net.steppschuh.markdowngenerator.Markdown.task;
package net.steppschuh.markdowngenerator;
/**
* Created by steppschuh on 23/12/2016.
*/
public class MarkdownBuilderTest {
@Test
public void example1() throws Exception {
MarkdownBuilder builder = new TextBuilder()
.heading("Markdown Builder")
.append("Demonstrating: ")
.append(bold("Bold Text"))
.newParagraph()
.beginList()
.append("I should be an item")
|
.append(italic("I should be an italic item"))
|
Steppschuh/Java-Markdown-Generator
|
Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/MarkdownBuilderTest.java
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/list/ListBuilder.java
// public class ListBuilder extends MarkdownBuilder<ListBuilder, UnorderedList> {
//
// public ListBuilder() {
// super();
// }
//
// public ListBuilder(MarkdownBuilder parentBuilder) {
// super(parentBuilder);
// }
//
// @Override
// protected ListBuilder getBuilder() {
// return this;
// }
//
// @Override
// protected UnorderedList createMarkdownElement() {
// return new UnorderedList();
// }
//
// @Override
// public ListBuilder append(Object value) {
// markdownElement.getItems().add(value);
// return this;
// }
//
// @Override
// public ListBuilder append(MarkdownSerializable value) {
// if (value instanceof ListBuilder) {
// UnorderedList unorderedList = ((ListBuilder) value).markdownElement;
// unorderedList.incrementIndentationLevel();
// markdownElement.getItems().add(unorderedList);
// return this;
// }
// return super.append(value);
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/TextBuilder.java
// public class TextBuilder extends MarkdownBuilder<TextBuilder, Text> {
//
// public TextBuilder() {
// }
//
// public TextBuilder(MarkdownBuilder parentBuilder) {
// super(parentBuilder);
// }
//
// @Override
// protected TextBuilder getBuilder() {
// return this;
// }
//
// @Override
// protected Text createMarkdownElement() {
// return new Text("");
// }
//
// @Override
// public TextBuilder append(Object value) {
// StringBuilder sb = new StringBuilder();
// if (markdownElement.getValue() != null) {
// sb.append(markdownElement.getValue());
// }
// sb.append(value);
// markdownElement.setValue(sb);
// return this;
// }
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/code/CodeBlock.java
// public class CodeBlock extends Text {
//
// public static final String LANGUAGE_UNKNOWN = "";
// public static final String LANGUAGE_JAVA = "java";
// public static final String LANGUAGE_MARKDOWN = "markdown";
//
// private String language = LANGUAGE_UNKNOWN;
//
// public CodeBlock(Object value) {
// this(value, "");
// }
//
// public CodeBlock(Object value, String language) {
// super(value);
// this.language = language;
// }
//
// @Override
// public String getPredecessor() {
// return "```" + language + System.lineSeparator();
// }
//
// @Override
// public String getSuccessor() {
// return System.lineSeparator() + "```";
// }
//
// public String getLanguage() {
// return language;
// }
//
// public void setLanguage(String language) {
// this.language = language;
// invalidateSerialized();
// }
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/Markdown.java
// public static BoldText bold(String value) {
// return new BoldText(value);
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/Markdown.java
// public static ItalicText italic(String value) {
// return new ItalicText(value);
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/Markdown.java
// public static TaskListItem task(String value) {
// return new TaskListItem(value);
// }
|
import net.steppschuh.markdowngenerator.list.ListBuilder;
import net.steppschuh.markdowngenerator.text.TextBuilder;
import net.steppschuh.markdowngenerator.text.code.CodeBlock;
import org.junit.Test;
import static net.steppschuh.markdowngenerator.Markdown.bold;
import static net.steppschuh.markdowngenerator.Markdown.italic;
import static net.steppschuh.markdowngenerator.Markdown.task;
|
package net.steppschuh.markdowngenerator;
/**
* Created by steppschuh on 23/12/2016.
*/
public class MarkdownBuilderTest {
@Test
public void example1() throws Exception {
MarkdownBuilder builder = new TextBuilder()
.heading("Markdown Builder")
.append("Demonstrating: ")
.append(bold("Bold Text"))
.newParagraph()
.beginList()
.append("I should be an item")
.append(italic("I should be an italic item"))
.end()
.newParagraph()
.beginQuote()
.append("I should be a quote").newLine()
.append("I should still be a quote")
.end()
.newParagraph()
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/list/ListBuilder.java
// public class ListBuilder extends MarkdownBuilder<ListBuilder, UnorderedList> {
//
// public ListBuilder() {
// super();
// }
//
// public ListBuilder(MarkdownBuilder parentBuilder) {
// super(parentBuilder);
// }
//
// @Override
// protected ListBuilder getBuilder() {
// return this;
// }
//
// @Override
// protected UnorderedList createMarkdownElement() {
// return new UnorderedList();
// }
//
// @Override
// public ListBuilder append(Object value) {
// markdownElement.getItems().add(value);
// return this;
// }
//
// @Override
// public ListBuilder append(MarkdownSerializable value) {
// if (value instanceof ListBuilder) {
// UnorderedList unorderedList = ((ListBuilder) value).markdownElement;
// unorderedList.incrementIndentationLevel();
// markdownElement.getItems().add(unorderedList);
// return this;
// }
// return super.append(value);
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/TextBuilder.java
// public class TextBuilder extends MarkdownBuilder<TextBuilder, Text> {
//
// public TextBuilder() {
// }
//
// public TextBuilder(MarkdownBuilder parentBuilder) {
// super(parentBuilder);
// }
//
// @Override
// protected TextBuilder getBuilder() {
// return this;
// }
//
// @Override
// protected Text createMarkdownElement() {
// return new Text("");
// }
//
// @Override
// public TextBuilder append(Object value) {
// StringBuilder sb = new StringBuilder();
// if (markdownElement.getValue() != null) {
// sb.append(markdownElement.getValue());
// }
// sb.append(value);
// markdownElement.setValue(sb);
// return this;
// }
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/code/CodeBlock.java
// public class CodeBlock extends Text {
//
// public static final String LANGUAGE_UNKNOWN = "";
// public static final String LANGUAGE_JAVA = "java";
// public static final String LANGUAGE_MARKDOWN = "markdown";
//
// private String language = LANGUAGE_UNKNOWN;
//
// public CodeBlock(Object value) {
// this(value, "");
// }
//
// public CodeBlock(Object value, String language) {
// super(value);
// this.language = language;
// }
//
// @Override
// public String getPredecessor() {
// return "```" + language + System.lineSeparator();
// }
//
// @Override
// public String getSuccessor() {
// return System.lineSeparator() + "```";
// }
//
// public String getLanguage() {
// return language;
// }
//
// public void setLanguage(String language) {
// this.language = language;
// invalidateSerialized();
// }
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/Markdown.java
// public static BoldText bold(String value) {
// return new BoldText(value);
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/Markdown.java
// public static ItalicText italic(String value) {
// return new ItalicText(value);
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/Markdown.java
// public static TaskListItem task(String value) {
// return new TaskListItem(value);
// }
// Path: Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/MarkdownBuilderTest.java
import net.steppschuh.markdowngenerator.list.ListBuilder;
import net.steppschuh.markdowngenerator.text.TextBuilder;
import net.steppschuh.markdowngenerator.text.code.CodeBlock;
import org.junit.Test;
import static net.steppschuh.markdowngenerator.Markdown.bold;
import static net.steppschuh.markdowngenerator.Markdown.italic;
import static net.steppschuh.markdowngenerator.Markdown.task;
package net.steppschuh.markdowngenerator;
/**
* Created by steppschuh on 23/12/2016.
*/
public class MarkdownBuilderTest {
@Test
public void example1() throws Exception {
MarkdownBuilder builder = new TextBuilder()
.heading("Markdown Builder")
.append("Demonstrating: ")
.append(bold("Bold Text"))
.newParagraph()
.beginList()
.append("I should be an item")
.append(italic("I should be an italic item"))
.end()
.newParagraph()
.beginQuote()
.append("I should be a quote").newLine()
.append("I should still be a quote")
.end()
.newParagraph()
|
.beginCodeBlock(CodeBlock.LANGUAGE_JAVA)
|
Steppschuh/Java-Markdown-Generator
|
Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/MarkdownBuilderTest.java
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/list/ListBuilder.java
// public class ListBuilder extends MarkdownBuilder<ListBuilder, UnorderedList> {
//
// public ListBuilder() {
// super();
// }
//
// public ListBuilder(MarkdownBuilder parentBuilder) {
// super(parentBuilder);
// }
//
// @Override
// protected ListBuilder getBuilder() {
// return this;
// }
//
// @Override
// protected UnorderedList createMarkdownElement() {
// return new UnorderedList();
// }
//
// @Override
// public ListBuilder append(Object value) {
// markdownElement.getItems().add(value);
// return this;
// }
//
// @Override
// public ListBuilder append(MarkdownSerializable value) {
// if (value instanceof ListBuilder) {
// UnorderedList unorderedList = ((ListBuilder) value).markdownElement;
// unorderedList.incrementIndentationLevel();
// markdownElement.getItems().add(unorderedList);
// return this;
// }
// return super.append(value);
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/TextBuilder.java
// public class TextBuilder extends MarkdownBuilder<TextBuilder, Text> {
//
// public TextBuilder() {
// }
//
// public TextBuilder(MarkdownBuilder parentBuilder) {
// super(parentBuilder);
// }
//
// @Override
// protected TextBuilder getBuilder() {
// return this;
// }
//
// @Override
// protected Text createMarkdownElement() {
// return new Text("");
// }
//
// @Override
// public TextBuilder append(Object value) {
// StringBuilder sb = new StringBuilder();
// if (markdownElement.getValue() != null) {
// sb.append(markdownElement.getValue());
// }
// sb.append(value);
// markdownElement.setValue(sb);
// return this;
// }
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/code/CodeBlock.java
// public class CodeBlock extends Text {
//
// public static final String LANGUAGE_UNKNOWN = "";
// public static final String LANGUAGE_JAVA = "java";
// public static final String LANGUAGE_MARKDOWN = "markdown";
//
// private String language = LANGUAGE_UNKNOWN;
//
// public CodeBlock(Object value) {
// this(value, "");
// }
//
// public CodeBlock(Object value, String language) {
// super(value);
// this.language = language;
// }
//
// @Override
// public String getPredecessor() {
// return "```" + language + System.lineSeparator();
// }
//
// @Override
// public String getSuccessor() {
// return System.lineSeparator() + "```";
// }
//
// public String getLanguage() {
// return language;
// }
//
// public void setLanguage(String language) {
// this.language = language;
// invalidateSerialized();
// }
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/Markdown.java
// public static BoldText bold(String value) {
// return new BoldText(value);
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/Markdown.java
// public static ItalicText italic(String value) {
// return new ItalicText(value);
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/Markdown.java
// public static TaskListItem task(String value) {
// return new TaskListItem(value);
// }
|
import net.steppschuh.markdowngenerator.list.ListBuilder;
import net.steppschuh.markdowngenerator.text.TextBuilder;
import net.steppschuh.markdowngenerator.text.code.CodeBlock;
import org.junit.Test;
import static net.steppschuh.markdowngenerator.Markdown.bold;
import static net.steppschuh.markdowngenerator.Markdown.italic;
import static net.steppschuh.markdowngenerator.Markdown.task;
|
package net.steppschuh.markdowngenerator;
/**
* Created by steppschuh on 23/12/2016.
*/
public class MarkdownBuilderTest {
@Test
public void example1() throws Exception {
MarkdownBuilder builder = new TextBuilder()
.heading("Markdown Builder")
.append("Demonstrating: ")
.append(bold("Bold Text"))
.newParagraph()
.beginList()
.append("I should be an item")
.append(italic("I should be an italic item"))
.end()
.newParagraph()
.beginQuote()
.append("I should be a quote").newLine()
.append("I should still be a quote")
.end()
.newParagraph()
.beginCodeBlock(CodeBlock.LANGUAGE_JAVA)
.append("// I should be code").newLine()
.append("dummyMethod(this);")
.end()
.newParagraph()
.append("Over.");
System.out.println(builder.toString());
}
@Test
public void example2() throws Exception {
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/list/ListBuilder.java
// public class ListBuilder extends MarkdownBuilder<ListBuilder, UnorderedList> {
//
// public ListBuilder() {
// super();
// }
//
// public ListBuilder(MarkdownBuilder parentBuilder) {
// super(parentBuilder);
// }
//
// @Override
// protected ListBuilder getBuilder() {
// return this;
// }
//
// @Override
// protected UnorderedList createMarkdownElement() {
// return new UnorderedList();
// }
//
// @Override
// public ListBuilder append(Object value) {
// markdownElement.getItems().add(value);
// return this;
// }
//
// @Override
// public ListBuilder append(MarkdownSerializable value) {
// if (value instanceof ListBuilder) {
// UnorderedList unorderedList = ((ListBuilder) value).markdownElement;
// unorderedList.incrementIndentationLevel();
// markdownElement.getItems().add(unorderedList);
// return this;
// }
// return super.append(value);
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/TextBuilder.java
// public class TextBuilder extends MarkdownBuilder<TextBuilder, Text> {
//
// public TextBuilder() {
// }
//
// public TextBuilder(MarkdownBuilder parentBuilder) {
// super(parentBuilder);
// }
//
// @Override
// protected TextBuilder getBuilder() {
// return this;
// }
//
// @Override
// protected Text createMarkdownElement() {
// return new Text("");
// }
//
// @Override
// public TextBuilder append(Object value) {
// StringBuilder sb = new StringBuilder();
// if (markdownElement.getValue() != null) {
// sb.append(markdownElement.getValue());
// }
// sb.append(value);
// markdownElement.setValue(sb);
// return this;
// }
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/code/CodeBlock.java
// public class CodeBlock extends Text {
//
// public static final String LANGUAGE_UNKNOWN = "";
// public static final String LANGUAGE_JAVA = "java";
// public static final String LANGUAGE_MARKDOWN = "markdown";
//
// private String language = LANGUAGE_UNKNOWN;
//
// public CodeBlock(Object value) {
// this(value, "");
// }
//
// public CodeBlock(Object value, String language) {
// super(value);
// this.language = language;
// }
//
// @Override
// public String getPredecessor() {
// return "```" + language + System.lineSeparator();
// }
//
// @Override
// public String getSuccessor() {
// return System.lineSeparator() + "```";
// }
//
// public String getLanguage() {
// return language;
// }
//
// public void setLanguage(String language) {
// this.language = language;
// invalidateSerialized();
// }
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/Markdown.java
// public static BoldText bold(String value) {
// return new BoldText(value);
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/Markdown.java
// public static ItalicText italic(String value) {
// return new ItalicText(value);
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/Markdown.java
// public static TaskListItem task(String value) {
// return new TaskListItem(value);
// }
// Path: Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/MarkdownBuilderTest.java
import net.steppschuh.markdowngenerator.list.ListBuilder;
import net.steppschuh.markdowngenerator.text.TextBuilder;
import net.steppschuh.markdowngenerator.text.code.CodeBlock;
import org.junit.Test;
import static net.steppschuh.markdowngenerator.Markdown.bold;
import static net.steppschuh.markdowngenerator.Markdown.italic;
import static net.steppschuh.markdowngenerator.Markdown.task;
package net.steppschuh.markdowngenerator;
/**
* Created by steppschuh on 23/12/2016.
*/
public class MarkdownBuilderTest {
@Test
public void example1() throws Exception {
MarkdownBuilder builder = new TextBuilder()
.heading("Markdown Builder")
.append("Demonstrating: ")
.append(bold("Bold Text"))
.newParagraph()
.beginList()
.append("I should be an item")
.append(italic("I should be an italic item"))
.end()
.newParagraph()
.beginQuote()
.append("I should be a quote").newLine()
.append("I should still be a quote")
.end()
.newParagraph()
.beginCodeBlock(CodeBlock.LANGUAGE_JAVA)
.append("// I should be code").newLine()
.append("dummyMethod(this);")
.end()
.newParagraph()
.append("Over.");
System.out.println(builder.toString());
}
@Test
public void example2() throws Exception {
|
MarkdownBuilder builder = new ListBuilder()
|
Steppschuh/Java-Markdown-Generator
|
Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/MarkdownBuilderTest.java
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/list/ListBuilder.java
// public class ListBuilder extends MarkdownBuilder<ListBuilder, UnorderedList> {
//
// public ListBuilder() {
// super();
// }
//
// public ListBuilder(MarkdownBuilder parentBuilder) {
// super(parentBuilder);
// }
//
// @Override
// protected ListBuilder getBuilder() {
// return this;
// }
//
// @Override
// protected UnorderedList createMarkdownElement() {
// return new UnorderedList();
// }
//
// @Override
// public ListBuilder append(Object value) {
// markdownElement.getItems().add(value);
// return this;
// }
//
// @Override
// public ListBuilder append(MarkdownSerializable value) {
// if (value instanceof ListBuilder) {
// UnorderedList unorderedList = ((ListBuilder) value).markdownElement;
// unorderedList.incrementIndentationLevel();
// markdownElement.getItems().add(unorderedList);
// return this;
// }
// return super.append(value);
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/TextBuilder.java
// public class TextBuilder extends MarkdownBuilder<TextBuilder, Text> {
//
// public TextBuilder() {
// }
//
// public TextBuilder(MarkdownBuilder parentBuilder) {
// super(parentBuilder);
// }
//
// @Override
// protected TextBuilder getBuilder() {
// return this;
// }
//
// @Override
// protected Text createMarkdownElement() {
// return new Text("");
// }
//
// @Override
// public TextBuilder append(Object value) {
// StringBuilder sb = new StringBuilder();
// if (markdownElement.getValue() != null) {
// sb.append(markdownElement.getValue());
// }
// sb.append(value);
// markdownElement.setValue(sb);
// return this;
// }
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/code/CodeBlock.java
// public class CodeBlock extends Text {
//
// public static final String LANGUAGE_UNKNOWN = "";
// public static final String LANGUAGE_JAVA = "java";
// public static final String LANGUAGE_MARKDOWN = "markdown";
//
// private String language = LANGUAGE_UNKNOWN;
//
// public CodeBlock(Object value) {
// this(value, "");
// }
//
// public CodeBlock(Object value, String language) {
// super(value);
// this.language = language;
// }
//
// @Override
// public String getPredecessor() {
// return "```" + language + System.lineSeparator();
// }
//
// @Override
// public String getSuccessor() {
// return System.lineSeparator() + "```";
// }
//
// public String getLanguage() {
// return language;
// }
//
// public void setLanguage(String language) {
// this.language = language;
// invalidateSerialized();
// }
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/Markdown.java
// public static BoldText bold(String value) {
// return new BoldText(value);
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/Markdown.java
// public static ItalicText italic(String value) {
// return new ItalicText(value);
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/Markdown.java
// public static TaskListItem task(String value) {
// return new TaskListItem(value);
// }
|
import net.steppschuh.markdowngenerator.list.ListBuilder;
import net.steppschuh.markdowngenerator.text.TextBuilder;
import net.steppschuh.markdowngenerator.text.code.CodeBlock;
import org.junit.Test;
import static net.steppschuh.markdowngenerator.Markdown.bold;
import static net.steppschuh.markdowngenerator.Markdown.italic;
import static net.steppschuh.markdowngenerator.Markdown.task;
|
}
@Test
public void example3() throws Exception {
MarkdownBuilder builder = new TextBuilder()
.heading("Markdown Builder")
.text("Demonstrating: ").bold("Bold Text")
.newParagraph()
.quote("I should be a quote\nI should still be a quote")
.beginQuote()
.text("I should be a quote").newLine()
.text("I should still be a quote")
.end()
.newParagraph()
.code("INLINE_CODE")
.beginCodeBlock(CodeBlock.LANGUAGE_JAVA)
.text("// some comment").newLine()
.text("dummyMethod(this);")
.end()
.subHeading("Lists")
.unorderedList(
"I should be an item",
italic("I should be an italic item")
)
.beginList()
.text("I should be an item")
.italic("I should be an italic item")
.end()
.newParagraph()
.taskList(
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/list/ListBuilder.java
// public class ListBuilder extends MarkdownBuilder<ListBuilder, UnorderedList> {
//
// public ListBuilder() {
// super();
// }
//
// public ListBuilder(MarkdownBuilder parentBuilder) {
// super(parentBuilder);
// }
//
// @Override
// protected ListBuilder getBuilder() {
// return this;
// }
//
// @Override
// protected UnorderedList createMarkdownElement() {
// return new UnorderedList();
// }
//
// @Override
// public ListBuilder append(Object value) {
// markdownElement.getItems().add(value);
// return this;
// }
//
// @Override
// public ListBuilder append(MarkdownSerializable value) {
// if (value instanceof ListBuilder) {
// UnorderedList unorderedList = ((ListBuilder) value).markdownElement;
// unorderedList.incrementIndentationLevel();
// markdownElement.getItems().add(unorderedList);
// return this;
// }
// return super.append(value);
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/TextBuilder.java
// public class TextBuilder extends MarkdownBuilder<TextBuilder, Text> {
//
// public TextBuilder() {
// }
//
// public TextBuilder(MarkdownBuilder parentBuilder) {
// super(parentBuilder);
// }
//
// @Override
// protected TextBuilder getBuilder() {
// return this;
// }
//
// @Override
// protected Text createMarkdownElement() {
// return new Text("");
// }
//
// @Override
// public TextBuilder append(Object value) {
// StringBuilder sb = new StringBuilder();
// if (markdownElement.getValue() != null) {
// sb.append(markdownElement.getValue());
// }
// sb.append(value);
// markdownElement.setValue(sb);
// return this;
// }
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/code/CodeBlock.java
// public class CodeBlock extends Text {
//
// public static final String LANGUAGE_UNKNOWN = "";
// public static final String LANGUAGE_JAVA = "java";
// public static final String LANGUAGE_MARKDOWN = "markdown";
//
// private String language = LANGUAGE_UNKNOWN;
//
// public CodeBlock(Object value) {
// this(value, "");
// }
//
// public CodeBlock(Object value, String language) {
// super(value);
// this.language = language;
// }
//
// @Override
// public String getPredecessor() {
// return "```" + language + System.lineSeparator();
// }
//
// @Override
// public String getSuccessor() {
// return System.lineSeparator() + "```";
// }
//
// public String getLanguage() {
// return language;
// }
//
// public void setLanguage(String language) {
// this.language = language;
// invalidateSerialized();
// }
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/Markdown.java
// public static BoldText bold(String value) {
// return new BoldText(value);
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/Markdown.java
// public static ItalicText italic(String value) {
// return new ItalicText(value);
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/Markdown.java
// public static TaskListItem task(String value) {
// return new TaskListItem(value);
// }
// Path: Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/MarkdownBuilderTest.java
import net.steppschuh.markdowngenerator.list.ListBuilder;
import net.steppschuh.markdowngenerator.text.TextBuilder;
import net.steppschuh.markdowngenerator.text.code.CodeBlock;
import org.junit.Test;
import static net.steppschuh.markdowngenerator.Markdown.bold;
import static net.steppschuh.markdowngenerator.Markdown.italic;
import static net.steppschuh.markdowngenerator.Markdown.task;
}
@Test
public void example3() throws Exception {
MarkdownBuilder builder = new TextBuilder()
.heading("Markdown Builder")
.text("Demonstrating: ").bold("Bold Text")
.newParagraph()
.quote("I should be a quote\nI should still be a quote")
.beginQuote()
.text("I should be a quote").newLine()
.text("I should still be a quote")
.end()
.newParagraph()
.code("INLINE_CODE")
.beginCodeBlock(CodeBlock.LANGUAGE_JAVA)
.text("// some comment").newLine()
.text("dummyMethod(this);")
.end()
.subHeading("Lists")
.unorderedList(
"I should be an item",
italic("I should be an italic item")
)
.beginList()
.text("I should be an item")
.italic("I should be an italic item")
.end()
.newParagraph()
.taskList(
|
task("Task 1", true),
|
Steppschuh/Java-Markdown-Generator
|
Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/progress/ProgressBar.java
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownElement.java
// public abstract class MarkdownElement implements MarkdownSerializable {
//
// private String serialized;
//
// /**
// * Attempts to generate a String representing this markdown element.
// *
// * @return Markdown as String
// * @throws MarkdownSerializationException If unable to generate a markdown String
// */
// public abstract String serialize() throws MarkdownSerializationException;
//
// /**
// * Returns the result of {@link MarkdownElement#getSerialized()} or the specified fallback if a
// * {@link MarkdownSerializationException} occurred.
// *
// * @param fallback String to return if serialization fails
// * @return Markdown as String or specified fallback
// */
// public String getSerialized(String fallback) {
// try {
// return getSerialized();
// } catch (MarkdownSerializationException e) {
// return fallback;
// }
// }
//
// /**
// * Calls {@link MarkdownElement#serialize()} or directly returns its last result from {@link
// * MarkdownElement#serialized}.
// *
// * @return Markdown as String
// * @throws MarkdownSerializationException If unable to generate a markdown String
// */
// public String getSerialized() throws MarkdownSerializationException {
// if (serialized == null) {
// serialized = serialize();
// }
// return serialized;
// }
//
// public void setSerialized(String serialized) {
// this.serialized = serialized;
// }
//
// /**
// * Sets {@link MarkdownElement#serialized} to null. The next call to {@link
// * MarkdownElement#getSerialized()} fill invoke a fresh serialization.
// */
// public void invalidateSerialized() {
// setSerialized(null);
// }
//
// @Override
// public MarkdownElement toMarkdownElement() throws MarkdownSerializationException {
// return this;
// }
//
// @Override
// public String toString() {
// return getSerialized(this.getClass().getSimpleName());
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownSerializationException.java
// public class MarkdownSerializationException extends Exception {
//
// public MarkdownSerializationException() {
// super();
// }
//
// public MarkdownSerializationException(String s) {
// super(s);
// }
//
// public MarkdownSerializationException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public MarkdownSerializationException(Throwable throwable) {
// super(throwable);
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/util/StringUtil.java
// public abstract class StringUtil {
//
// public static String fillUpAligned(String value, String fill, int length, int alignment) {
// switch (alignment) {
// case Table.ALIGN_RIGHT: {
// return fillUpRightAligned(value, fill, length);
// }
// case Table.ALIGN_CENTER: {
// return fillUpCenterAligned(value, fill, length);
// }
// default: {
// return fillUpLeftAligned(value, fill, length);
// }
// }
// }
//
// public static String fillUpLeftAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// while (value.length() < length) {
// value += fill;
// }
// return value;
// }
//
// public static String fillUpRightAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// while (value.length() < length) {
// value = fill + value;
// }
// return value;
// }
//
// public static String fillUpCenterAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// boolean left = true;
// while (value.length() < length) {
// if (left) {
// value = fillUpLeftAligned(value, fill, value.length() + 1);
// } else {
// value = fillUpRightAligned(value, fill, value.length() + 1);
// }
// left = !left;
// }
// return value;
// }
//
// public static String surroundValueWith(String value, String surrounding) {
// return surrounding + value + surrounding;
// }
//
// }
|
import net.steppschuh.markdowngenerator.MarkdownElement;
import net.steppschuh.markdowngenerator.MarkdownSerializationException;
import net.steppschuh.markdowngenerator.util.StringUtil;
|
package net.steppschuh.markdowngenerator.progress;
/**
* Created by Stephan on 12/18/2016.
*/
public class ProgressBar extends MarkdownElement {
public static final int LENGTH_SMALL = 15;
public static final int LENGTH_NORMAL = 20;
public static final int LENGTH_LARGE = 50;
public static final char OPENING_CHAR_DEFAULT = '[';
public static final char CLOSING_CHAR_DEFAULT = ']';
public static final char FILL_CHAR_DEFAULT = '=';
public static final char EMPTY_CHAR_DEFAULT = '-';
private char openingChar = OPENING_CHAR_DEFAULT;
private char closingChar = CLOSING_CHAR_DEFAULT;
private char fillChar = FILL_CHAR_DEFAULT;
private char emptyChar = EMPTY_CHAR_DEFAULT;
private int length = LENGTH_NORMAL;
private boolean appendValue = false;
private boolean appendPercentage = false;
private double value;
private double minimumValue = 0;
private double maximumValue = 1;
public ProgressBar(double value) {
this.value = value;
}
public ProgressBar(double value, int length) {
this.value = value;
this.length = length;
}
private void trimValue() {
value = Math.max(minimumValue, Math.min(maximumValue, value));
}
@Override
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownElement.java
// public abstract class MarkdownElement implements MarkdownSerializable {
//
// private String serialized;
//
// /**
// * Attempts to generate a String representing this markdown element.
// *
// * @return Markdown as String
// * @throws MarkdownSerializationException If unable to generate a markdown String
// */
// public abstract String serialize() throws MarkdownSerializationException;
//
// /**
// * Returns the result of {@link MarkdownElement#getSerialized()} or the specified fallback if a
// * {@link MarkdownSerializationException} occurred.
// *
// * @param fallback String to return if serialization fails
// * @return Markdown as String or specified fallback
// */
// public String getSerialized(String fallback) {
// try {
// return getSerialized();
// } catch (MarkdownSerializationException e) {
// return fallback;
// }
// }
//
// /**
// * Calls {@link MarkdownElement#serialize()} or directly returns its last result from {@link
// * MarkdownElement#serialized}.
// *
// * @return Markdown as String
// * @throws MarkdownSerializationException If unable to generate a markdown String
// */
// public String getSerialized() throws MarkdownSerializationException {
// if (serialized == null) {
// serialized = serialize();
// }
// return serialized;
// }
//
// public void setSerialized(String serialized) {
// this.serialized = serialized;
// }
//
// /**
// * Sets {@link MarkdownElement#serialized} to null. The next call to {@link
// * MarkdownElement#getSerialized()} fill invoke a fresh serialization.
// */
// public void invalidateSerialized() {
// setSerialized(null);
// }
//
// @Override
// public MarkdownElement toMarkdownElement() throws MarkdownSerializationException {
// return this;
// }
//
// @Override
// public String toString() {
// return getSerialized(this.getClass().getSimpleName());
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownSerializationException.java
// public class MarkdownSerializationException extends Exception {
//
// public MarkdownSerializationException() {
// super();
// }
//
// public MarkdownSerializationException(String s) {
// super(s);
// }
//
// public MarkdownSerializationException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public MarkdownSerializationException(Throwable throwable) {
// super(throwable);
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/util/StringUtil.java
// public abstract class StringUtil {
//
// public static String fillUpAligned(String value, String fill, int length, int alignment) {
// switch (alignment) {
// case Table.ALIGN_RIGHT: {
// return fillUpRightAligned(value, fill, length);
// }
// case Table.ALIGN_CENTER: {
// return fillUpCenterAligned(value, fill, length);
// }
// default: {
// return fillUpLeftAligned(value, fill, length);
// }
// }
// }
//
// public static String fillUpLeftAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// while (value.length() < length) {
// value += fill;
// }
// return value;
// }
//
// public static String fillUpRightAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// while (value.length() < length) {
// value = fill + value;
// }
// return value;
// }
//
// public static String fillUpCenterAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// boolean left = true;
// while (value.length() < length) {
// if (left) {
// value = fillUpLeftAligned(value, fill, value.length() + 1);
// } else {
// value = fillUpRightAligned(value, fill, value.length() + 1);
// }
// left = !left;
// }
// return value;
// }
//
// public static String surroundValueWith(String value, String surrounding) {
// return surrounding + value + surrounding;
// }
//
// }
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/progress/ProgressBar.java
import net.steppschuh.markdowngenerator.MarkdownElement;
import net.steppschuh.markdowngenerator.MarkdownSerializationException;
import net.steppschuh.markdowngenerator.util.StringUtil;
package net.steppschuh.markdowngenerator.progress;
/**
* Created by Stephan on 12/18/2016.
*/
public class ProgressBar extends MarkdownElement {
public static final int LENGTH_SMALL = 15;
public static final int LENGTH_NORMAL = 20;
public static final int LENGTH_LARGE = 50;
public static final char OPENING_CHAR_DEFAULT = '[';
public static final char CLOSING_CHAR_DEFAULT = ']';
public static final char FILL_CHAR_DEFAULT = '=';
public static final char EMPTY_CHAR_DEFAULT = '-';
private char openingChar = OPENING_CHAR_DEFAULT;
private char closingChar = CLOSING_CHAR_DEFAULT;
private char fillChar = FILL_CHAR_DEFAULT;
private char emptyChar = EMPTY_CHAR_DEFAULT;
private int length = LENGTH_NORMAL;
private boolean appendValue = false;
private boolean appendPercentage = false;
private double value;
private double minimumValue = 0;
private double maximumValue = 1;
public ProgressBar(double value) {
this.value = value;
}
public ProgressBar(double value, int length) {
this.value = value;
this.length = length;
}
private void trimValue() {
value = Math.max(minimumValue, Math.min(maximumValue, value));
}
@Override
|
public String serialize() throws MarkdownSerializationException {
|
Steppschuh/Java-Markdown-Generator
|
Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/progress/ProgressBar.java
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownElement.java
// public abstract class MarkdownElement implements MarkdownSerializable {
//
// private String serialized;
//
// /**
// * Attempts to generate a String representing this markdown element.
// *
// * @return Markdown as String
// * @throws MarkdownSerializationException If unable to generate a markdown String
// */
// public abstract String serialize() throws MarkdownSerializationException;
//
// /**
// * Returns the result of {@link MarkdownElement#getSerialized()} or the specified fallback if a
// * {@link MarkdownSerializationException} occurred.
// *
// * @param fallback String to return if serialization fails
// * @return Markdown as String or specified fallback
// */
// public String getSerialized(String fallback) {
// try {
// return getSerialized();
// } catch (MarkdownSerializationException e) {
// return fallback;
// }
// }
//
// /**
// * Calls {@link MarkdownElement#serialize()} or directly returns its last result from {@link
// * MarkdownElement#serialized}.
// *
// * @return Markdown as String
// * @throws MarkdownSerializationException If unable to generate a markdown String
// */
// public String getSerialized() throws MarkdownSerializationException {
// if (serialized == null) {
// serialized = serialize();
// }
// return serialized;
// }
//
// public void setSerialized(String serialized) {
// this.serialized = serialized;
// }
//
// /**
// * Sets {@link MarkdownElement#serialized} to null. The next call to {@link
// * MarkdownElement#getSerialized()} fill invoke a fresh serialization.
// */
// public void invalidateSerialized() {
// setSerialized(null);
// }
//
// @Override
// public MarkdownElement toMarkdownElement() throws MarkdownSerializationException {
// return this;
// }
//
// @Override
// public String toString() {
// return getSerialized(this.getClass().getSimpleName());
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownSerializationException.java
// public class MarkdownSerializationException extends Exception {
//
// public MarkdownSerializationException() {
// super();
// }
//
// public MarkdownSerializationException(String s) {
// super(s);
// }
//
// public MarkdownSerializationException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public MarkdownSerializationException(Throwable throwable) {
// super(throwable);
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/util/StringUtil.java
// public abstract class StringUtil {
//
// public static String fillUpAligned(String value, String fill, int length, int alignment) {
// switch (alignment) {
// case Table.ALIGN_RIGHT: {
// return fillUpRightAligned(value, fill, length);
// }
// case Table.ALIGN_CENTER: {
// return fillUpCenterAligned(value, fill, length);
// }
// default: {
// return fillUpLeftAligned(value, fill, length);
// }
// }
// }
//
// public static String fillUpLeftAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// while (value.length() < length) {
// value += fill;
// }
// return value;
// }
//
// public static String fillUpRightAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// while (value.length() < length) {
// value = fill + value;
// }
// return value;
// }
//
// public static String fillUpCenterAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// boolean left = true;
// while (value.length() < length) {
// if (left) {
// value = fillUpLeftAligned(value, fill, value.length() + 1);
// } else {
// value = fillUpRightAligned(value, fill, value.length() + 1);
// }
// left = !left;
// }
// return value;
// }
//
// public static String surroundValueWith(String value, String surrounding) {
// return surrounding + value + surrounding;
// }
//
// }
|
import net.steppschuh.markdowngenerator.MarkdownElement;
import net.steppschuh.markdowngenerator.MarkdownSerializationException;
import net.steppschuh.markdowngenerator.util.StringUtil;
|
private boolean appendPercentage = false;
private double value;
private double minimumValue = 0;
private double maximumValue = 1;
public ProgressBar(double value) {
this.value = value;
}
public ProgressBar(double value, int length) {
this.value = value;
this.length = length;
}
private void trimValue() {
value = Math.max(minimumValue, Math.min(maximumValue, value));
}
@Override
public String serialize() throws MarkdownSerializationException {
trimValue();
StringBuilder sb = new StringBuilder().append(openingChar);
int filledCharsCount = calculateFilledCharsCount(value, minimumValue, maximumValue, length);
for (int charIndex = 0; charIndex < length; charIndex++) {
sb.append((charIndex < filledCharsCount) ? fillChar : emptyChar);
}
sb.append(closingChar);
if (appendValue) {
String readableValue = getReadableValue(value);
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownElement.java
// public abstract class MarkdownElement implements MarkdownSerializable {
//
// private String serialized;
//
// /**
// * Attempts to generate a String representing this markdown element.
// *
// * @return Markdown as String
// * @throws MarkdownSerializationException If unable to generate a markdown String
// */
// public abstract String serialize() throws MarkdownSerializationException;
//
// /**
// * Returns the result of {@link MarkdownElement#getSerialized()} or the specified fallback if a
// * {@link MarkdownSerializationException} occurred.
// *
// * @param fallback String to return if serialization fails
// * @return Markdown as String or specified fallback
// */
// public String getSerialized(String fallback) {
// try {
// return getSerialized();
// } catch (MarkdownSerializationException e) {
// return fallback;
// }
// }
//
// /**
// * Calls {@link MarkdownElement#serialize()} or directly returns its last result from {@link
// * MarkdownElement#serialized}.
// *
// * @return Markdown as String
// * @throws MarkdownSerializationException If unable to generate a markdown String
// */
// public String getSerialized() throws MarkdownSerializationException {
// if (serialized == null) {
// serialized = serialize();
// }
// return serialized;
// }
//
// public void setSerialized(String serialized) {
// this.serialized = serialized;
// }
//
// /**
// * Sets {@link MarkdownElement#serialized} to null. The next call to {@link
// * MarkdownElement#getSerialized()} fill invoke a fresh serialization.
// */
// public void invalidateSerialized() {
// setSerialized(null);
// }
//
// @Override
// public MarkdownElement toMarkdownElement() throws MarkdownSerializationException {
// return this;
// }
//
// @Override
// public String toString() {
// return getSerialized(this.getClass().getSimpleName());
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownSerializationException.java
// public class MarkdownSerializationException extends Exception {
//
// public MarkdownSerializationException() {
// super();
// }
//
// public MarkdownSerializationException(String s) {
// super(s);
// }
//
// public MarkdownSerializationException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public MarkdownSerializationException(Throwable throwable) {
// super(throwable);
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/util/StringUtil.java
// public abstract class StringUtil {
//
// public static String fillUpAligned(String value, String fill, int length, int alignment) {
// switch (alignment) {
// case Table.ALIGN_RIGHT: {
// return fillUpRightAligned(value, fill, length);
// }
// case Table.ALIGN_CENTER: {
// return fillUpCenterAligned(value, fill, length);
// }
// default: {
// return fillUpLeftAligned(value, fill, length);
// }
// }
// }
//
// public static String fillUpLeftAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// while (value.length() < length) {
// value += fill;
// }
// return value;
// }
//
// public static String fillUpRightAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// while (value.length() < length) {
// value = fill + value;
// }
// return value;
// }
//
// public static String fillUpCenterAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// boolean left = true;
// while (value.length() < length) {
// if (left) {
// value = fillUpLeftAligned(value, fill, value.length() + 1);
// } else {
// value = fillUpRightAligned(value, fill, value.length() + 1);
// }
// left = !left;
// }
// return value;
// }
//
// public static String surroundValueWith(String value, String surrounding) {
// return surrounding + value + surrounding;
// }
//
// }
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/progress/ProgressBar.java
import net.steppschuh.markdowngenerator.MarkdownElement;
import net.steppschuh.markdowngenerator.MarkdownSerializationException;
import net.steppschuh.markdowngenerator.util.StringUtil;
private boolean appendPercentage = false;
private double value;
private double minimumValue = 0;
private double maximumValue = 1;
public ProgressBar(double value) {
this.value = value;
}
public ProgressBar(double value, int length) {
this.value = value;
this.length = length;
}
private void trimValue() {
value = Math.max(minimumValue, Math.min(maximumValue, value));
}
@Override
public String serialize() throws MarkdownSerializationException {
trimValue();
StringBuilder sb = new StringBuilder().append(openingChar);
int filledCharsCount = calculateFilledCharsCount(value, minimumValue, maximumValue, length);
for (int charIndex = 0; charIndex < length; charIndex++) {
sb.append((charIndex < filledCharsCount) ? fillChar : emptyChar);
}
sb.append(closingChar);
if (appendValue) {
String readableValue = getReadableValue(value);
|
readableValue = StringUtil.fillUpRightAligned(readableValue, " ", 7);
|
Steppschuh/Java-Markdown-Generator
|
Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/text/emphasis/BoldTextTest.java
|
// Path: Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/DummyObject.java
// public class DummyObject implements MarkdownSerializable {
//
// private Object foo;
// private String bar;
// private int baz;
//
// public DummyObject() {
// this.foo = true;
// this.bar = "qux";
// this.baz = 1337;
// }
//
// public DummyObject(Object foo, String bar, int baz) {
// this.foo = foo;
// this.bar = bar;
// this.baz = baz;
// }
//
// public TableRow toMarkdownTableRow() {
// return new TableRow<>(Arrays.asList(
// foo, bar, baz
// ));
// }
//
// @Override
// public MarkdownElement toMarkdownElement() throws MarkdownSerializationException {
// return toMarkdownTableRow();
// }
//
// @Override
// public String toString() {
// try {
// return toMarkdownElement().toString();
// } catch (MarkdownSerializationException e) {
// return this.getClass().getSimpleName();
// }
// }
//
// public Object getFoo() {
// return foo;
// }
//
// public String getBar() {
// return bar;
// }
//
// public int getBaz() {
// return baz;
// }
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/Text.java
// public class Text extends MarkdownElement implements MarkdownCascadable {
//
// protected Object value;
//
// public Text(Object value) {
// this.value = value;
// }
//
// @Override
// public String serialize() throws MarkdownSerializationException {
// if (value == null) {
// throw new MarkdownSerializationException("Value is null");
// }
// return getPredecessor() + value.toString() + getSuccessor();
// }
//
// @Override
// public String getPredecessor() {
// return "";
// }
//
// @Override
// public String getSuccessor() {
// return getPredecessor();
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// invalidateSerialized();
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/emphasis/BoldText.java
// public class BoldText extends Text {
//
// public BoldText(Object value) {
// super(value);
// }
//
// @Override
// public String getPredecessor() {
// return "**";
// }
//
// }
|
import net.steppschuh.markdowngenerator.DummyObject;
import net.steppschuh.markdowngenerator.text.Text;
import net.steppschuh.markdowngenerator.text.emphasis.BoldText;
import org.junit.Test;
|
package net.steppschuh.markdowngenerator.text.emphasis;
/**
* Created by steppschuh on 15/12/2016.
*/
public class BoldTextTest {
@Test
public void example1() throws Exception {
|
// Path: Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/DummyObject.java
// public class DummyObject implements MarkdownSerializable {
//
// private Object foo;
// private String bar;
// private int baz;
//
// public DummyObject() {
// this.foo = true;
// this.bar = "qux";
// this.baz = 1337;
// }
//
// public DummyObject(Object foo, String bar, int baz) {
// this.foo = foo;
// this.bar = bar;
// this.baz = baz;
// }
//
// public TableRow toMarkdownTableRow() {
// return new TableRow<>(Arrays.asList(
// foo, bar, baz
// ));
// }
//
// @Override
// public MarkdownElement toMarkdownElement() throws MarkdownSerializationException {
// return toMarkdownTableRow();
// }
//
// @Override
// public String toString() {
// try {
// return toMarkdownElement().toString();
// } catch (MarkdownSerializationException e) {
// return this.getClass().getSimpleName();
// }
// }
//
// public Object getFoo() {
// return foo;
// }
//
// public String getBar() {
// return bar;
// }
//
// public int getBaz() {
// return baz;
// }
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/Text.java
// public class Text extends MarkdownElement implements MarkdownCascadable {
//
// protected Object value;
//
// public Text(Object value) {
// this.value = value;
// }
//
// @Override
// public String serialize() throws MarkdownSerializationException {
// if (value == null) {
// throw new MarkdownSerializationException("Value is null");
// }
// return getPredecessor() + value.toString() + getSuccessor();
// }
//
// @Override
// public String getPredecessor() {
// return "";
// }
//
// @Override
// public String getSuccessor() {
// return getPredecessor();
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// invalidateSerialized();
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/emphasis/BoldText.java
// public class BoldText extends Text {
//
// public BoldText(Object value) {
// super(value);
// }
//
// @Override
// public String getPredecessor() {
// return "**";
// }
//
// }
// Path: Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/text/emphasis/BoldTextTest.java
import net.steppschuh.markdowngenerator.DummyObject;
import net.steppschuh.markdowngenerator.text.Text;
import net.steppschuh.markdowngenerator.text.emphasis.BoldText;
import org.junit.Test;
package net.steppschuh.markdowngenerator.text.emphasis;
/**
* Created by steppschuh on 15/12/2016.
*/
public class BoldTextTest {
@Test
public void example1() throws Exception {
|
Text text = new BoldText("I am bold text");
|
Steppschuh/Java-Markdown-Generator
|
Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/text/emphasis/BoldTextTest.java
|
// Path: Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/DummyObject.java
// public class DummyObject implements MarkdownSerializable {
//
// private Object foo;
// private String bar;
// private int baz;
//
// public DummyObject() {
// this.foo = true;
// this.bar = "qux";
// this.baz = 1337;
// }
//
// public DummyObject(Object foo, String bar, int baz) {
// this.foo = foo;
// this.bar = bar;
// this.baz = baz;
// }
//
// public TableRow toMarkdownTableRow() {
// return new TableRow<>(Arrays.asList(
// foo, bar, baz
// ));
// }
//
// @Override
// public MarkdownElement toMarkdownElement() throws MarkdownSerializationException {
// return toMarkdownTableRow();
// }
//
// @Override
// public String toString() {
// try {
// return toMarkdownElement().toString();
// } catch (MarkdownSerializationException e) {
// return this.getClass().getSimpleName();
// }
// }
//
// public Object getFoo() {
// return foo;
// }
//
// public String getBar() {
// return bar;
// }
//
// public int getBaz() {
// return baz;
// }
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/Text.java
// public class Text extends MarkdownElement implements MarkdownCascadable {
//
// protected Object value;
//
// public Text(Object value) {
// this.value = value;
// }
//
// @Override
// public String serialize() throws MarkdownSerializationException {
// if (value == null) {
// throw new MarkdownSerializationException("Value is null");
// }
// return getPredecessor() + value.toString() + getSuccessor();
// }
//
// @Override
// public String getPredecessor() {
// return "";
// }
//
// @Override
// public String getSuccessor() {
// return getPredecessor();
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// invalidateSerialized();
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/emphasis/BoldText.java
// public class BoldText extends Text {
//
// public BoldText(Object value) {
// super(value);
// }
//
// @Override
// public String getPredecessor() {
// return "**";
// }
//
// }
|
import net.steppschuh.markdowngenerator.DummyObject;
import net.steppschuh.markdowngenerator.text.Text;
import net.steppschuh.markdowngenerator.text.emphasis.BoldText;
import org.junit.Test;
|
package net.steppschuh.markdowngenerator.text.emphasis;
/**
* Created by steppschuh on 15/12/2016.
*/
public class BoldTextTest {
@Test
public void example1() throws Exception {
|
// Path: Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/DummyObject.java
// public class DummyObject implements MarkdownSerializable {
//
// private Object foo;
// private String bar;
// private int baz;
//
// public DummyObject() {
// this.foo = true;
// this.bar = "qux";
// this.baz = 1337;
// }
//
// public DummyObject(Object foo, String bar, int baz) {
// this.foo = foo;
// this.bar = bar;
// this.baz = baz;
// }
//
// public TableRow toMarkdownTableRow() {
// return new TableRow<>(Arrays.asList(
// foo, bar, baz
// ));
// }
//
// @Override
// public MarkdownElement toMarkdownElement() throws MarkdownSerializationException {
// return toMarkdownTableRow();
// }
//
// @Override
// public String toString() {
// try {
// return toMarkdownElement().toString();
// } catch (MarkdownSerializationException e) {
// return this.getClass().getSimpleName();
// }
// }
//
// public Object getFoo() {
// return foo;
// }
//
// public String getBar() {
// return bar;
// }
//
// public int getBaz() {
// return baz;
// }
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/Text.java
// public class Text extends MarkdownElement implements MarkdownCascadable {
//
// protected Object value;
//
// public Text(Object value) {
// this.value = value;
// }
//
// @Override
// public String serialize() throws MarkdownSerializationException {
// if (value == null) {
// throw new MarkdownSerializationException("Value is null");
// }
// return getPredecessor() + value.toString() + getSuccessor();
// }
//
// @Override
// public String getPredecessor() {
// return "";
// }
//
// @Override
// public String getSuccessor() {
// return getPredecessor();
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// invalidateSerialized();
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/emphasis/BoldText.java
// public class BoldText extends Text {
//
// public BoldText(Object value) {
// super(value);
// }
//
// @Override
// public String getPredecessor() {
// return "**";
// }
//
// }
// Path: Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/text/emphasis/BoldTextTest.java
import net.steppschuh.markdowngenerator.DummyObject;
import net.steppschuh.markdowngenerator.text.Text;
import net.steppschuh.markdowngenerator.text.emphasis.BoldText;
import org.junit.Test;
package net.steppschuh.markdowngenerator.text.emphasis;
/**
* Created by steppschuh on 15/12/2016.
*/
public class BoldTextTest {
@Test
public void example1() throws Exception {
|
Text text = new BoldText("I am bold text");
|
Steppschuh/Java-Markdown-Generator
|
Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/text/emphasis/BoldTextTest.java
|
// Path: Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/DummyObject.java
// public class DummyObject implements MarkdownSerializable {
//
// private Object foo;
// private String bar;
// private int baz;
//
// public DummyObject() {
// this.foo = true;
// this.bar = "qux";
// this.baz = 1337;
// }
//
// public DummyObject(Object foo, String bar, int baz) {
// this.foo = foo;
// this.bar = bar;
// this.baz = baz;
// }
//
// public TableRow toMarkdownTableRow() {
// return new TableRow<>(Arrays.asList(
// foo, bar, baz
// ));
// }
//
// @Override
// public MarkdownElement toMarkdownElement() throws MarkdownSerializationException {
// return toMarkdownTableRow();
// }
//
// @Override
// public String toString() {
// try {
// return toMarkdownElement().toString();
// } catch (MarkdownSerializationException e) {
// return this.getClass().getSimpleName();
// }
// }
//
// public Object getFoo() {
// return foo;
// }
//
// public String getBar() {
// return bar;
// }
//
// public int getBaz() {
// return baz;
// }
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/Text.java
// public class Text extends MarkdownElement implements MarkdownCascadable {
//
// protected Object value;
//
// public Text(Object value) {
// this.value = value;
// }
//
// @Override
// public String serialize() throws MarkdownSerializationException {
// if (value == null) {
// throw new MarkdownSerializationException("Value is null");
// }
// return getPredecessor() + value.toString() + getSuccessor();
// }
//
// @Override
// public String getPredecessor() {
// return "";
// }
//
// @Override
// public String getSuccessor() {
// return getPredecessor();
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// invalidateSerialized();
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/emphasis/BoldText.java
// public class BoldText extends Text {
//
// public BoldText(Object value) {
// super(value);
// }
//
// @Override
// public String getPredecessor() {
// return "**";
// }
//
// }
|
import net.steppschuh.markdowngenerator.DummyObject;
import net.steppschuh.markdowngenerator.text.Text;
import net.steppschuh.markdowngenerator.text.emphasis.BoldText;
import org.junit.Test;
|
package net.steppschuh.markdowngenerator.text.emphasis;
/**
* Created by steppschuh on 15/12/2016.
*/
public class BoldTextTest {
@Test
public void example1() throws Exception {
Text text = new BoldText("I am bold text");
System.out.println(text);
}
@Test
public void example2() throws Exception {
|
// Path: Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/DummyObject.java
// public class DummyObject implements MarkdownSerializable {
//
// private Object foo;
// private String bar;
// private int baz;
//
// public DummyObject() {
// this.foo = true;
// this.bar = "qux";
// this.baz = 1337;
// }
//
// public DummyObject(Object foo, String bar, int baz) {
// this.foo = foo;
// this.bar = bar;
// this.baz = baz;
// }
//
// public TableRow toMarkdownTableRow() {
// return new TableRow<>(Arrays.asList(
// foo, bar, baz
// ));
// }
//
// @Override
// public MarkdownElement toMarkdownElement() throws MarkdownSerializationException {
// return toMarkdownTableRow();
// }
//
// @Override
// public String toString() {
// try {
// return toMarkdownElement().toString();
// } catch (MarkdownSerializationException e) {
// return this.getClass().getSimpleName();
// }
// }
//
// public Object getFoo() {
// return foo;
// }
//
// public String getBar() {
// return bar;
// }
//
// public int getBaz() {
// return baz;
// }
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/Text.java
// public class Text extends MarkdownElement implements MarkdownCascadable {
//
// protected Object value;
//
// public Text(Object value) {
// this.value = value;
// }
//
// @Override
// public String serialize() throws MarkdownSerializationException {
// if (value == null) {
// throw new MarkdownSerializationException("Value is null");
// }
// return getPredecessor() + value.toString() + getSuccessor();
// }
//
// @Override
// public String getPredecessor() {
// return "";
// }
//
// @Override
// public String getSuccessor() {
// return getPredecessor();
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// invalidateSerialized();
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/emphasis/BoldText.java
// public class BoldText extends Text {
//
// public BoldText(Object value) {
// super(value);
// }
//
// @Override
// public String getPredecessor() {
// return "**";
// }
//
// }
// Path: Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/text/emphasis/BoldTextTest.java
import net.steppschuh.markdowngenerator.DummyObject;
import net.steppschuh.markdowngenerator.text.Text;
import net.steppschuh.markdowngenerator.text.emphasis.BoldText;
import org.junit.Test;
package net.steppschuh.markdowngenerator.text.emphasis;
/**
* Created by steppschuh on 15/12/2016.
*/
public class BoldTextTest {
@Test
public void example1() throws Exception {
Text text = new BoldText("I am bold text");
System.out.println(text);
}
@Test
public void example2() throws Exception {
|
Text text = new BoldText(new DummyObject());
|
Steppschuh/Java-Markdown-Generator
|
Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/heading/Heading.java
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/Text.java
// public class Text extends MarkdownElement implements MarkdownCascadable {
//
// protected Object value;
//
// public Text(Object value) {
// this.value = value;
// }
//
// @Override
// public String serialize() throws MarkdownSerializationException {
// if (value == null) {
// throw new MarkdownSerializationException("Value is null");
// }
// return getPredecessor() + value.toString() + getSuccessor();
// }
//
// @Override
// public String getPredecessor() {
// return "";
// }
//
// @Override
// public String getSuccessor() {
// return getPredecessor();
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// invalidateSerialized();
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/util/StringUtil.java
// public abstract class StringUtil {
//
// public static String fillUpAligned(String value, String fill, int length, int alignment) {
// switch (alignment) {
// case Table.ALIGN_RIGHT: {
// return fillUpRightAligned(value, fill, length);
// }
// case Table.ALIGN_CENTER: {
// return fillUpCenterAligned(value, fill, length);
// }
// default: {
// return fillUpLeftAligned(value, fill, length);
// }
// }
// }
//
// public static String fillUpLeftAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// while (value.length() < length) {
// value += fill;
// }
// return value;
// }
//
// public static String fillUpRightAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// while (value.length() < length) {
// value = fill + value;
// }
// return value;
// }
//
// public static String fillUpCenterAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// boolean left = true;
// while (value.length() < length) {
// if (left) {
// value = fillUpLeftAligned(value, fill, value.length() + 1);
// } else {
// value = fillUpRightAligned(value, fill, value.length() + 1);
// }
// left = !left;
// }
// return value;
// }
//
// public static String surroundValueWith(String value, String surrounding) {
// return surrounding + value + surrounding;
// }
//
// }
|
import net.steppschuh.markdowngenerator.text.Text;
import net.steppschuh.markdowngenerator.util.StringUtil;
|
package net.steppschuh.markdowngenerator.text.heading;
/**
* Created by steppschuh on 16/12/2016.
*/
public class Heading extends Text {
public static final int MINIMUM_LEVEL = 1;
public static final int MAXIMUM_LEVEL = 6;
public static final char UNDERLINE_CHAR_1 = '=';
public static final char UNDERLINE_CHAR_2 = '-';
private int level;
boolean underlineStyle = true;
public Heading(Object value) {
super(value);
this.level = MINIMUM_LEVEL;
}
public Heading(Object value, int level) {
super(value);
this.level = level;
trimLevel();
}
@Override
public String getPredecessor() {
if (underlineStyle && level < 3) {
return "";
}
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/Text.java
// public class Text extends MarkdownElement implements MarkdownCascadable {
//
// protected Object value;
//
// public Text(Object value) {
// this.value = value;
// }
//
// @Override
// public String serialize() throws MarkdownSerializationException {
// if (value == null) {
// throw new MarkdownSerializationException("Value is null");
// }
// return getPredecessor() + value.toString() + getSuccessor();
// }
//
// @Override
// public String getPredecessor() {
// return "";
// }
//
// @Override
// public String getSuccessor() {
// return getPredecessor();
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// invalidateSerialized();
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/util/StringUtil.java
// public abstract class StringUtil {
//
// public static String fillUpAligned(String value, String fill, int length, int alignment) {
// switch (alignment) {
// case Table.ALIGN_RIGHT: {
// return fillUpRightAligned(value, fill, length);
// }
// case Table.ALIGN_CENTER: {
// return fillUpCenterAligned(value, fill, length);
// }
// default: {
// return fillUpLeftAligned(value, fill, length);
// }
// }
// }
//
// public static String fillUpLeftAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// while (value.length() < length) {
// value += fill;
// }
// return value;
// }
//
// public static String fillUpRightAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// while (value.length() < length) {
// value = fill + value;
// }
// return value;
// }
//
// public static String fillUpCenterAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// boolean left = true;
// while (value.length() < length) {
// if (left) {
// value = fillUpLeftAligned(value, fill, value.length() + 1);
// } else {
// value = fillUpRightAligned(value, fill, value.length() + 1);
// }
// left = !left;
// }
// return value;
// }
//
// public static String surroundValueWith(String value, String surrounding) {
// return surrounding + value + surrounding;
// }
//
// }
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/heading/Heading.java
import net.steppschuh.markdowngenerator.text.Text;
import net.steppschuh.markdowngenerator.util.StringUtil;
package net.steppschuh.markdowngenerator.text.heading;
/**
* Created by steppschuh on 16/12/2016.
*/
public class Heading extends Text {
public static final int MINIMUM_LEVEL = 1;
public static final int MAXIMUM_LEVEL = 6;
public static final char UNDERLINE_CHAR_1 = '=';
public static final char UNDERLINE_CHAR_2 = '-';
private int level;
boolean underlineStyle = true;
public Heading(Object value) {
super(value);
this.level = MINIMUM_LEVEL;
}
public Heading(Object value, int level) {
super(value);
this.level = level;
trimLevel();
}
@Override
public String getPredecessor() {
if (underlineStyle && level < 3) {
return "";
}
|
return StringUtil.fillUpRightAligned("", "#", level) + " ";
|
Steppschuh/Java-Markdown-Generator
|
Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/Text.java
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownCascadable.java
// public interface MarkdownCascadable {
//
// /**
// * @return the string that should be added before the value
// */
// String getPredecessor();
//
// /**
// * @return the string that should be added after the value
// */
// String getSuccessor();
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownElement.java
// public abstract class MarkdownElement implements MarkdownSerializable {
//
// private String serialized;
//
// /**
// * Attempts to generate a String representing this markdown element.
// *
// * @return Markdown as String
// * @throws MarkdownSerializationException If unable to generate a markdown String
// */
// public abstract String serialize() throws MarkdownSerializationException;
//
// /**
// * Returns the result of {@link MarkdownElement#getSerialized()} or the specified fallback if a
// * {@link MarkdownSerializationException} occurred.
// *
// * @param fallback String to return if serialization fails
// * @return Markdown as String or specified fallback
// */
// public String getSerialized(String fallback) {
// try {
// return getSerialized();
// } catch (MarkdownSerializationException e) {
// return fallback;
// }
// }
//
// /**
// * Calls {@link MarkdownElement#serialize()} or directly returns its last result from {@link
// * MarkdownElement#serialized}.
// *
// * @return Markdown as String
// * @throws MarkdownSerializationException If unable to generate a markdown String
// */
// public String getSerialized() throws MarkdownSerializationException {
// if (serialized == null) {
// serialized = serialize();
// }
// return serialized;
// }
//
// public void setSerialized(String serialized) {
// this.serialized = serialized;
// }
//
// /**
// * Sets {@link MarkdownElement#serialized} to null. The next call to {@link
// * MarkdownElement#getSerialized()} fill invoke a fresh serialization.
// */
// public void invalidateSerialized() {
// setSerialized(null);
// }
//
// @Override
// public MarkdownElement toMarkdownElement() throws MarkdownSerializationException {
// return this;
// }
//
// @Override
// public String toString() {
// return getSerialized(this.getClass().getSimpleName());
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownSerializationException.java
// public class MarkdownSerializationException extends Exception {
//
// public MarkdownSerializationException() {
// super();
// }
//
// public MarkdownSerializationException(String s) {
// super(s);
// }
//
// public MarkdownSerializationException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public MarkdownSerializationException(Throwable throwable) {
// super(throwable);
// }
//
// }
|
import net.steppschuh.markdowngenerator.MarkdownCascadable;
import net.steppschuh.markdowngenerator.MarkdownElement;
import net.steppschuh.markdowngenerator.MarkdownSerializationException;
|
package net.steppschuh.markdowngenerator.text;
public class Text extends MarkdownElement implements MarkdownCascadable {
protected Object value;
public Text(Object value) {
this.value = value;
}
@Override
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownCascadable.java
// public interface MarkdownCascadable {
//
// /**
// * @return the string that should be added before the value
// */
// String getPredecessor();
//
// /**
// * @return the string that should be added after the value
// */
// String getSuccessor();
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownElement.java
// public abstract class MarkdownElement implements MarkdownSerializable {
//
// private String serialized;
//
// /**
// * Attempts to generate a String representing this markdown element.
// *
// * @return Markdown as String
// * @throws MarkdownSerializationException If unable to generate a markdown String
// */
// public abstract String serialize() throws MarkdownSerializationException;
//
// /**
// * Returns the result of {@link MarkdownElement#getSerialized()} or the specified fallback if a
// * {@link MarkdownSerializationException} occurred.
// *
// * @param fallback String to return if serialization fails
// * @return Markdown as String or specified fallback
// */
// public String getSerialized(String fallback) {
// try {
// return getSerialized();
// } catch (MarkdownSerializationException e) {
// return fallback;
// }
// }
//
// /**
// * Calls {@link MarkdownElement#serialize()} or directly returns its last result from {@link
// * MarkdownElement#serialized}.
// *
// * @return Markdown as String
// * @throws MarkdownSerializationException If unable to generate a markdown String
// */
// public String getSerialized() throws MarkdownSerializationException {
// if (serialized == null) {
// serialized = serialize();
// }
// return serialized;
// }
//
// public void setSerialized(String serialized) {
// this.serialized = serialized;
// }
//
// /**
// * Sets {@link MarkdownElement#serialized} to null. The next call to {@link
// * MarkdownElement#getSerialized()} fill invoke a fresh serialization.
// */
// public void invalidateSerialized() {
// setSerialized(null);
// }
//
// @Override
// public MarkdownElement toMarkdownElement() throws MarkdownSerializationException {
// return this;
// }
//
// @Override
// public String toString() {
// return getSerialized(this.getClass().getSimpleName());
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownSerializationException.java
// public class MarkdownSerializationException extends Exception {
//
// public MarkdownSerializationException() {
// super();
// }
//
// public MarkdownSerializationException(String s) {
// super(s);
// }
//
// public MarkdownSerializationException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public MarkdownSerializationException(Throwable throwable) {
// super(throwable);
// }
//
// }
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/Text.java
import net.steppschuh.markdowngenerator.MarkdownCascadable;
import net.steppschuh.markdowngenerator.MarkdownElement;
import net.steppschuh.markdowngenerator.MarkdownSerializationException;
package net.steppschuh.markdowngenerator.text;
public class Text extends MarkdownElement implements MarkdownCascadable {
protected Object value;
public Text(Object value) {
this.value = value;
}
@Override
|
public String serialize() throws MarkdownSerializationException {
|
Steppschuh/Java-Markdown-Generator
|
Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/text/emphasis/ItalicTextTest.java
|
// Path: Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/DummyObject.java
// public class DummyObject implements MarkdownSerializable {
//
// private Object foo;
// private String bar;
// private int baz;
//
// public DummyObject() {
// this.foo = true;
// this.bar = "qux";
// this.baz = 1337;
// }
//
// public DummyObject(Object foo, String bar, int baz) {
// this.foo = foo;
// this.bar = bar;
// this.baz = baz;
// }
//
// public TableRow toMarkdownTableRow() {
// return new TableRow<>(Arrays.asList(
// foo, bar, baz
// ));
// }
//
// @Override
// public MarkdownElement toMarkdownElement() throws MarkdownSerializationException {
// return toMarkdownTableRow();
// }
//
// @Override
// public String toString() {
// try {
// return toMarkdownElement().toString();
// } catch (MarkdownSerializationException e) {
// return this.getClass().getSimpleName();
// }
// }
//
// public Object getFoo() {
// return foo;
// }
//
// public String getBar() {
// return bar;
// }
//
// public int getBaz() {
// return baz;
// }
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/Text.java
// public class Text extends MarkdownElement implements MarkdownCascadable {
//
// protected Object value;
//
// public Text(Object value) {
// this.value = value;
// }
//
// @Override
// public String serialize() throws MarkdownSerializationException {
// if (value == null) {
// throw new MarkdownSerializationException("Value is null");
// }
// return getPredecessor() + value.toString() + getSuccessor();
// }
//
// @Override
// public String getPredecessor() {
// return "";
// }
//
// @Override
// public String getSuccessor() {
// return getPredecessor();
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// invalidateSerialized();
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/emphasis/ItalicText.java
// public class ItalicText extends Text {
//
// public ItalicText(Object value) {
// super(value);
// }
//
// @Override
// public String getPredecessor() {
// return "_";
// }
//
// }
|
import net.steppschuh.markdowngenerator.DummyObject;
import net.steppschuh.markdowngenerator.text.Text;
import net.steppschuh.markdowngenerator.text.emphasis.ItalicText;
import org.junit.Test;
|
package net.steppschuh.markdowngenerator.text.emphasis;
/**
* Created by steppschuh on 15/12/2016.
*/
public class ItalicTextTest {
@Test
public void example1() throws Exception {
|
// Path: Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/DummyObject.java
// public class DummyObject implements MarkdownSerializable {
//
// private Object foo;
// private String bar;
// private int baz;
//
// public DummyObject() {
// this.foo = true;
// this.bar = "qux";
// this.baz = 1337;
// }
//
// public DummyObject(Object foo, String bar, int baz) {
// this.foo = foo;
// this.bar = bar;
// this.baz = baz;
// }
//
// public TableRow toMarkdownTableRow() {
// return new TableRow<>(Arrays.asList(
// foo, bar, baz
// ));
// }
//
// @Override
// public MarkdownElement toMarkdownElement() throws MarkdownSerializationException {
// return toMarkdownTableRow();
// }
//
// @Override
// public String toString() {
// try {
// return toMarkdownElement().toString();
// } catch (MarkdownSerializationException e) {
// return this.getClass().getSimpleName();
// }
// }
//
// public Object getFoo() {
// return foo;
// }
//
// public String getBar() {
// return bar;
// }
//
// public int getBaz() {
// return baz;
// }
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/Text.java
// public class Text extends MarkdownElement implements MarkdownCascadable {
//
// protected Object value;
//
// public Text(Object value) {
// this.value = value;
// }
//
// @Override
// public String serialize() throws MarkdownSerializationException {
// if (value == null) {
// throw new MarkdownSerializationException("Value is null");
// }
// return getPredecessor() + value.toString() + getSuccessor();
// }
//
// @Override
// public String getPredecessor() {
// return "";
// }
//
// @Override
// public String getSuccessor() {
// return getPredecessor();
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// invalidateSerialized();
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/emphasis/ItalicText.java
// public class ItalicText extends Text {
//
// public ItalicText(Object value) {
// super(value);
// }
//
// @Override
// public String getPredecessor() {
// return "_";
// }
//
// }
// Path: Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/text/emphasis/ItalicTextTest.java
import net.steppschuh.markdowngenerator.DummyObject;
import net.steppschuh.markdowngenerator.text.Text;
import net.steppschuh.markdowngenerator.text.emphasis.ItalicText;
import org.junit.Test;
package net.steppschuh.markdowngenerator.text.emphasis;
/**
* Created by steppschuh on 15/12/2016.
*/
public class ItalicTextTest {
@Test
public void example1() throws Exception {
|
Text text = new ItalicText("I am italic text");
|
Steppschuh/Java-Markdown-Generator
|
Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/text/emphasis/ItalicTextTest.java
|
// Path: Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/DummyObject.java
// public class DummyObject implements MarkdownSerializable {
//
// private Object foo;
// private String bar;
// private int baz;
//
// public DummyObject() {
// this.foo = true;
// this.bar = "qux";
// this.baz = 1337;
// }
//
// public DummyObject(Object foo, String bar, int baz) {
// this.foo = foo;
// this.bar = bar;
// this.baz = baz;
// }
//
// public TableRow toMarkdownTableRow() {
// return new TableRow<>(Arrays.asList(
// foo, bar, baz
// ));
// }
//
// @Override
// public MarkdownElement toMarkdownElement() throws MarkdownSerializationException {
// return toMarkdownTableRow();
// }
//
// @Override
// public String toString() {
// try {
// return toMarkdownElement().toString();
// } catch (MarkdownSerializationException e) {
// return this.getClass().getSimpleName();
// }
// }
//
// public Object getFoo() {
// return foo;
// }
//
// public String getBar() {
// return bar;
// }
//
// public int getBaz() {
// return baz;
// }
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/Text.java
// public class Text extends MarkdownElement implements MarkdownCascadable {
//
// protected Object value;
//
// public Text(Object value) {
// this.value = value;
// }
//
// @Override
// public String serialize() throws MarkdownSerializationException {
// if (value == null) {
// throw new MarkdownSerializationException("Value is null");
// }
// return getPredecessor() + value.toString() + getSuccessor();
// }
//
// @Override
// public String getPredecessor() {
// return "";
// }
//
// @Override
// public String getSuccessor() {
// return getPredecessor();
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// invalidateSerialized();
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/emphasis/ItalicText.java
// public class ItalicText extends Text {
//
// public ItalicText(Object value) {
// super(value);
// }
//
// @Override
// public String getPredecessor() {
// return "_";
// }
//
// }
|
import net.steppschuh.markdowngenerator.DummyObject;
import net.steppschuh.markdowngenerator.text.Text;
import net.steppschuh.markdowngenerator.text.emphasis.ItalicText;
import org.junit.Test;
|
package net.steppschuh.markdowngenerator.text.emphasis;
/**
* Created by steppschuh on 15/12/2016.
*/
public class ItalicTextTest {
@Test
public void example1() throws Exception {
|
// Path: Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/DummyObject.java
// public class DummyObject implements MarkdownSerializable {
//
// private Object foo;
// private String bar;
// private int baz;
//
// public DummyObject() {
// this.foo = true;
// this.bar = "qux";
// this.baz = 1337;
// }
//
// public DummyObject(Object foo, String bar, int baz) {
// this.foo = foo;
// this.bar = bar;
// this.baz = baz;
// }
//
// public TableRow toMarkdownTableRow() {
// return new TableRow<>(Arrays.asList(
// foo, bar, baz
// ));
// }
//
// @Override
// public MarkdownElement toMarkdownElement() throws MarkdownSerializationException {
// return toMarkdownTableRow();
// }
//
// @Override
// public String toString() {
// try {
// return toMarkdownElement().toString();
// } catch (MarkdownSerializationException e) {
// return this.getClass().getSimpleName();
// }
// }
//
// public Object getFoo() {
// return foo;
// }
//
// public String getBar() {
// return bar;
// }
//
// public int getBaz() {
// return baz;
// }
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/Text.java
// public class Text extends MarkdownElement implements MarkdownCascadable {
//
// protected Object value;
//
// public Text(Object value) {
// this.value = value;
// }
//
// @Override
// public String serialize() throws MarkdownSerializationException {
// if (value == null) {
// throw new MarkdownSerializationException("Value is null");
// }
// return getPredecessor() + value.toString() + getSuccessor();
// }
//
// @Override
// public String getPredecessor() {
// return "";
// }
//
// @Override
// public String getSuccessor() {
// return getPredecessor();
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// invalidateSerialized();
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/emphasis/ItalicText.java
// public class ItalicText extends Text {
//
// public ItalicText(Object value) {
// super(value);
// }
//
// @Override
// public String getPredecessor() {
// return "_";
// }
//
// }
// Path: Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/text/emphasis/ItalicTextTest.java
import net.steppschuh.markdowngenerator.DummyObject;
import net.steppschuh.markdowngenerator.text.Text;
import net.steppschuh.markdowngenerator.text.emphasis.ItalicText;
import org.junit.Test;
package net.steppschuh.markdowngenerator.text.emphasis;
/**
* Created by steppschuh on 15/12/2016.
*/
public class ItalicTextTest {
@Test
public void example1() throws Exception {
|
Text text = new ItalicText("I am italic text");
|
Steppschuh/Java-Markdown-Generator
|
Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/text/emphasis/ItalicTextTest.java
|
// Path: Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/DummyObject.java
// public class DummyObject implements MarkdownSerializable {
//
// private Object foo;
// private String bar;
// private int baz;
//
// public DummyObject() {
// this.foo = true;
// this.bar = "qux";
// this.baz = 1337;
// }
//
// public DummyObject(Object foo, String bar, int baz) {
// this.foo = foo;
// this.bar = bar;
// this.baz = baz;
// }
//
// public TableRow toMarkdownTableRow() {
// return new TableRow<>(Arrays.asList(
// foo, bar, baz
// ));
// }
//
// @Override
// public MarkdownElement toMarkdownElement() throws MarkdownSerializationException {
// return toMarkdownTableRow();
// }
//
// @Override
// public String toString() {
// try {
// return toMarkdownElement().toString();
// } catch (MarkdownSerializationException e) {
// return this.getClass().getSimpleName();
// }
// }
//
// public Object getFoo() {
// return foo;
// }
//
// public String getBar() {
// return bar;
// }
//
// public int getBaz() {
// return baz;
// }
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/Text.java
// public class Text extends MarkdownElement implements MarkdownCascadable {
//
// protected Object value;
//
// public Text(Object value) {
// this.value = value;
// }
//
// @Override
// public String serialize() throws MarkdownSerializationException {
// if (value == null) {
// throw new MarkdownSerializationException("Value is null");
// }
// return getPredecessor() + value.toString() + getSuccessor();
// }
//
// @Override
// public String getPredecessor() {
// return "";
// }
//
// @Override
// public String getSuccessor() {
// return getPredecessor();
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// invalidateSerialized();
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/emphasis/ItalicText.java
// public class ItalicText extends Text {
//
// public ItalicText(Object value) {
// super(value);
// }
//
// @Override
// public String getPredecessor() {
// return "_";
// }
//
// }
|
import net.steppschuh.markdowngenerator.DummyObject;
import net.steppschuh.markdowngenerator.text.Text;
import net.steppschuh.markdowngenerator.text.emphasis.ItalicText;
import org.junit.Test;
|
package net.steppschuh.markdowngenerator.text.emphasis;
/**
* Created by steppschuh on 15/12/2016.
*/
public class ItalicTextTest {
@Test
public void example1() throws Exception {
Text text = new ItalicText("I am italic text");
System.out.println(text);
}
@Test
public void example2() throws Exception {
|
// Path: Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/DummyObject.java
// public class DummyObject implements MarkdownSerializable {
//
// private Object foo;
// private String bar;
// private int baz;
//
// public DummyObject() {
// this.foo = true;
// this.bar = "qux";
// this.baz = 1337;
// }
//
// public DummyObject(Object foo, String bar, int baz) {
// this.foo = foo;
// this.bar = bar;
// this.baz = baz;
// }
//
// public TableRow toMarkdownTableRow() {
// return new TableRow<>(Arrays.asList(
// foo, bar, baz
// ));
// }
//
// @Override
// public MarkdownElement toMarkdownElement() throws MarkdownSerializationException {
// return toMarkdownTableRow();
// }
//
// @Override
// public String toString() {
// try {
// return toMarkdownElement().toString();
// } catch (MarkdownSerializationException e) {
// return this.getClass().getSimpleName();
// }
// }
//
// public Object getFoo() {
// return foo;
// }
//
// public String getBar() {
// return bar;
// }
//
// public int getBaz() {
// return baz;
// }
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/Text.java
// public class Text extends MarkdownElement implements MarkdownCascadable {
//
// protected Object value;
//
// public Text(Object value) {
// this.value = value;
// }
//
// @Override
// public String serialize() throws MarkdownSerializationException {
// if (value == null) {
// throw new MarkdownSerializationException("Value is null");
// }
// return getPredecessor() + value.toString() + getSuccessor();
// }
//
// @Override
// public String getPredecessor() {
// return "";
// }
//
// @Override
// public String getSuccessor() {
// return getPredecessor();
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// invalidateSerialized();
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/emphasis/ItalicText.java
// public class ItalicText extends Text {
//
// public ItalicText(Object value) {
// super(value);
// }
//
// @Override
// public String getPredecessor() {
// return "_";
// }
//
// }
// Path: Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/text/emphasis/ItalicTextTest.java
import net.steppschuh.markdowngenerator.DummyObject;
import net.steppschuh.markdowngenerator.text.Text;
import net.steppschuh.markdowngenerator.text.emphasis.ItalicText;
import org.junit.Test;
package net.steppschuh.markdowngenerator.text.emphasis;
/**
* Created by steppschuh on 15/12/2016.
*/
public class ItalicTextTest {
@Test
public void example1() throws Exception {
Text text = new ItalicText("I am italic text");
System.out.println(text);
}
@Test
public void example2() throws Exception {
|
Text text = new ItalicText(new DummyObject());
|
Steppschuh/Java-Markdown-Generator
|
Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/link/Link.java
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownElement.java
// public abstract class MarkdownElement implements MarkdownSerializable {
//
// private String serialized;
//
// /**
// * Attempts to generate a String representing this markdown element.
// *
// * @return Markdown as String
// * @throws MarkdownSerializationException If unable to generate a markdown String
// */
// public abstract String serialize() throws MarkdownSerializationException;
//
// /**
// * Returns the result of {@link MarkdownElement#getSerialized()} or the specified fallback if a
// * {@link MarkdownSerializationException} occurred.
// *
// * @param fallback String to return if serialization fails
// * @return Markdown as String or specified fallback
// */
// public String getSerialized(String fallback) {
// try {
// return getSerialized();
// } catch (MarkdownSerializationException e) {
// return fallback;
// }
// }
//
// /**
// * Calls {@link MarkdownElement#serialize()} or directly returns its last result from {@link
// * MarkdownElement#serialized}.
// *
// * @return Markdown as String
// * @throws MarkdownSerializationException If unable to generate a markdown String
// */
// public String getSerialized() throws MarkdownSerializationException {
// if (serialized == null) {
// serialized = serialize();
// }
// return serialized;
// }
//
// public void setSerialized(String serialized) {
// this.serialized = serialized;
// }
//
// /**
// * Sets {@link MarkdownElement#serialized} to null. The next call to {@link
// * MarkdownElement#getSerialized()} fill invoke a fresh serialization.
// */
// public void invalidateSerialized() {
// setSerialized(null);
// }
//
// @Override
// public MarkdownElement toMarkdownElement() throws MarkdownSerializationException {
// return this;
// }
//
// @Override
// public String toString() {
// return getSerialized(this.getClass().getSimpleName());
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownSerializationException.java
// public class MarkdownSerializationException extends Exception {
//
// public MarkdownSerializationException() {
// super();
// }
//
// public MarkdownSerializationException(String s) {
// super(s);
// }
//
// public MarkdownSerializationException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public MarkdownSerializationException(Throwable throwable) {
// super(throwable);
// }
//
// }
|
import net.steppschuh.markdowngenerator.MarkdownElement;
import net.steppschuh.markdowngenerator.MarkdownSerializationException;
|
package net.steppschuh.markdowngenerator.link;
public class Link extends MarkdownElement {
private Object text;
private String url;
public Link(Object text, String url) {
this.text = text;
this.url = url;
}
public Link(String url) {
this(url, url);
}
@Override
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownElement.java
// public abstract class MarkdownElement implements MarkdownSerializable {
//
// private String serialized;
//
// /**
// * Attempts to generate a String representing this markdown element.
// *
// * @return Markdown as String
// * @throws MarkdownSerializationException If unable to generate a markdown String
// */
// public abstract String serialize() throws MarkdownSerializationException;
//
// /**
// * Returns the result of {@link MarkdownElement#getSerialized()} or the specified fallback if a
// * {@link MarkdownSerializationException} occurred.
// *
// * @param fallback String to return if serialization fails
// * @return Markdown as String or specified fallback
// */
// public String getSerialized(String fallback) {
// try {
// return getSerialized();
// } catch (MarkdownSerializationException e) {
// return fallback;
// }
// }
//
// /**
// * Calls {@link MarkdownElement#serialize()} or directly returns its last result from {@link
// * MarkdownElement#serialized}.
// *
// * @return Markdown as String
// * @throws MarkdownSerializationException If unable to generate a markdown String
// */
// public String getSerialized() throws MarkdownSerializationException {
// if (serialized == null) {
// serialized = serialize();
// }
// return serialized;
// }
//
// public void setSerialized(String serialized) {
// this.serialized = serialized;
// }
//
// /**
// * Sets {@link MarkdownElement#serialized} to null. The next call to {@link
// * MarkdownElement#getSerialized()} fill invoke a fresh serialization.
// */
// public void invalidateSerialized() {
// setSerialized(null);
// }
//
// @Override
// public MarkdownElement toMarkdownElement() throws MarkdownSerializationException {
// return this;
// }
//
// @Override
// public String toString() {
// return getSerialized(this.getClass().getSimpleName());
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownSerializationException.java
// public class MarkdownSerializationException extends Exception {
//
// public MarkdownSerializationException() {
// super();
// }
//
// public MarkdownSerializationException(String s) {
// super(s);
// }
//
// public MarkdownSerializationException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public MarkdownSerializationException(Throwable throwable) {
// super(throwable);
// }
//
// }
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/link/Link.java
import net.steppschuh.markdowngenerator.MarkdownElement;
import net.steppschuh.markdowngenerator.MarkdownSerializationException;
package net.steppschuh.markdowngenerator.link;
public class Link extends MarkdownElement {
private Object text;
private String url;
public Link(Object text, String url) {
this.text = text;
this.url = url;
}
public Link(String url) {
this(url, url);
}
@Override
|
public String serialize() throws MarkdownSerializationException {
|
Steppschuh/Java-Markdown-Generator
|
Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/image/Image.java
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownSerializationException.java
// public class MarkdownSerializationException extends Exception {
//
// public MarkdownSerializationException() {
// super();
// }
//
// public MarkdownSerializationException(String s) {
// super(s);
// }
//
// public MarkdownSerializationException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public MarkdownSerializationException(Throwable throwable) {
// super(throwable);
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/link/Link.java
// public class Link extends MarkdownElement {
//
// private Object text;
// private String url;
//
// public Link(Object text, String url) {
// this.text = text;
// this.url = url;
// }
//
// public Link(String url) {
// this(url, url);
// }
//
// @Override
// public String serialize() throws MarkdownSerializationException {
// StringBuilder sb = new StringBuilder();
// sb.append("[").append(text).append("]");
// sb.append("(").append(url).append(")");
// return sb.toString();
// }
//
// public Object getText() {
// return text;
// }
//
// public void setText(Object text) {
// this.text = text;
// invalidateSerialized();
// }
//
// public String getUrl() {
// return url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// invalidateSerialized();
// }
//
// }
|
import net.steppschuh.markdowngenerator.MarkdownSerializationException;
import net.steppschuh.markdowngenerator.link.Link;
|
package net.steppschuh.markdowngenerator.image;
public class Image extends Link {
public Image(Object text, String url) {
super(text, url);
}
public Image(String url) {
this(url, url);
}
@Override
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownSerializationException.java
// public class MarkdownSerializationException extends Exception {
//
// public MarkdownSerializationException() {
// super();
// }
//
// public MarkdownSerializationException(String s) {
// super(s);
// }
//
// public MarkdownSerializationException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public MarkdownSerializationException(Throwable throwable) {
// super(throwable);
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/link/Link.java
// public class Link extends MarkdownElement {
//
// private Object text;
// private String url;
//
// public Link(Object text, String url) {
// this.text = text;
// this.url = url;
// }
//
// public Link(String url) {
// this(url, url);
// }
//
// @Override
// public String serialize() throws MarkdownSerializationException {
// StringBuilder sb = new StringBuilder();
// sb.append("[").append(text).append("]");
// sb.append("(").append(url).append(")");
// return sb.toString();
// }
//
// public Object getText() {
// return text;
// }
//
// public void setText(Object text) {
// this.text = text;
// invalidateSerialized();
// }
//
// public String getUrl() {
// return url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// invalidateSerialized();
// }
//
// }
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/image/Image.java
import net.steppschuh.markdowngenerator.MarkdownSerializationException;
import net.steppschuh.markdowngenerator.link.Link;
package net.steppschuh.markdowngenerator.image;
public class Image extends Link {
public Image(Object text, String url) {
super(text, url);
}
public Image(String url) {
this(url, url);
}
@Override
|
public String serialize() throws MarkdownSerializationException {
|
Steppschuh/Java-Markdown-Generator
|
Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/table/TableTest.java
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/emphasis/BoldText.java
// public class BoldText extends Text {
//
// public BoldText(Object value) {
// super(value);
// }
//
// @Override
// public String getPredecessor() {
// return "**";
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/code/Code.java
// public class Code extends Text {
//
// public Code(Object value) {
// super(value);
// }
//
// @Override
// public String getPredecessor() {
// return "`";
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/Text.java
// public class Text extends MarkdownElement implements MarkdownCascadable {
//
// protected Object value;
//
// public Text(Object value) {
// this.value = value;
// }
//
// @Override
// public String serialize() throws MarkdownSerializationException {
// if (value == null) {
// throw new MarkdownSerializationException("Value is null");
// }
// return getPredecessor() + value.toString() + getSuccessor();
// }
//
// @Override
// public String getPredecessor() {
// return "";
// }
//
// @Override
// public String getSuccessor() {
// return getPredecessor();
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// invalidateSerialized();
// }
//
// }
|
import net.steppschuh.markdowngenerator.text.emphasis.BoldText;
import net.steppschuh.markdowngenerator.text.code.Code;
import net.steppschuh.markdowngenerator.text.Text;
import org.junit.Test;
import java.util.Arrays;
import java.util.List;
|
package net.steppschuh.markdowngenerator.table;
/**
* Created by steppschuh on 15/12/2016.
*/
public class TableTest {
@Test
public void example1() throws Exception {
List<TableRow> rows = Arrays.asList(
new TableRow(Arrays.asList(
"Left",
"Center",
"Right"
)),
new TableRow(Arrays.asList(
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/emphasis/BoldText.java
// public class BoldText extends Text {
//
// public BoldText(Object value) {
// super(value);
// }
//
// @Override
// public String getPredecessor() {
// return "**";
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/code/Code.java
// public class Code extends Text {
//
// public Code(Object value) {
// super(value);
// }
//
// @Override
// public String getPredecessor() {
// return "`";
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/Text.java
// public class Text extends MarkdownElement implements MarkdownCascadable {
//
// protected Object value;
//
// public Text(Object value) {
// this.value = value;
// }
//
// @Override
// public String serialize() throws MarkdownSerializationException {
// if (value == null) {
// throw new MarkdownSerializationException("Value is null");
// }
// return getPredecessor() + value.toString() + getSuccessor();
// }
//
// @Override
// public String getPredecessor() {
// return "";
// }
//
// @Override
// public String getSuccessor() {
// return getPredecessor();
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// invalidateSerialized();
// }
//
// }
// Path: Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/table/TableTest.java
import net.steppschuh.markdowngenerator.text.emphasis.BoldText;
import net.steppschuh.markdowngenerator.text.code.Code;
import net.steppschuh.markdowngenerator.text.Text;
import org.junit.Test;
import java.util.Arrays;
import java.util.List;
package net.steppschuh.markdowngenerator.table;
/**
* Created by steppschuh on 15/12/2016.
*/
public class TableTest {
@Test
public void example1() throws Exception {
List<TableRow> rows = Arrays.asList(
new TableRow(Arrays.asList(
"Left",
"Center",
"Right"
)),
new TableRow(Arrays.asList(
|
new Text("Normal Text"),
|
Steppschuh/Java-Markdown-Generator
|
Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/table/TableTest.java
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/emphasis/BoldText.java
// public class BoldText extends Text {
//
// public BoldText(Object value) {
// super(value);
// }
//
// @Override
// public String getPredecessor() {
// return "**";
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/code/Code.java
// public class Code extends Text {
//
// public Code(Object value) {
// super(value);
// }
//
// @Override
// public String getPredecessor() {
// return "`";
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/Text.java
// public class Text extends MarkdownElement implements MarkdownCascadable {
//
// protected Object value;
//
// public Text(Object value) {
// this.value = value;
// }
//
// @Override
// public String serialize() throws MarkdownSerializationException {
// if (value == null) {
// throw new MarkdownSerializationException("Value is null");
// }
// return getPredecessor() + value.toString() + getSuccessor();
// }
//
// @Override
// public String getPredecessor() {
// return "";
// }
//
// @Override
// public String getSuccessor() {
// return getPredecessor();
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// invalidateSerialized();
// }
//
// }
|
import net.steppschuh.markdowngenerator.text.emphasis.BoldText;
import net.steppschuh.markdowngenerator.text.code.Code;
import net.steppschuh.markdowngenerator.text.Text;
import org.junit.Test;
import java.util.Arrays;
import java.util.List;
|
package net.steppschuh.markdowngenerator.table;
/**
* Created by steppschuh on 15/12/2016.
*/
public class TableTest {
@Test
public void example1() throws Exception {
List<TableRow> rows = Arrays.asList(
new TableRow(Arrays.asList(
"Left",
"Center",
"Right"
)),
new TableRow(Arrays.asList(
new Text("Normal Text"),
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/emphasis/BoldText.java
// public class BoldText extends Text {
//
// public BoldText(Object value) {
// super(value);
// }
//
// @Override
// public String getPredecessor() {
// return "**";
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/code/Code.java
// public class Code extends Text {
//
// public Code(Object value) {
// super(value);
// }
//
// @Override
// public String getPredecessor() {
// return "`";
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/Text.java
// public class Text extends MarkdownElement implements MarkdownCascadable {
//
// protected Object value;
//
// public Text(Object value) {
// this.value = value;
// }
//
// @Override
// public String serialize() throws MarkdownSerializationException {
// if (value == null) {
// throw new MarkdownSerializationException("Value is null");
// }
// return getPredecessor() + value.toString() + getSuccessor();
// }
//
// @Override
// public String getPredecessor() {
// return "";
// }
//
// @Override
// public String getSuccessor() {
// return getPredecessor();
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// invalidateSerialized();
// }
//
// }
// Path: Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/table/TableTest.java
import net.steppschuh.markdowngenerator.text.emphasis.BoldText;
import net.steppschuh.markdowngenerator.text.code.Code;
import net.steppschuh.markdowngenerator.text.Text;
import org.junit.Test;
import java.util.Arrays;
import java.util.List;
package net.steppschuh.markdowngenerator.table;
/**
* Created by steppschuh on 15/12/2016.
*/
public class TableTest {
@Test
public void example1() throws Exception {
List<TableRow> rows = Arrays.asList(
new TableRow(Arrays.asList(
"Left",
"Center",
"Right"
)),
new TableRow(Arrays.asList(
new Text("Normal Text"),
|
new BoldText("Bold Text"),
|
Steppschuh/Java-Markdown-Generator
|
Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/table/TableTest.java
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/emphasis/BoldText.java
// public class BoldText extends Text {
//
// public BoldText(Object value) {
// super(value);
// }
//
// @Override
// public String getPredecessor() {
// return "**";
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/code/Code.java
// public class Code extends Text {
//
// public Code(Object value) {
// super(value);
// }
//
// @Override
// public String getPredecessor() {
// return "`";
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/Text.java
// public class Text extends MarkdownElement implements MarkdownCascadable {
//
// protected Object value;
//
// public Text(Object value) {
// this.value = value;
// }
//
// @Override
// public String serialize() throws MarkdownSerializationException {
// if (value == null) {
// throw new MarkdownSerializationException("Value is null");
// }
// return getPredecessor() + value.toString() + getSuccessor();
// }
//
// @Override
// public String getPredecessor() {
// return "";
// }
//
// @Override
// public String getSuccessor() {
// return getPredecessor();
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// invalidateSerialized();
// }
//
// }
|
import net.steppschuh.markdowngenerator.text.emphasis.BoldText;
import net.steppschuh.markdowngenerator.text.code.Code;
import net.steppschuh.markdowngenerator.text.Text;
import org.junit.Test;
import java.util.Arrays;
import java.util.List;
|
package net.steppschuh.markdowngenerator.table;
/**
* Created by steppschuh on 15/12/2016.
*/
public class TableTest {
@Test
public void example1() throws Exception {
List<TableRow> rows = Arrays.asList(
new TableRow(Arrays.asList(
"Left",
"Center",
"Right"
)),
new TableRow(Arrays.asList(
new Text("Normal Text"),
new BoldText("Bold Text"),
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/emphasis/BoldText.java
// public class BoldText extends Text {
//
// public BoldText(Object value) {
// super(value);
// }
//
// @Override
// public String getPredecessor() {
// return "**";
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/code/Code.java
// public class Code extends Text {
//
// public Code(Object value) {
// super(value);
// }
//
// @Override
// public String getPredecessor() {
// return "`";
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/Text.java
// public class Text extends MarkdownElement implements MarkdownCascadable {
//
// protected Object value;
//
// public Text(Object value) {
// this.value = value;
// }
//
// @Override
// public String serialize() throws MarkdownSerializationException {
// if (value == null) {
// throw new MarkdownSerializationException("Value is null");
// }
// return getPredecessor() + value.toString() + getSuccessor();
// }
//
// @Override
// public String getPredecessor() {
// return "";
// }
//
// @Override
// public String getSuccessor() {
// return getPredecessor();
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// invalidateSerialized();
// }
//
// }
// Path: Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/table/TableTest.java
import net.steppschuh.markdowngenerator.text.emphasis.BoldText;
import net.steppschuh.markdowngenerator.text.code.Code;
import net.steppschuh.markdowngenerator.text.Text;
import org.junit.Test;
import java.util.Arrays;
import java.util.List;
package net.steppschuh.markdowngenerator.table;
/**
* Created by steppschuh on 15/12/2016.
*/
public class TableTest {
@Test
public void example1() throws Exception {
List<TableRow> rows = Arrays.asList(
new TableRow(Arrays.asList(
"Left",
"Center",
"Right"
)),
new TableRow(Arrays.asList(
new Text("Normal Text"),
new BoldText("Bold Text"),
|
new Code("Code Text")
|
Steppschuh/Java-Markdown-Generator
|
Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/text/code/CodeBlockTest.java
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/Text.java
// public class Text extends MarkdownElement implements MarkdownCascadable {
//
// protected Object value;
//
// public Text(Object value) {
// this.value = value;
// }
//
// @Override
// public String serialize() throws MarkdownSerializationException {
// if (value == null) {
// throw new MarkdownSerializationException("Value is null");
// }
// return getPredecessor() + value.toString() + getSuccessor();
// }
//
// @Override
// public String getPredecessor() {
// return "";
// }
//
// @Override
// public String getSuccessor() {
// return getPredecessor();
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// invalidateSerialized();
// }
//
// }
|
import net.steppschuh.markdowngenerator.text.Text;
import org.junit.Test;
|
package net.steppschuh.markdowngenerator.text.code;
/**
* Created by steppschuh on 15/12/2016.
*/
public class CodeBlockTest {
@Test
public void example1() throws Exception {
String code = "System.out.println(\"I am a code block\");";
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/text/Text.java
// public class Text extends MarkdownElement implements MarkdownCascadable {
//
// protected Object value;
//
// public Text(Object value) {
// this.value = value;
// }
//
// @Override
// public String serialize() throws MarkdownSerializationException {
// if (value == null) {
// throw new MarkdownSerializationException("Value is null");
// }
// return getPredecessor() + value.toString() + getSuccessor();
// }
//
// @Override
// public String getPredecessor() {
// return "";
// }
//
// @Override
// public String getSuccessor() {
// return getPredecessor();
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// invalidateSerialized();
// }
//
// }
// Path: Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/text/code/CodeBlockTest.java
import net.steppschuh.markdowngenerator.text.Text;
import org.junit.Test;
package net.steppschuh.markdowngenerator.text.code;
/**
* Created by steppschuh on 15/12/2016.
*/
public class CodeBlockTest {
@Test
public void example1() throws Exception {
String code = "System.out.println(\"I am a code block\");";
|
Text text = new CodeBlock(code);
|
Steppschuh/Java-Markdown-Generator
|
Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/table/TableRow.java
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownElement.java
// public abstract class MarkdownElement implements MarkdownSerializable {
//
// private String serialized;
//
// /**
// * Attempts to generate a String representing this markdown element.
// *
// * @return Markdown as String
// * @throws MarkdownSerializationException If unable to generate a markdown String
// */
// public abstract String serialize() throws MarkdownSerializationException;
//
// /**
// * Returns the result of {@link MarkdownElement#getSerialized()} or the specified fallback if a
// * {@link MarkdownSerializationException} occurred.
// *
// * @param fallback String to return if serialization fails
// * @return Markdown as String or specified fallback
// */
// public String getSerialized(String fallback) {
// try {
// return getSerialized();
// } catch (MarkdownSerializationException e) {
// return fallback;
// }
// }
//
// /**
// * Calls {@link MarkdownElement#serialize()} or directly returns its last result from {@link
// * MarkdownElement#serialized}.
// *
// * @return Markdown as String
// * @throws MarkdownSerializationException If unable to generate a markdown String
// */
// public String getSerialized() throws MarkdownSerializationException {
// if (serialized == null) {
// serialized = serialize();
// }
// return serialized;
// }
//
// public void setSerialized(String serialized) {
// this.serialized = serialized;
// }
//
// /**
// * Sets {@link MarkdownElement#serialized} to null. The next call to {@link
// * MarkdownElement#getSerialized()} fill invoke a fresh serialization.
// */
// public void invalidateSerialized() {
// setSerialized(null);
// }
//
// @Override
// public MarkdownElement toMarkdownElement() throws MarkdownSerializationException {
// return this;
// }
//
// @Override
// public String toString() {
// return getSerialized(this.getClass().getSimpleName());
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownSerializationException.java
// public class MarkdownSerializationException extends Exception {
//
// public MarkdownSerializationException() {
// super();
// }
//
// public MarkdownSerializationException(String s) {
// super(s);
// }
//
// public MarkdownSerializationException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public MarkdownSerializationException(Throwable throwable) {
// super(throwable);
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/util/StringUtil.java
// public abstract class StringUtil {
//
// public static String fillUpAligned(String value, String fill, int length, int alignment) {
// switch (alignment) {
// case Table.ALIGN_RIGHT: {
// return fillUpRightAligned(value, fill, length);
// }
// case Table.ALIGN_CENTER: {
// return fillUpCenterAligned(value, fill, length);
// }
// default: {
// return fillUpLeftAligned(value, fill, length);
// }
// }
// }
//
// public static String fillUpLeftAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// while (value.length() < length) {
// value += fill;
// }
// return value;
// }
//
// public static String fillUpRightAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// while (value.length() < length) {
// value = fill + value;
// }
// return value;
// }
//
// public static String fillUpCenterAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// boolean left = true;
// while (value.length() < length) {
// if (left) {
// value = fillUpLeftAligned(value, fill, value.length() + 1);
// } else {
// value = fillUpRightAligned(value, fill, value.length() + 1);
// }
// left = !left;
// }
// return value;
// }
//
// public static String surroundValueWith(String value, String surrounding) {
// return surrounding + value + surrounding;
// }
//
// }
|
import net.steppschuh.markdowngenerator.MarkdownElement;
import net.steppschuh.markdowngenerator.MarkdownSerializationException;
import net.steppschuh.markdowngenerator.util.StringUtil;
import java.util.ArrayList;
import java.util.List;
|
package net.steppschuh.markdowngenerator.table;
public class TableRow<T extends Object> extends MarkdownElement {
private List<T> columns;
public TableRow() {
this.columns = new ArrayList<>();
}
public TableRow(List<T> columns) {
this.columns = columns;
}
@Override
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownElement.java
// public abstract class MarkdownElement implements MarkdownSerializable {
//
// private String serialized;
//
// /**
// * Attempts to generate a String representing this markdown element.
// *
// * @return Markdown as String
// * @throws MarkdownSerializationException If unable to generate a markdown String
// */
// public abstract String serialize() throws MarkdownSerializationException;
//
// /**
// * Returns the result of {@link MarkdownElement#getSerialized()} or the specified fallback if a
// * {@link MarkdownSerializationException} occurred.
// *
// * @param fallback String to return if serialization fails
// * @return Markdown as String or specified fallback
// */
// public String getSerialized(String fallback) {
// try {
// return getSerialized();
// } catch (MarkdownSerializationException e) {
// return fallback;
// }
// }
//
// /**
// * Calls {@link MarkdownElement#serialize()} or directly returns its last result from {@link
// * MarkdownElement#serialized}.
// *
// * @return Markdown as String
// * @throws MarkdownSerializationException If unable to generate a markdown String
// */
// public String getSerialized() throws MarkdownSerializationException {
// if (serialized == null) {
// serialized = serialize();
// }
// return serialized;
// }
//
// public void setSerialized(String serialized) {
// this.serialized = serialized;
// }
//
// /**
// * Sets {@link MarkdownElement#serialized} to null. The next call to {@link
// * MarkdownElement#getSerialized()} fill invoke a fresh serialization.
// */
// public void invalidateSerialized() {
// setSerialized(null);
// }
//
// @Override
// public MarkdownElement toMarkdownElement() throws MarkdownSerializationException {
// return this;
// }
//
// @Override
// public String toString() {
// return getSerialized(this.getClass().getSimpleName());
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownSerializationException.java
// public class MarkdownSerializationException extends Exception {
//
// public MarkdownSerializationException() {
// super();
// }
//
// public MarkdownSerializationException(String s) {
// super(s);
// }
//
// public MarkdownSerializationException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public MarkdownSerializationException(Throwable throwable) {
// super(throwable);
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/util/StringUtil.java
// public abstract class StringUtil {
//
// public static String fillUpAligned(String value, String fill, int length, int alignment) {
// switch (alignment) {
// case Table.ALIGN_RIGHT: {
// return fillUpRightAligned(value, fill, length);
// }
// case Table.ALIGN_CENTER: {
// return fillUpCenterAligned(value, fill, length);
// }
// default: {
// return fillUpLeftAligned(value, fill, length);
// }
// }
// }
//
// public static String fillUpLeftAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// while (value.length() < length) {
// value += fill;
// }
// return value;
// }
//
// public static String fillUpRightAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// while (value.length() < length) {
// value = fill + value;
// }
// return value;
// }
//
// public static String fillUpCenterAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// boolean left = true;
// while (value.length() < length) {
// if (left) {
// value = fillUpLeftAligned(value, fill, value.length() + 1);
// } else {
// value = fillUpRightAligned(value, fill, value.length() + 1);
// }
// left = !left;
// }
// return value;
// }
//
// public static String surroundValueWith(String value, String surrounding) {
// return surrounding + value + surrounding;
// }
//
// }
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/table/TableRow.java
import net.steppschuh.markdowngenerator.MarkdownElement;
import net.steppschuh.markdowngenerator.MarkdownSerializationException;
import net.steppschuh.markdowngenerator.util.StringUtil;
import java.util.ArrayList;
import java.util.List;
package net.steppschuh.markdowngenerator.table;
public class TableRow<T extends Object> extends MarkdownElement {
private List<T> columns;
public TableRow() {
this.columns = new ArrayList<>();
}
public TableRow(List<T> columns) {
this.columns = columns;
}
@Override
|
public String serialize() throws MarkdownSerializationException {
|
Steppschuh/Java-Markdown-Generator
|
Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/table/TableRow.java
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownElement.java
// public abstract class MarkdownElement implements MarkdownSerializable {
//
// private String serialized;
//
// /**
// * Attempts to generate a String representing this markdown element.
// *
// * @return Markdown as String
// * @throws MarkdownSerializationException If unable to generate a markdown String
// */
// public abstract String serialize() throws MarkdownSerializationException;
//
// /**
// * Returns the result of {@link MarkdownElement#getSerialized()} or the specified fallback if a
// * {@link MarkdownSerializationException} occurred.
// *
// * @param fallback String to return if serialization fails
// * @return Markdown as String or specified fallback
// */
// public String getSerialized(String fallback) {
// try {
// return getSerialized();
// } catch (MarkdownSerializationException e) {
// return fallback;
// }
// }
//
// /**
// * Calls {@link MarkdownElement#serialize()} or directly returns its last result from {@link
// * MarkdownElement#serialized}.
// *
// * @return Markdown as String
// * @throws MarkdownSerializationException If unable to generate a markdown String
// */
// public String getSerialized() throws MarkdownSerializationException {
// if (serialized == null) {
// serialized = serialize();
// }
// return serialized;
// }
//
// public void setSerialized(String serialized) {
// this.serialized = serialized;
// }
//
// /**
// * Sets {@link MarkdownElement#serialized} to null. The next call to {@link
// * MarkdownElement#getSerialized()} fill invoke a fresh serialization.
// */
// public void invalidateSerialized() {
// setSerialized(null);
// }
//
// @Override
// public MarkdownElement toMarkdownElement() throws MarkdownSerializationException {
// return this;
// }
//
// @Override
// public String toString() {
// return getSerialized(this.getClass().getSimpleName());
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownSerializationException.java
// public class MarkdownSerializationException extends Exception {
//
// public MarkdownSerializationException() {
// super();
// }
//
// public MarkdownSerializationException(String s) {
// super(s);
// }
//
// public MarkdownSerializationException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public MarkdownSerializationException(Throwable throwable) {
// super(throwable);
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/util/StringUtil.java
// public abstract class StringUtil {
//
// public static String fillUpAligned(String value, String fill, int length, int alignment) {
// switch (alignment) {
// case Table.ALIGN_RIGHT: {
// return fillUpRightAligned(value, fill, length);
// }
// case Table.ALIGN_CENTER: {
// return fillUpCenterAligned(value, fill, length);
// }
// default: {
// return fillUpLeftAligned(value, fill, length);
// }
// }
// }
//
// public static String fillUpLeftAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// while (value.length() < length) {
// value += fill;
// }
// return value;
// }
//
// public static String fillUpRightAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// while (value.length() < length) {
// value = fill + value;
// }
// return value;
// }
//
// public static String fillUpCenterAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// boolean left = true;
// while (value.length() < length) {
// if (left) {
// value = fillUpLeftAligned(value, fill, value.length() + 1);
// } else {
// value = fillUpRightAligned(value, fill, value.length() + 1);
// }
// left = !left;
// }
// return value;
// }
//
// public static String surroundValueWith(String value, String surrounding) {
// return surrounding + value + surrounding;
// }
//
// }
|
import net.steppschuh.markdowngenerator.MarkdownElement;
import net.steppschuh.markdowngenerator.MarkdownSerializationException;
import net.steppschuh.markdowngenerator.util.StringUtil;
import java.util.ArrayList;
import java.util.List;
|
package net.steppschuh.markdowngenerator.table;
public class TableRow<T extends Object> extends MarkdownElement {
private List<T> columns;
public TableRow() {
this.columns = new ArrayList<>();
}
public TableRow(List<T> columns) {
this.columns = columns;
}
@Override
public String serialize() throws MarkdownSerializationException {
StringBuilder sb = new StringBuilder();
for (Object item : columns) {
if (item == null) {
throw new MarkdownSerializationException("Column is null");
}
if (item.toString().contains(Table.SEPARATOR)) {
throw new MarkdownSerializationException("Column contains seperator char \"" + Table.SEPARATOR + "\"");
}
sb.append(Table.SEPARATOR);
|
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownElement.java
// public abstract class MarkdownElement implements MarkdownSerializable {
//
// private String serialized;
//
// /**
// * Attempts to generate a String representing this markdown element.
// *
// * @return Markdown as String
// * @throws MarkdownSerializationException If unable to generate a markdown String
// */
// public abstract String serialize() throws MarkdownSerializationException;
//
// /**
// * Returns the result of {@link MarkdownElement#getSerialized()} or the specified fallback if a
// * {@link MarkdownSerializationException} occurred.
// *
// * @param fallback String to return if serialization fails
// * @return Markdown as String or specified fallback
// */
// public String getSerialized(String fallback) {
// try {
// return getSerialized();
// } catch (MarkdownSerializationException e) {
// return fallback;
// }
// }
//
// /**
// * Calls {@link MarkdownElement#serialize()} or directly returns its last result from {@link
// * MarkdownElement#serialized}.
// *
// * @return Markdown as String
// * @throws MarkdownSerializationException If unable to generate a markdown String
// */
// public String getSerialized() throws MarkdownSerializationException {
// if (serialized == null) {
// serialized = serialize();
// }
// return serialized;
// }
//
// public void setSerialized(String serialized) {
// this.serialized = serialized;
// }
//
// /**
// * Sets {@link MarkdownElement#serialized} to null. The next call to {@link
// * MarkdownElement#getSerialized()} fill invoke a fresh serialization.
// */
// public void invalidateSerialized() {
// setSerialized(null);
// }
//
// @Override
// public MarkdownElement toMarkdownElement() throws MarkdownSerializationException {
// return this;
// }
//
// @Override
// public String toString() {
// return getSerialized(this.getClass().getSimpleName());
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/MarkdownSerializationException.java
// public class MarkdownSerializationException extends Exception {
//
// public MarkdownSerializationException() {
// super();
// }
//
// public MarkdownSerializationException(String s) {
// super(s);
// }
//
// public MarkdownSerializationException(String s, Throwable throwable) {
// super(s, throwable);
// }
//
// public MarkdownSerializationException(Throwable throwable) {
// super(throwable);
// }
//
// }
//
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/util/StringUtil.java
// public abstract class StringUtil {
//
// public static String fillUpAligned(String value, String fill, int length, int alignment) {
// switch (alignment) {
// case Table.ALIGN_RIGHT: {
// return fillUpRightAligned(value, fill, length);
// }
// case Table.ALIGN_CENTER: {
// return fillUpCenterAligned(value, fill, length);
// }
// default: {
// return fillUpLeftAligned(value, fill, length);
// }
// }
// }
//
// public static String fillUpLeftAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// while (value.length() < length) {
// value += fill;
// }
// return value;
// }
//
// public static String fillUpRightAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// while (value.length() < length) {
// value = fill + value;
// }
// return value;
// }
//
// public static String fillUpCenterAligned(String value, String fill, int length) {
// if (value.length() >= length) {
// return value;
// }
// boolean left = true;
// while (value.length() < length) {
// if (left) {
// value = fillUpLeftAligned(value, fill, value.length() + 1);
// } else {
// value = fillUpRightAligned(value, fill, value.length() + 1);
// }
// left = !left;
// }
// return value;
// }
//
// public static String surroundValueWith(String value, String surrounding) {
// return surrounding + value + surrounding;
// }
//
// }
// Path: Source/MarkdownGenerator/src/main/java/net/steppschuh/markdowngenerator/table/TableRow.java
import net.steppschuh.markdowngenerator.MarkdownElement;
import net.steppschuh.markdowngenerator.MarkdownSerializationException;
import net.steppschuh.markdowngenerator.util.StringUtil;
import java.util.ArrayList;
import java.util.List;
package net.steppschuh.markdowngenerator.table;
public class TableRow<T extends Object> extends MarkdownElement {
private List<T> columns;
public TableRow() {
this.columns = new ArrayList<>();
}
public TableRow(List<T> columns) {
this.columns = columns;
}
@Override
public String serialize() throws MarkdownSerializationException {
StringBuilder sb = new StringBuilder();
for (Object item : columns) {
if (item == null) {
throw new MarkdownSerializationException("Column is null");
}
if (item.toString().contains(Table.SEPARATOR)) {
throw new MarkdownSerializationException("Column contains seperator char \"" + Table.SEPARATOR + "\"");
}
sb.append(Table.SEPARATOR);
|
sb.append(StringUtil.surroundValueWith(item.toString(), " "));
|
Steppschuh/Java-Markdown-Generator
|
Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/text/TextTest.java
|
// Path: Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/DummyObject.java
// public class DummyObject implements MarkdownSerializable {
//
// private Object foo;
// private String bar;
// private int baz;
//
// public DummyObject() {
// this.foo = true;
// this.bar = "qux";
// this.baz = 1337;
// }
//
// public DummyObject(Object foo, String bar, int baz) {
// this.foo = foo;
// this.bar = bar;
// this.baz = baz;
// }
//
// public TableRow toMarkdownTableRow() {
// return new TableRow<>(Arrays.asList(
// foo, bar, baz
// ));
// }
//
// @Override
// public MarkdownElement toMarkdownElement() throws MarkdownSerializationException {
// return toMarkdownTableRow();
// }
//
// @Override
// public String toString() {
// try {
// return toMarkdownElement().toString();
// } catch (MarkdownSerializationException e) {
// return this.getClass().getSimpleName();
// }
// }
//
// public Object getFoo() {
// return foo;
// }
//
// public String getBar() {
// return bar;
// }
//
// public int getBaz() {
// return baz;
// }
// }
|
import net.steppschuh.markdowngenerator.DummyObject;
import org.junit.Test;
|
package net.steppschuh.markdowngenerator.text;
/**
* Created by steppschuh on 15/12/2016.
*/
public class TextTest {
@Test
public void example1() throws Exception {
Text text = new Text("I am normal text");
System.out.println(text);
}
@Test
public void example2() throws Exception {
|
// Path: Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/DummyObject.java
// public class DummyObject implements MarkdownSerializable {
//
// private Object foo;
// private String bar;
// private int baz;
//
// public DummyObject() {
// this.foo = true;
// this.bar = "qux";
// this.baz = 1337;
// }
//
// public DummyObject(Object foo, String bar, int baz) {
// this.foo = foo;
// this.bar = bar;
// this.baz = baz;
// }
//
// public TableRow toMarkdownTableRow() {
// return new TableRow<>(Arrays.asList(
// foo, bar, baz
// ));
// }
//
// @Override
// public MarkdownElement toMarkdownElement() throws MarkdownSerializationException {
// return toMarkdownTableRow();
// }
//
// @Override
// public String toString() {
// try {
// return toMarkdownElement().toString();
// } catch (MarkdownSerializationException e) {
// return this.getClass().getSimpleName();
// }
// }
//
// public Object getFoo() {
// return foo;
// }
//
// public String getBar() {
// return bar;
// }
//
// public int getBaz() {
// return baz;
// }
// }
// Path: Source/MarkdownGenerator/src/test/java/net/steppschuh/markdowngenerator/text/TextTest.java
import net.steppschuh.markdowngenerator.DummyObject;
import org.junit.Test;
package net.steppschuh.markdowngenerator.text;
/**
* Created by steppschuh on 15/12/2016.
*/
public class TextTest {
@Test
public void example1() throws Exception {
Text text = new Text("I am normal text");
System.out.println(text);
}
@Test
public void example2() throws Exception {
|
Text text = new Text(new DummyObject());
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.