nus-yam/ex-repair huggingface dataset:
Program: 184308
Project: 184308
Buggy source:
public String compile(CompilerContext context,Type type,Code code){
  String name="String_Node_Str" + type.name + "String_Node_Str"+ "String_Node_Str"+ String.valueOf(count++);
  try {
    byte[] b=this.doCompile(name,code,context);
    if (log.isDebugEnabled()) {
      try {
        FileOutputStream fos=new FileOutputStream("String_Node_Str" + name + "String_Node_Str");
        fos.write(b);
        fos.close();
      }
 catch (      FileNotFoundException e) {
        log.error(e);
        throw new RuntimeException(e);
      }
catch (      IOException e) {
        log.error(e);
        throw new RuntimeException(e);
      }
    }
    NebulaClassLoader.defineClass(name,b);
    return name;
  }
 catch (  ClassFormatError e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
public String compile(CompilerContext context,Type type,Code code){
  String name=this.getClass().getSimpleName() + "String_Node_Str" + type.name+ "String_Node_Str"+ "String_Node_Str"+ String.valueOf(count++);
  try {
    byte[] b=this.doCompile(name,code,context);
    if (log.isDebugEnabled()) {
      try {
        FileOutputStream fos=new FileOutputStream("String_Node_Str" + name + "String_Node_Str");
        fos.write(b);
        fos.close();
      }
 catch (      FileNotFoundException e) {
        log.error(e);
        throw new RuntimeException(e);
      }
catch (      IOException e) {
        log.error(e);
        throw new RuntimeException(e);
      }
    }
    NebulaClassLoader.defineClass(name,b);
    return name;
  }
 catch (  ClassFormatError e) {
    throw new RuntimeException(e);
  }
}
Program: 184309
Project: 184309
Buggy source:
public <T>EntityExpression compile(CompilerContext context,Type type,String actionName,Expr<T> exp){
  String name="String_Node_Str" + type.name + "String_Node_Str"+ NamesEncoding.encode(actionName)+ "String_Node_Str"+ String.valueOf(count++);
  try {
    byte[] b=this.doCompile(name,exp,context);
    if (log.isDebugEnabled()) {
      try {
        FileOutputStream fos=new FileOutputStream("String_Node_Str" + name + "String_Node_Str");
        fos.write(b);
        fos.close();
      }
 catch (      FileNotFoundException e) {
        log.error(e);
        throw new RuntimeException(e);
      }
catch (      IOException e) {
        log.error(e);
        throw new RuntimeException(e);
      }
    }
    Class<?> expClass=NebulaClassLoader.defineClass(name,b);
    EntityExpression expr=(EntityExpression)expClass.newInstance();
    return expr;
  }
 catch (  ClassFormatError e) {
    throw new RuntimeException(e);
  }
catch (  InstantiationException e) {
    throw new RuntimeException(e);
  }
catch (  IllegalAccessException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
public <T>EntityExpression compile(CompilerContext context,Type type,String actionName,Expr<T> exp){
  String name=this.getClass().getSimpleName() + "String_Node_Str" + type.name+ "String_Node_Str"+ NamesEncoding.encode(actionName)+ "String_Node_Str"+ String.valueOf(count++);
  try {
    byte[] b=this.doCompile(name,exp,context);
    if (log.isDebugEnabled()) {
      try {
        FileOutputStream fos=new FileOutputStream("String_Node_Str" + name + "String_Node_Str");
        fos.write(b);
        fos.close();
      }
 catch (      FileNotFoundException e) {
        log.error(e);
        throw new RuntimeException(e);
      }
catch (      IOException e) {
        log.error(e);
        throw new RuntimeException(e);
      }
    }
    Class<?> expClass=NebulaClassLoader.defineClass(name,b);
    EntityExpression expr=(EntityExpression)expClass.newInstance();
    return expr;
  }
 catch (  ClassFormatError e) {
    throw new RuntimeException(e);
  }
catch (  InstantiationException e) {
    throw new RuntimeException(e);
  }
catch (  IllegalAccessException e) {
    throw new RuntimeException(e);
  }
}
Program: 184311
Project: 184311
Buggy source:
protected void setUp() throws Exception {
  loader=new TypeLoaderForTest(new SystemTypeLoader());
  funcCmp=new EntityActionComplier();
  context=new CompilerContext(){
    @Override public Type resolveType(    String name){
      return loader.findType(name);
    }
  }
;
  cp=new Compiler(context);
}

Fixed version (ground truth):
protected void setUp() throws Exception {
  loader=new TypeLoaderForTest(new SystemTypeLoader());
  funcCmp=EntityActionComplier.DEFAULT;
  context=new CompilerContext(){
    @Override public Type resolveType(    String name){
      return loader.findType(name);
    }
  }
;
  cp=new Compiler(context);
}
Program: 184312
Project: 184312
Buggy source:
protected void setUp() throws Exception {
  loader=new TypeLoaderForTest(new SystemTypeLoader());
  funcCmp=new EntityClauseComplier();
  context=new CompilerContext(){
    @Override public Type resolveType(    String name){
      return loader.findType(name);
    }
  }
;
  cp=new Compiler(context);
}

Fixed version (ground truth):
protected void setUp() throws Exception {
  loader=new TypeLoaderForTest(new SystemTypeLoader());
  funcCmp=EntityClauseComplier.DEFAULT;
  context=new CompilerContext(){
    @Override public Type resolveType(    String name){
      return loader.findType(name);
    }
  }
;
  cp=new Compiler(context);
}
Program: 184313
Project: 184313
Buggy source:
@SuppressWarnings("String_Node_Str") private <T>T compute(Expr<T> expr,Entity entity){
  EntityExpressionComplier complier=new EntityExpressionComplier();
  return (T)complier.compile(new CompilerContext(){
    @Override public Type resolveType(    String name){
      return compiler.findType(name);
    }
  }
,type,"String_Node_Str",expr).eval(context,null,entity);
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") private <T>T compute(Expr<T> expr,Entity entity){
  EntityExpressionComplier complier=EntityExpressionComplier.DEFAULT;
  return (T)complier.compile(new CompilerContext(){
    @Override public Type resolveType(    String name){
      return compiler.findType(name);
    }
  }
,type,"String_Node_Str",expr).eval(context,null,entity);
}
Program: 184316
Project: 184316
Buggy source:
protected void get(HttpServletRequest req){
  try {
    String query=URIUtil.decodePath(req.getQueryString());
    List<Entity> dataList;
    if (query == null || query.length() == 0) {
      dataList=datastoreHolder.get().listAll();
      this.cache=buildFrom(dataList);
    }
 else {
      this.cache=dataCache.get(query).get();
    }
    this.lastModified=System.currentTimeMillis();
  }
 catch (  ExecutionException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
protected void get(HttpServletRequest req){
  this.cache=dataCached.get();
  this.lastModified=System.currentTimeMillis();
}
Program: 184317
Project: 184317
Buggy source:
public AttachedEntityListResouce(Broker<DataHelper<Entity,Reader,Writer>> json,Broker<DataStore<Entity>> datas,final String attachedToTypeName,final String attachToID){
  super("String_Node_Str",0,1000);
  this.jsonHolder=json;
  this.datastoreHolder=datas;
  this.dataCache=CacheBuilder.newBuilder().maximumSize(1000).build(new CacheLoader<String,DataHolder>(){
    public DataHolder load(    String query){
      DataStore<Entity> dataStore=datastoreHolder.get();
      Map<String,Classificator<String,Entity>> classificatores=dataStore.getClassificatores();
      return new DataHolder(classificatores.get(checkNotNull(attachedToTypeName)),attachToID);
    }
  }
);
  json.addWatcher(new DataWatcher<DataHelper<Entity,Reader,Writer>>(){
    @Override public boolean onUpdate(    DataHelper<Entity,Reader,Writer> newData,    DataHelper<Entity,Reader,Writer> oldData){
      dataCache.cleanUp();
      return false;
    }
  }
);
}

Fixed version (ground truth):
public AttachedEntityListResouce(Broker<DataHelper<Entity,Reader,Writer>> json,Broker<DataStore<Entity>> datas,final String attachedToTypeName,final String attachToID){
  super("String_Node_Str",0,1000);
  this.jsonHolder=json;
  this.datastoreHolder=datas;
  this.dataCached=new DataHolder(datastoreHolder.get().getClassificator(checkNotNull(attachedToTypeName)),attachToID);
}
Program: 184318
Project: 184318
Buggy source:
Flow(TypeLoader typeLoader,String name){
  super(typeLoader,name);
  steps=new SmartList<String,Step>(new Function<Step,String>(){
    @Override public String apply(    Step input){
      return input.name;
    }
  }
);
}

Fixed version (ground truth):
Flow(TypeLoader typeLoader,Type superType,String name){
  super(typeLoader,name,superType,TypeStandalone.Flow);
  steps=new SmartList<String,Step>(new Function<Step,String>(){
    @Override public String apply(    Step input){
      return input.name;
    }
  }
);
}
Program: 184319
Project: 184319
Buggy source:
public void put(T newData){
  boolean hasLostReference=false;
  for (  DataWatcher<T> listener : listeners) {
    if (listener != null) {
      boolean result=listener.onUpdate(newData,this.lastData);
      if (!result)       break;
    }
 else {
      hasLostReference=true;
    }
  }
  if (hasLostReference) {
    for (int i=listeners.size() - 1; i >= 0; i--) {
      DataWatcher<T> listener=listeners.get(i);
      if (listener == null) {
        listeners.remove(i);
      }
    }
  }
  this.lastData=newData;
}

Fixed version (ground truth):
public void put(T newData){
  boolean hasLostReference=false;
  for (  DataWatcher<T> listener : listeners) {
    if (listener != null) {
      boolean result=listener.onUpdate(newData,this.lastData);
      if (result)       break;
    }
 else {
      hasLostReference=true;
    }
  }
  if (hasLostReference) {
    for (int i=listeners.size() - 1; i >= 0; i--) {
      DataWatcher<T> listener=listeners.get(i);
      if (listener == null) {
        listeners.remove(i);
      }
    }
  }
  this.lastData=newData;
}
Program: 184320
Project: 184320
Buggy source:
public DefaultDataRepos(TypeDatastore loader){
  this.typeBrokers=loader;
  this.cachedDatastore=CacheBuilder.newBuilder().build(new CacheLoader<String,BrokerEx>(){
    public BrokerEx load(    final String path) throws Exception {
      Broker<Type> typeBroker=DefaultDataRepos.this.typeBrokers.getBroker(path);
      DataStore datastore=DefaultDataRepos.this.loadDataStore(typeBroker.get().getName(),typeBroker.get());
      BrokerCascade<DataStore,Type> datastoreBroker=new BrokerCascade<DataStore,Type>(datastore){
        @Override public boolean onUpdate(        Type newData,        Type oldData){
          DataStore datastore=DefaultDataRepos.this.loadDataStore(newData.getName(),oldData);
          this.put(datastore);
          return false;
        }
      }
;
      typeBroker.addWatcher(datastoreBroker);
      return datastoreBroker;
    }
  }
);
}

Fixed version (ground truth):
public DefaultDataRepos(TypeDatastore loader){
  this.typeBrokers=loader;
  this.cachedDatastore=CacheBuilder.newBuilder().build(new CacheLoader<String,BrokerEx>(){
    public BrokerEx load(    final String path) throws Exception {
      Broker<Type> typeBroker=DefaultDataRepos.this.typeBrokers.getBroker(path);
      DataStore datastore=DefaultDataRepos.this.loadDataStore(typeBroker.get().getName(),typeBroker.get());
      BrokerCascade<DataStore,Type> datastoreBroker=new BrokerCascade<DataStore,Type>(datastore){
        @Override public boolean onUpdate(        Type newData,        Type oldData){
          DataStore datastore=DefaultDataRepos.this.loadDataStore(newData.getName(),newData);
          this.put(datastore);
          return false;
        }
      }
;
      typeBroker.addWatcher(datastoreBroker);
      return datastoreBroker;
    }
  }
);
}
Program: 184321
Project: 184321
Buggy source:
@Override public boolean onUpdate(Type newData,Type oldData){
  DataStore datastore=DefaultDataRepos.this.loadDataStore(newData.getName(),oldData);
  this.put(datastore);
  return false;
}

Fixed version (ground truth):
@Override public boolean onUpdate(Type newData,Type oldData){
  DataStore datastore=DefaultDataRepos.this.loadDataStore(newData.getName(),newData);
  this.put(datastore);
  return false;
}
Program: 184325
Project: 184325
Buggy source:
@SuppressWarnings("String_Node_Str") @Override public boolean equals(Object obj){
  return filterFunction.equals(((DataFilter<V>)obj).filterFunction);
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") @Override public boolean equals(Object obj){
  return obj != null ? filterFunction.equals(((DataFilter<V>)obj).filterFunction) : false;
}
Program: 184326
Project: 184326
Buggy source:
@Override public void flush(){
  lock.lock();
  try {
    Iterator<EditableEntity> i=changes.listIterator();
    while (i.hasNext()) {
      EditableEntity e=i.next();
      e.store.apply(e);
    }
  }
  finally {
    changes.clear();
    lock.unlock();
  }
}

Fixed version (ground truth):
@Override public void flush(){
  lock.lock();
  try {
    Iterator<EditableEntity> i=changes.listIterator();
    while (i.hasNext()) {
      EditableEntity e=i.next();
      e.store.apply(e);
    }
    changes.clear();
  }
  finally {
    lock.unlock();
  }
}
Program: 184327
Project: 184327
Buggy source:
@Override public void clearChanges(){
  lock.lock();
  changes.clear();
  lock.unlock();
}

Fixed version (ground truth):
@Override public void clearChanges(){
  lock.lock();
  try {
    changes.clear();
  }
  finally {
    lock.unlock();
  }
}
Program: 184328
Project: 184328
Buggy source:
@Override public void markChanged(Entity v){
  lock.lock();
  changes.add((EditableEntity)v);
  lock.unlock();
}

Fixed version (ground truth):
@Override public void markChanged(Entity v){
  lock.lock();
  try {
    changes.add((EditableEntity)v);
  }
  finally {
    lock.unlock();
  }
}
Program: 184330
Project: 184330
Buggy source:
public RecentDateClassificatorFunction(){
  today=new DateTime().withMillisOfDay(0);
  thisWeek=today.withDayOfWeek(1);
  thisMonth=today.withDayOfMonth(1);
  threeMonth=today.minusMonths(2).withDayOfMonth(1);
  sixMonth=today.minusMonths(5).withDayOfMonth(1);
}

Fixed version (ground truth):
public RecentDateClassificatorFunction(DateTime today){
  this.today=today;
  thisWeek=today.withDayOfWeek(1);
  thisMonth=today.withDayOfMonth(1);
  threeMonth=today.minusMonths(2).withDayOfMonth(1);
  sixMonth=today.minusMonths(5).withDayOfMonth(1);
}
Program: 184331
Project: 184331
Buggy source:
public static String encode(String value){
  char[] vs=value.toCharArray();
  char[] nvs=new char[vs.length * 3 + 1];
  int posV=0;
  int posNv=0;
  boolean special=false;
  for (; posV < vs.length; ) {
    if (vs[posV] < 0xFF) {
      char v=vs[posV++];
      if ('0' <= v && v <= '9') {
        nvs[posNv++]='D';
        nvs[posNv++]=v;
        special=true;
        break;
      }
 else       if ('A' <= v && v <= 'Z') {
        nvs[posNv++]=v;
        break;
      }
 else       if ('a' <= v && v <= 'z') {
        nvs[posNv++]=(char)(v - 0x20);
        break;
      }
 else {
      }
    }
 else {
      nvs[posNv++]='Z';
      special=true;
      break;
    }
  }
  for (; posV < vs.length; posV++) {
    char v=vs[posV];
    if (v < 0xFF) {
      if (('0' <= v && v <= '9') || ('A' <= v && v <= 'Z')) {
        nvs[posNv++]=v;
      }
 else       if ('a' <= v && v <= 'z') {
        nvs[posNv++]=(char)(v - 0x20);
      }
 else       if ('_' == v) {
        nvs[posNv++]=v;
      }
 else       if ('-' == v) {
        nvs[posNv++]='_';
      }
 else {
      }
    }
 else {
      int nv=v - 0xFF;
      nvs[posNv++]=e[nv % SPAC];
      nv/=SPAC;
      nvs[posNv++]=e[nv % SPAC];
    }
  }
  if (special) {
    nvs[posNv++]='_';
  }
  return new String(nvs,0,posNv);
}

Fixed version (ground truth):
public static String encode(String value){
  char[] vs=value.toCharArray();
  char[] nvs=new char[vs.length * 3 + 1];
  int posV=0;
  int posNv=0;
  boolean special=false;
  for (; posV < vs.length; ) {
    if (vs[posV] < 0xFF) {
      char v=vs[posV++];
      if ('0' <= v && v <= '9') {
        nvs[posNv++]='D';
        nvs[posNv++]=v;
        special=true;
        break;
      }
 else       if ('A' <= v && v <= 'Z') {
        nvs[posNv++]=v;
        break;
      }
 else       if ('a' <= v && v <= 'z') {
        nvs[posNv++]=(char)(v - 0x20);
        break;
      }
 else {
      }
    }
 else {
      nvs[posNv++]='Z';
      special=true;
      break;
    }
  }
  for (; posV < vs.length; posV++) {
    char v=vs[posV];
    if (v < 0xFF) {
      if (('0' <= v && v <= '9') || ('A' <= v && v <= 'Z')) {
        nvs[posNv++]=v;
      }
 else       if ('a' <= v && v <= 'z') {
        nvs[posNv++]=(char)(v - 0x20);
      }
 else       if ('_' == v) {
        nvs[posNv++]=v;
      }
 else       if ('-' == v) {
        nvs[posNv++]='_';
      }
 else {
      }
    }
 else {
      int nv=v - 0xFF;
      nvs[posNv++]=e[nv % SPAC];
      nv/=SPAC;
      nvs[posNv++]=e[nv % SPAC];
    }
  }
  if (special) {
    nvs[posNv++]='_';
  }
  if (log.isTraceEnabled()) {
    log.trace("String_Node_Str" + value + "String_Node_Str"+ new String(nvs,0,posNv)+ "String_Node_Str");
  }
  return new String(nvs,0,posNv);
}
Program: 184333
Project: 184333
Buggy source:
protected void setUp() throws Exception {
  super.setUp();
  list=new SmartList<Entity>(new Function<Entity,String>(){
    @Override public String apply(    Entity from){
      return from.get("String_Node_Str").toString();
    }
  }
);
  classificator=list.liveClassify(new Function<Entity,String>(){
    Function<DateTime,String> convertFunction=new RecentDateClassificatorFunction();
    @Override public String apply(    Entity from){
      return convertFunction.apply((DateTime)from.get("String_Node_Str"));
    }
  }
);
}

Fixed version (ground truth):
protected void setUp() throws Exception {
  super.setUp();
  list=new SmartList<Entity>(new Function<Entity,String>(){
    @Override public String apply(    Entity from){
      return from.get("String_Node_Str").toString();
    }
  }
);
  classificator=list.liveClassify(new Function<Entity,String>(){
    Function<DateTime,String> convertFunction=new RecentDateClassificatorFunction(new DateTime().withDayOfMonth(10).withDayOfWeek(3));
    @Override public String apply(    Entity from){
      return convertFunction.apply((DateTime)from.get("String_Node_Str"));
    }
  }
);
}
Program: 184334
Project: 184334
Buggy source:
public void testActualFields_Key() throws RecognitionException {
  String text="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  List<Type> fs=loader.defineNebula(new StringReader(text));
  Type type=fs.get(0);
}

Fixed version (ground truth):
public void testActualFields_Key() throws RecognitionException {
  String text="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  List<Type> fs=loader.defineNebula(new StringReader(text));
  Type type=fs.get(0);
  List<Field> fields=type.fields;
  int i=0;
  assertEquals("String_Node_Str",fields.get(i).name);
  assertEquals(Importance.Key,fields.get(i).importance);
  i++;
  assertEquals("String_Node_Str",fields.get(i).name);
  assertEquals(Importance.Key,fields.get(i).importance);
  assertEquals(i + 1,fields.size());
}
Program: 184336
Project: 184336
Buggy source:
@Override public void output(JsonGenerator out,Type value) throws Exception {
  Type type=(Type)value;
  out.writeStartObject();
  out.writeStringField("String_Node_Str",type.getName());
  if (type.getSuperType() != null) {
    out.writeStringField("String_Node_Str",type.getSuperType().getName());
  }
  out.writeStringField("String_Node_Str",type.getStandalone().name());
  out.writeFieldName("String_Node_Str");
  fieldListDataDealer.writeTo(null,type.getFields(),out);
  out.writeFieldName("String_Node_Str");
  out.writeStartObject();
  InheritHashMap p=type.getAttrs();
  for (  String k : p.getNames()) {
    out.writeStringField(k,p.get(k).toString());
  }
  out.writeEndObject();
  Alias n=type.getNameAlias();
  out.writeFieldName("String_Node_Str");
  out.writeStartObject();
  for (  String k : n.alias.keySet()) {
    out.writeStringField(k,n.alias.get(k).toString());
  }
  out.writeEndObject();
  out.writeBooleanField("String_Node_Str",type.isMutable());
  out.writeStringField("String_Node_Str",type.getCode());
  out.writeEndObject();
}

Fixed version (ground truth):
@Override public void output(JsonGenerator out,Type value) throws Exception {
  Type type=(Type)value;
  out.writeStartObject();
  out.writeStringField("String_Node_Str",type.getName());
  if (type.getSuperType() != null) {
    out.writeStringField("String_Node_Str",type.getSuperType().getName());
  }
  out.writeStringField("String_Node_Str",type.getStandalone().name());
  out.writeFieldName("String_Node_Str");
  fieldListDataDealer.writeTo(null,type.getFields(),out);
  Alias n=type.getNameAlias();
  out.writeFieldName("String_Node_Str");
  out.writeStartObject();
  for (  String k : n.alias.keySet()) {
    out.writeStringField(k,n.alias.get(k).toString());
  }
  out.writeEndObject();
  out.writeFieldName("String_Node_Str");
  out.writeStartObject();
  InheritHashMap p=type.getAttrs();
  for (  String k : p.getNames()) {
    out.writeStringField(k,p.get(k).toString());
  }
  out.writeEndObject();
  out.writeBooleanField("String_Node_Str",type.isMutable());
  out.writeStringField("String_Node_Str",type.getCode());
  out.writeEndObject();
}
Program: 184337
Project: 184337
Buggy source:
public void put(String name,Object v){
  newData.put(name,v);
  if (data != null) {
    store.markChanged(this);
  }
  this.dirty=true;
}

Fixed version (ground truth):
public void put(String name,Object v){
  newData.put(name,v);
  if (!this.dirty && data != null) {
    store.markChanged(this);
  }
  this.dirty=true;
}
Program: 184338
Project: 184338
Buggy source:
@Override public void add(Entity v){
  persistence.add(v);
}

Fixed version (ground truth):
@Override public void add(Entity v){
  if (v.isTransient()) {
    EditableEntity entity=(EditableEntity)v;
    entity.store=this;
  }
  persistence.add(v);
}
Program: 184339
Project: 184339
Buggy source:
@Override protected String post(Request req){
  try {
    DataStore<Entity> store=datastoreHolder.get();
    Entity data=store.createNew();
    InputStream in=req.getInputStream();
    if (log.isTraceEnabled()) {
      in=FileUtil.print(in);
    }
    Entity inData=jsonHolder.get().readFrom(data,new InputStreamReader(in));
    store.add(inData);
    store.flush();
    return req.getAddress().getPath() + data.getID();
  }
 catch (  IOException e) {
    log.error(e);
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
@Override protected String post(Request req){
  try {
    DataStore<Entity> store=datastoreHolder.get();
    InputStream in=req.getInputStream();
    if (log.isTraceEnabled()) {
      in=FileUtil.print(in);
    }
    Entity inData=jsonHolder.get().readFrom(null,new InputStreamReader(in));
    store.add(inData);
    store.flush();
    return req.getAddress().getPath() + inData.getID();
  }
 catch (  IOException e) {
    log.error(e);
    throw new RuntimeException(e);
  }
}
Program: 184340
Project: 184340
Buggy source:
protected void put(Request req) throws IOException {
  BufferedInputStream bio=new BufferedInputStream(req.getInputStream());
  if (log.isTraceEnabled()) {
    log.trace("String_Node_Str");
    log.trace(FileUtil.readAllTextFrom(bio));
  }
  Type type=typeLoader.findType(key);
  String oldCode=type.getCode();
  String newCode=FileUtil.readAllTextFrom(bio);
  if (!oldCode.equals(newCode)) {
    if (log.isTraceEnabled()) {
      log.trace("String_Node_Str");
      log.trace(oldCode);
      log.trace("String_Node_Str");
      log.trace(type.getCode());
    }
    type=typeLoader.update(type,newCode);
    dataWareHouse.define(Entity.class,type.getName());
  }
 else {
    if (log.isTraceEnabled()) {
      log.trace("String_Node_Str");
      log.trace(type.getCode());
    }
  }
}

Fixed version (ground truth):
protected void put(Request req) throws IOException {
  BufferedInputStream bio=new BufferedInputStream(req.getInputStream());
  if (log.isTraceEnabled()) {
    log.trace("String_Node_Str");
    log.trace(FileUtil.readAllTextFrom(bio));
  }
  Type type=typeLoader.findType(key);
  String oldCode=type.getCode();
  String newCode=FileUtil.readAllTextFrom(bio);
  if (!oldCode.equals(newCode)) {
    if (log.isTraceEnabled()) {
      log.trace("String_Node_Str");
      log.trace(oldCode);
      log.trace("String_Node_Str");
      log.trace(type.getCode());
    }
    type=typeLoader.update(type,newCode);
    dataWareHouse.reload(Entity.class,type.getName());
  }
 else {
    if (log.isTraceEnabled()) {
      log.trace("String_Node_Str");
      log.trace(type.getCode());
    }
  }
}
Program: 184342
Project: 184342
Buggy source:
@Override public void add(Entity v){
  if (v instanceof EditableEntity) {
    EditableEntity vv=(EditableEntity)v;
    this.markChanged(vv);
  }
}

Fixed version (ground truth):
@Override public void add(Entity v){
}
Program: 184343
Project: 184343
Buggy source:
@Override public void reload(Class<Entity> clz,String name){
  DataHolder<DataStore<Entity>> store=this.stores.get(name);
  if (store != null) {
    DataStore<Entity> oldData=store.get();
    oldData.unload();
    Type type=loader.findType(name);
    DataStore<Entity> newData=new EntityDbDataStore(this,type,dbConfig.getPersister(type));
    store.set(newData,oldData);
  }
 else {
    throw new UnsupportedOperationException("String_Node_Str");
  }
}

Fixed version (ground truth):
@Override public void reload(Class<Entity> clz,String name){
  DataHolder<DataStore<Entity>> holder=this.stores.get(name);
  if (holder != null) {
    DataStore<Entity> oldData=holder.get();
    oldData.unload();
    Type type=loader.findType(name);
    DataStore<Entity> newData=new EntityDbDataStore(this,type,dbConfig.getPersister(type));
    holder.set(newData,oldData);
  }
 else {
    throw new UnsupportedOperationException("String_Node_Str");
  }
}
Program: 184344
Project: 184344
Buggy source:
public final void test_SimpleTypeWith_EntityArray_readJsonParserString() throws Exception {
  String txtType="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  type=loader.testDefineNebula(new StringReader(txtType)).get(0);
  entityMerger=new EntitySerializer(type);
  String txtData="String_Node_Str";
  StringReader in=new StringReader(txtData);
  JsonParser jsonParser=factory.createJsonParser(in);
  Entity entity=entityMerger.readFrom(new EditableEntity(),jsonParser);
  assertNotNull(entity);
  assertEquals("String_Node_Str",entity.get("String_Node_Str"));
  assertEquals(12L,entity.get("String_Node_Str"));
  @SuppressWarnings("String_Node_Str") List<Entity> educations=(List<Entity>)entity.get("String_Node_Str");
  assertEquals(2,educations.size());
}

Fixed version (ground truth):
public final void test_SimpleTypeWith_EntityArray_readJsonParserString() throws Exception {
  String txtType="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  type=loader.testDefineNebula(new StringReader(txtType)).get(0);
  entityMerger=new EntitySerializer(type);
  String txtData="String_Node_Str";
  StringReader in=new StringReader(txtData);
  JsonParser jsonParser=factory.createJsonParser(in);
  Entity entity=entityMerger.readFrom(null,jsonParser);
  assertNotNull(entity);
  assertEquals("String_Node_Str",entity.get("String_Node_Str"));
  assertEquals(12L,entity.get("String_Node_Str"));
  @SuppressWarnings("String_Node_Str") List<Entity> educations=(List<Entity>)entity.get("String_Node_Str");
  assertEquals(2,educations.size());
}
Program: 184345
Project: 184345
Buggy source:
@Override protected void get(Address address){
  Query query=address.getQuery();
  List<Type> dataList;
  if (query.isEmpty()) {
    dataList=types;
  }
 else {
    Filter<Type> filter=filterBuilder.buildFrom(query,null);
    dataList=types.query(filter);
  }
  ByteArrayOutputStream bout=new ByteArrayOutputStream();
  PrintStream out=new PrintStream(bout);
  boolean start=true;
  out.append('[');
  for (  Type data : dataList) {
    if (!start) {
      out.append(',');
    }
 else {
      start=false;
    }
    json.stringifyTo(data,new OutputStreamWriter(out));
  }
  out.append(']');
  out.flush();
  out.close();
  this.lastModified=System.currentTimeMillis();
  this.cache=bout.toByteArray();
}

Fixed version (ground truth):
@Override protected void get(Address address){
  Query query=address.getQuery();
  List<Type> dataList;
  if (query.isEmpty()) {
    dataList=typeLoader.all();
  }
 else {
    Filter<Type> filter=filterBuilder.buildFrom(query,null);
    dataList=typeLoader.all().query(filter);
  }
  ByteArrayOutputStream bout=new ByteArrayOutputStream();
  PrintStream out=new PrintStream(bout);
  boolean start=true;
  out.append('[');
  for (  Type data : dataList) {
    if (!start) {
      out.append(',');
    }
 else {
      start=false;
    }
    json.stringifyTo(data,new OutputStreamWriter(out));
  }
  out.append(']');
  out.flush();
  out.close();
  this.lastModified=System.currentTimeMillis();
  this.cache=bout.toByteArray();
}
Program: 184346
Project: 184346
Buggy source:
public TypeListResouce(TypeLoader typeLoader,JsonHelper<Type> json,TypeFilterBuilder filterBuilder){
  this.types=typeLoader.all();
  this.typeLoader=typeLoader;
  this.json=json;
  this.filterBuilder=filterBuilder;
}

Fixed version (ground truth):
public TypeListResouce(TypeLoader typeLoader,JsonHelper<Type> json,TypeFilterBuilder filterBuilder){
  this.typeLoader=typeLoader;
  this.json=json;
  this.filterBuilder=filterBuilder;
}
Program: 184347
Project: 184347
Buggy source:
protected void make(){
  try {
    ByteArrayOutputStream bout=new ByteArrayOutputStream();
    Writer w=new OutputStreamWriter(bout);
    Map<String,String> data=datas.get(key);
    json.stringifyTo(data,bout);
    w.flush();
    w.close();
    this.lastModified=System.currentTimeMillis();
    this.buffer=bout.toByteArray();
  }
 catch (  IOException e) {
    log.error(e);
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
protected void make(){
  try {
    ByteArrayOutputStream bout=new ByteArrayOutputStream();
    Writer w=new OutputStreamWriter(bout);
    Map<String,String> data=datas.get(key);
    if (data != null) {
      json.stringifyTo(data,bout);
      w.flush();
      w.close();
      this.lastModified=System.currentTimeMillis();
      this.buffer=bout.toByteArray();
    }
 else {
      this.lastModified=System.currentTimeMillis();
      this.buffer=new byte[0];
    }
  }
 catch (  IOException e) {
    log.error(e);
    throw new RuntimeException(e);
  }
}
Program: 184349
Project: 184349
Buggy source:
@Override public Resource resolve(Address target){
  Path path=target.getPath();
  Source source=loader.findSource(path.getPath());
  if (source != null) {
    return new StaticResource(source,TheMimeTypes.get(source));
  }
  String[] segments=target.getPath().getSegments();
  String templateTypeName=segments[0];
  if (segments.length != 2) {
    throw new RuntimeException(segments.toString());
  }
  String[] names=path.getName().split("String_Node_Str");
  String typeName=names[0];
  String actionName=names[1];
  if (log.isTraceEnabled()) {
    log.trace("String_Node_Str" + path);
    log.trace("String_Node_Str" + templateTypeName);
    log.trace("String_Node_Str" + typeName);
    log.trace("String_Node_Str" + actionName);
  }
  return new TemplateResouce(cfg,typeLoader,templateTypeName,typeName,actionName);
}

Fixed version (ground truth):
@Override public Resource resolve(Address target){
  Path path=target.getPath();
  Source source=loader.findSource(path.getPath());
  if (source != null) {
    return new EditableStaticResource(source,TheMimeTypes.get(source));
  }
  String[] segments=target.getPath().getSegments();
  String templateTypeName=segments[0];
  if (segments.length != 2) {
    throw new RuntimeException(segments.toString());
  }
  String[] names=path.getName().split("String_Node_Str");
  String typeName=names[0];
  String actionName=names[1];
  if (log.isTraceEnabled()) {
    log.trace("String_Node_Str" + path);
    log.trace("String_Node_Str" + templateTypeName);
    log.trace("String_Node_Str" + typeName);
    log.trace("String_Node_Str" + actionName);
  }
  return new TemplateResouce(cfg,typeLoader,templateTypeName,typeName,actionName);
}
Program: 184350
Project: 184350
Buggy source:
@Override public void configure(BasicResourceContainer site){
  site.register("String_Node_Str",staticEngine);
  site.register("String_Node_Str",templateResouceEngine);
  site.register("String_Node_Str",typeResouceEngine);
  site.register("String_Node_Str",staticEngine);
  site.register("String_Node_Str",dataResouceEngine);
  site.register("String_Node_Str",typeResouceEngine);
  site.register("String_Node_Str",typeResouceEngine);
}

Fixed version (ground truth):
@Override public void configure(BasicResourceContainer site){
  site.register("String_Node_Str",staticEngine);
  site.register("String_Node_Str",templateResouceEngine);
  site.register("String_Node_Str",templateResouceEngine);
  site.register("String_Node_Str",typeResouceEngine);
  site.register("String_Node_Str",staticEngine);
  site.register("String_Node_Str",dataResouceEngine);
  site.register("String_Node_Str",typeResouceEngine);
  site.register("String_Node_Str",typeResouceEngine);
}
Program: 184351
Project: 184351
Buggy source:
@Override public Object[] bind(Context context,Method method){
  System.out.println("String_Node_Str" + method.getName());
  if ("String_Node_Str".equals(method.getName()) || "String_Node_Str".equals(method.getName())) {
    Company company=new Company();
    if (context.getId() != null)     company.setId(Integer.parseInt(context.getId()));
    company.setName((String)context.getParameter("String_Node_Str"));
    company.setTel((String)context.getParameter("String_Node_Str"));
    company.setAddress((String)context.getParameter("String_Node_Str"));
    company.setDescription((String)context.getParameter("String_Node_Str"));
    return new Object[]{company};
  }
 else   if ("String_Node_Str".equals(method.getName())) {
    return new Object[]{Long.parseLong((String)context.getParameter("String_Node_Str"))};
  }
 else   if ("String_Node_Str".equals(method.getName())) {
    String id=context.getId();
    return new Object[]{id};
  }
 else   if ("String_Node_Str".equals(method.getName())) {
    return new Object[]{Integer.valueOf(((String)context.getParameter("String_Node_Str")))};
  }
  return null;
}

Fixed version (ground truth):
@Override public Object[] bind(Context context,Method method){
  System.out.println("String_Node_Str" + method.getName());
  if ("String_Node_Str".equals(method.getName()) || "String_Node_Str".equals(method.getName())) {
    Company company=new Company();
    if (!"String_Node_Str".equals(method.getName()) && context.getId() != null)     company.setId(Integer.parseInt(context.getId()));
    company.setName((String)context.getParameter("String_Node_Str"));
    company.setTel((String)context.getParameter("String_Node_Str"));
    company.setAddress((String)context.getParameter("String_Node_Str"));
    company.setDescription((String)context.getParameter("String_Node_Str"));
    return new Object[]{company};
  }
 else   if ("String_Node_Str".equals(method.getName())) {
    return new Object[]{Long.parseLong((String)context.getParameter("String_Node_Str"))};
  }
 else   if ("String_Node_Str".equals(method.getName())) {
    String id=context.getId();
    return new Object[]{id};
  }
 else   if ("String_Node_Str".equals(method.getName())) {
    return new Object[]{Integer.valueOf(((String)context.getParameter("String_Node_Str")))};
  }
  return null;
}
Program: 184352
Project: 184352
Buggy source:
public static DataBinder<Company> createDataBinder(){
  return new DataBinder<Company>(){
    @Override public Object[] bind(    Context context,    Method method){
      System.out.println("String_Node_Str" + method.getName());
      if ("String_Node_Str".equals(method.getName()) || "String_Node_Str".equals(method.getName())) {
        Company company=new Company();
        if (context.getId() != null)         company.setId(Integer.parseInt(context.getId()));
        company.setName((String)context.getParameter("String_Node_Str"));
        company.setTel((String)context.getParameter("String_Node_Str"));
        company.setAddress((String)context.getParameter("String_Node_Str"));
        company.setDescription((String)context.getParameter("String_Node_Str"));
        return new Object[]{company};
      }
 else       if ("String_Node_Str".equals(method.getName())) {
        return new Object[]{Long.parseLong((String)context.getParameter("String_Node_Str"))};
      }
 else       if ("String_Node_Str".equals(method.getName())) {
        String id=context.getId();
        return new Object[]{id};
      }
 else       if ("String_Node_Str".equals(method.getName())) {
        return new Object[]{Integer.valueOf(((String)context.getParameter("String_Node_Str")))};
      }
      return null;
    }
  }
;
}

Fixed version (ground truth):
public static DataBinder<Company> createDataBinder(){
  return new DataBinder<Company>(){
    @Override public Object[] bind(    Context context,    Method method){
      System.out.println("String_Node_Str" + method.getName());
      if ("String_Node_Str".equals(method.getName()) || "String_Node_Str".equals(method.getName())) {
        Company company=new Company();
        if (!"String_Node_Str".equals(method.getName()) && context.getId() != null)         company.setId(Integer.parseInt(context.getId()));
        company.setName((String)context.getParameter("String_Node_Str"));
        company.setTel((String)context.getParameter("String_Node_Str"));
        company.setAddress((String)context.getParameter("String_Node_Str"));
        company.setDescription((String)context.getParameter("String_Node_Str"));
        return new Object[]{company};
      }
 else       if ("String_Node_Str".equals(method.getName())) {
        return new Object[]{Long.parseLong((String)context.getParameter("String_Node_Str"))};
      }
 else       if ("String_Node_Str".equals(method.getName())) {
        String id=context.getId();
        return new Object[]{id};
      }
 else       if ("String_Node_Str".equals(method.getName())) {
        return new Object[]{Integer.valueOf(((String)context.getParameter("String_Node_Str")))};
      }
      return null;
    }
  }
;
}
Program: 184353
Project: 184353
Buggy source:
@Override public void stop(){
  super.stop();
  removeLocationListener();
  getContext().unregisterReceiver(locationReceiver);
}

Fixed version (ground truth):
@Override public void stop(){
  super.stop();
  stpe.shutdown();
  removeLocationListener();
  getContext().unregisterReceiver(locationReceiver);
}
Program: 184354
Project: 184354
Buggy source:
@Override public void start(){
  super.start();
  addLocationListenerWithAllProviders();
  Thread thread=new Thread(controller);
  thread.start();
  IntentFilter intentFilter=new IntentFilter(LOCATION_UPDATE_ACTION);
  getContext().registerReceiver(locationReceiver,intentFilter);
  Log.d(TAG,"String_Node_Str");
}

Fixed version (ground truth):
@Override public void start(){
  super.start();
  addLocationListenerWithAllProviders();
  stpe=new ScheduledThreadPoolExecutor(1);
  stpe.scheduleAtFixedRate(controller,MAX_TIME_WITHOUT_NEW_LOCATION,MAX_TIME_WITHOUT_NEW_LOCATION,TimeUnit.MILLISECONDS);
  IntentFilter intentFilter=new IntentFilter(LOCATION_UPDATE_ACTION);
  getContext().registerReceiver(locationReceiver,intentFilter);
  Log.d(TAG,"String_Node_Str");
}
Program: 184355
Project: 184355
Buggy source:
public void run(){
  long timeElapsed;
  while (isSensing()) {
    Log.d(TAG,"String_Node_Str" + MAX_TIME_WITHOUT_NEW_LOCATION);
    try {
      Thread.sleep(MAX_TIME_WITHOUT_NEW_LOCATION);
    }
 catch (    Exception e) {
      Log.e(TAG,"String_Node_Str",e);
    }
    timeElapsed=System.currentTimeMillis() - lastLocationTime;
    if (timeElapsed > MAX_TIME_WITHOUT_NEW_LOCATION && locationAdded) {
      removeLocationListener();
      Log.d(TAG,"String_Node_Str" + !locationAdded);
    }
    Log.d(TAG,"String_Node_Str" + timeElapsed + "String_Node_Str"+ MAX_TIME_WITHOUT_NEW_LOCATION);
    if (timeElapsed > (MAX_TIME_WITHOUT_NEW_LOCATION + RESTART_TIME) && !locationAdded) {
      addLocationListenerWithAllProviders();
      Log.d(TAG,"String_Node_Str" + locationAdded);
    }
  }
  Log.d(TAG,"String_Node_Str");
}

Fixed version (ground truth):
public void run(){
  long timeElapsed=System.currentTimeMillis() - lastLocationTime;
  Log.d(TAG,"String_Node_Str" + timeElapsed + "String_Node_Str"+ MAX_TIME_WITHOUT_NEW_LOCATION);
  if (timeElapsed > MAX_TIME_WITHOUT_NEW_LOCATION && locationAdded) {
    removeLocationListener();
    Log.d(TAG,"String_Node_Str" + !locationAdded);
  }
 else   if (timeElapsed > (MAX_TIME_WITHOUT_NEW_LOCATION + RESTART_TIME) && !locationAdded) {
    addLocationListenerWithAllProviders();
    Log.d(TAG,"String_Node_Str" + locationAdded);
  }
  Log.d(TAG,"String_Node_Str");
}
Program: 184356
Project: 184356
Buggy source:
/** 
 * @see android.app.Application#onCreate()
 */
@Override public final void onCreate(){
  super.onCreate();
  ProjectGenerator.buildProjectJsonQ(this);
  Log.i(getClass().getName(),"String_Node_Str");
  taskCollection=new HashMap<String,DataTask>();
}

Fixed version (ground truth):
/** 
 * @see android.app.Application#onCreate()
 */
@Override public final void onCreate(){
  super.onCreate();
  ProjectGenerator.buildProjectJsonS(this);
  Log.i(getClass().getName(),"String_Node_Str");
  taskCollection=new HashMap<String,DataTask>();
}
Program: 184357
Project: 184357
Buggy source:
/** 
 * Threads & Runnable 
 */
public void run(){
  Looper.prepare();
  while (isRunning()) {
    try {
      compute();
      if (getPeriodTime() > 1) {
        Thread.sleep(getPeriodTime());
      }
    }
 catch (    Exception e) {
      Log.e(TAG,"String_Node_Str" + e);
    }
  }
}

Fixed version (ground truth):
/** 
 * Threads & Runnable 
 */
public void run(){
  Looper.prepare();
  while (isRunning()) {
    compute();
    if (getPeriodTime() > 1) {
      try {
        Thread.sleep(getPeriodTime());
      }
 catch (      Exception e) {
        Log.e(TAG,"String_Node_Str" + e);
      }
    }
  }
}
Program: 184359
Project: 184359
Buggy source:
public Data pullData(){
  if (!dataBuffer.isEmpty())   return dataBuffer.remove();
 else   return null;
}

Fixed version (ground truth):
public Data pullData(){
  if (!dataBuffer.isEmpty() && dataBuffer.peek() != null)   return dataBuffer.poll();
 else   return null;
}
Program: 184360
Project: 184360
Buggy source:
public void pushData(Data data){
  if (dataBuffer != null)   dataBuffer.offer(data);
}

Fixed version (ground truth):
public void pushData(Data data){
  if (dataBuffer != null && data != null)   dataBuffer.offer(data);
}
Program: 184361
Project: 184361
Buggy source:
public boolean offer(ResultFile resultFile){
  if (maxFiles > 0 && fileQueue.size() >= maxFiles) {
    poll();
  }
  return fileQueue.offer(resultFile);
}

Fixed version (ground truth):
public boolean offer(ResultFile resultFile){
  if (resultFile != null) {
    if (maxFiles > 0 && fileQueue.size() >= maxFiles) {
      poll();
    }
    return fileQueue.offer(resultFile);
  }
 else   return false;
}
Program: 184362
Project: 184362
Buggy source:
public boolean isEmpty(){
  return fileQueue.isEmpty();
}

Fixed version (ground truth):
public boolean isEmpty(){
  return fileQueue.isEmpty() && fileQueue.peek() != null;
}
Program: 184363
Project: 184363
Buggy source:
public AccelerometerSensor(Context context,int SensorType){
  super(context);
  String service=Context.SENSOR_SERVICE;
  sm=(SensorManager)context.getSystemService(service);
  accelerometer=sm.getDefaultSensor(sensorType);
  Log.d(TAG,"String_Node_Str" + accelerometer.getName());
}

Fixed version (ground truth):
public AccelerometerSensor(Context context,int sensorType){
  super(context);
  String service=Context.SENSOR_SERVICE;
  sm=(SensorManager)context.getSystemService(service);
  accelerometer=sm.getDefaultSensor(sensorType);
  Log.d(TAG,"String_Node_Str" + accelerometer.getName());
}
Program: 184364
Project: 184364
Buggy source:
@Override protected void onDraw(Canvas canvas){
  Drawable drawable=getDrawable();
  int drawableHeight=drawable.getIntrinsicHeight();
  int drawableWidth=drawable.getIntrinsicWidth();
  if (drawableWidth == 0 || drawableHeight == 0) {
    return;
  }
  final int available=getHeight() - getPaddingTop() - getPaddingBottom()- drawableHeight;
  if (mAnimationStartTime != NO_ANIMATION) {
    long time=AnimationUtils.currentAnimationTimeMillis();
    int deltaTime=(int)(time - mAnimationStartTime);
    mPosition=mAnimationStartPosition + ANIMATION_SPEED * (mSwitch ? deltaTime : -deltaTime) / 1000;
    if (mPosition < 0)     mPosition=0;
    if (mPosition > available)     mPosition=available;
    boolean done=(mPosition == (mSwitch ? available : 0));
    if (!done) {
      invalidate();
    }
 else {
      mAnimationStartTime=NO_ANIMATION;
    }
  }
 else {
    mPosition=mSwitch ? available : 0;
  }
  int offsetTop=getPaddingTop() + mPosition;
  int offsetLeft=(getWidth() - drawableWidth - getPaddingLeft()- getPaddingRight()) / 2;
  int saveCount=canvas.getSaveCount();
  canvas.save();
  canvas.translate(offsetLeft,offsetTop);
  drawable.draw(canvas);
  canvas.restoreToCount(saveCount);
}

Fixed version (ground truth):
@Override protected void onDraw(Canvas canvas){
  Drawable drawable=getDrawable();
  int drawableHeight=drawable.getIntrinsicHeight();
  int drawableWidth=drawable.getIntrinsicWidth();
  if (drawableWidth == 0 || drawableHeight == 0) {
    return;
  }
  final int available=getHeight() - getPaddingTop() - getPaddingBottom()- drawableHeight;
  if (mAnimationStartTime != NO_ANIMATION) {
    long time=AnimationUtils.currentAnimationTimeMillis();
    int deltaTime=(int)(time - mAnimationStartTime);
    mPosition=mAnimationStartPosition + ANIMATION_SPEED * (mSwitch ? deltaTime : -deltaTime) / 1000;
    if (mPosition < 0)     mPosition=0;
    if (mPosition > available)     mPosition=available;
    boolean done=(mPosition == (mSwitch ? available : 0));
    if (!done) {
      invalidate();
    }
 else {
      mAnimationStartTime=NO_ANIMATION;
    }
  }
 else   if (!isPressed()) {
    mPosition=mSwitch ? available : 0;
  }
  int offsetTop=getPaddingTop() + mPosition;
  int offsetLeft=(getWidth() - drawableWidth - getPaddingLeft()- getPaddingRight()) / 2;
  int saveCount=canvas.getSaveCount();
  canvas.save();
  canvas.translate(offsetLeft,offsetTop);
  drawable.draw(canvas);
  canvas.restoreToCount(saveCount);
}