If you think the Android project LeBlue listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package houtbecke.rs.le.session;
//fromwww.java2s.comimport java.util.Arrays;
publicclass MockedResponseObject implements MockedResponse {
finalprivate String[] mockedResultValues;
private Event[] nextMockedEvents;
@Override
public String[] getMockedResultValues() {
// TODO: allow lazy getting of results
// String[] ret = new String[mockedResultValues.length];
// for (int k = 0; k < mockedResultValues.length; k++)
// ret[k] = mockedResultValues[k].toString();
// return ret;
return mockedResultValues;
}
publicvoid addEvents(Event... events) {
Event[] newEvents = new Event[events.length + nextMockedEvents.length];
System.arraycopy(nextMockedEvents, 0, newEvents, 0, nextMockedEvents.length);
System.arraycopy(events, 0, newEvents, nextMockedEvents.length, events.length);
nextMockedEvents = newEvents;
}
@Override
public Event[] getNextMockedEvents() {
return nextMockedEvents;
}
int pos = -1;
String value = null;
publicvoid forArguments(String argument, int pos) {
this.pos = pos;
this.value = argument;
}
boolean selfDestroying = false;
@Override
publicboolean isSelfDestroying() {
return selfDestroying;
}
publicvoid destroyAfterUse() {
selfDestroying = true;
}
@Override
publicboolean isForArguments(String[] values) {
if (pos == -1)
return true;
if (pos >= values.length)
return false;
if (value == null)
return values[pos] == null;
return value.equals(values[pos]);
}
public MockedResponseObject(Event nextMockedEvent) {
this(new Event[] {nextMockedEvent}, null);
}
public MockedResponseObject(String... mockedResultValues) {
this(new Event[]{}, mockedResultValues);
}
public MockedResponseObject(Event nextMockedEvent, String[] mockedResultValues) {
this(new Event[]{nextMockedEvent}, mockedResultValues);
}
public MockedResponseObject(Event... nextMockedEvents) {
this(nextMockedEvents, new String[] {});
}
public MockedResponseObject(Event nextMockedEvents[], String[] mockedResultValues) {
this.mockedResultValues = mockedResultValues == null ? new String[] {} : mockedResultValues;
this.nextMockedEvents = nextMockedEvents;
}
}