Android Open Source - sloop Data Entry Impl






From Project

Back to project page sloop.

License

The source code is released under:

NON-LICENSE The Sloop data-browser source code is hereby released into the Public Domain. The original author, David Megginson, Megginson Technologies Ltd., and Acclar Open Ltd. provide no warranty:...

If you think the Android project sloop 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 com.megginson.sloop.model.impl;
//from   ww  w. j  a  v  a2s .co m
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;

import com.megginson.sloop.model.DataEntry;

/**
 * A single name=value pair in a data record.
 * 
 * This implements the {@link Parcelable} interface, so that it can be passed
 * around in an Android {@link Bundle}.
 * 
 * @author David Megginson
 * @see DataCollectionImpl
 * @see DataRecordImpl
 */
class DataEntryImpl implements DataEntry {

  private String mKey;
  private String mValue;
  private boolean mHasFilter = false;
  
  protected DataEntryImpl (String key, String value) {
    this(key, value, false);
  }

  protected DataEntryImpl(String key, String value, boolean hasFilter) {
    mKey = key;
    setValue(value);
    mHasFilter = hasFilter;
  }
  
  /* (non-Javadoc)
   * @see com.megginson.sloop.model.DataEntry#hasFilter()
   */
  @Override
  public boolean hasFilter () {
    return mHasFilter;
  }

  @Override
  public String getKey() {
    return mKey;
  }

  @Override
  public String getValue() {
    return mValue;
  }

  @Override
  public String setValue(String value) {
    String oldValue = mValue;
    mValue = value;
    return oldValue;
  }

  @Override
  public int describeContents() {
    return 0;
  }

  @Override
  public void writeToParcel(Parcel dest, int flags) {
    dest.writeString(mKey);
    dest.writeString(mValue);
    dest.writeValue(mHasFilter);
  }

  @Override
  public boolean equals(Object o) {
    if (o == this) {
      return true;
    } else if (o instanceof DataEntryImpl) {
      return getKey().equals(((DataEntryImpl) o).getKey())
          && getValue().equals(((DataEntryImpl) o).getValue());
    } else {
      return false;
    }
  }

  @Override
  public int hashCode() {
    return getKey().hashCode() + getValue().hashCode();
  }

  @Override
  public String toString() {
    return "{" + getKey() + "=" + getValue() + "}";
  }

  public final static Parcelable.Creator<DataEntryImpl> CREATOR = new Parcelable.Creator<DataEntryImpl>() {

    @Override
    public DataEntryImpl createFromParcel(Parcel source) {
      String key = source.readString();
      String value = source.readString();
      boolean hasFilter = (Boolean)source.readValue(Boolean.class.getClassLoader());
      return new DataEntryImpl(key, value, hasFilter);
    }

    @Override
    public DataEntryImpl[] newArray(int size) {
      return new DataEntryImpl[size];
    }
  };

}




Java Source Code List

com.megginson.sloop.activities.ActivitiesUtil.java
com.megginson.sloop.activities.AddressActionProvider.java
com.megginson.sloop.activities.BookmarkEditActivity.java
com.megginson.sloop.activities.BookmarkListActivity.java
com.megginson.sloop.activities.InfoBarFragment.java
com.megginson.sloop.activities.MainActivity.java
com.megginson.sloop.activities.MainDisplayFragment.java
com.megginson.sloop.activities.TextFilterFragment.java
com.megginson.sloop.activities.package-info.java
com.megginson.sloop.model.Bookmark.java
com.megginson.sloop.model.DataCollection.java
com.megginson.sloop.model.DataEntry.java
com.megginson.sloop.model.DataRecord.java
com.megginson.sloop.model.Util.java
com.megginson.sloop.model.ValueFilter.java
com.megginson.sloop.model.impl.ContainsStringFilter.java
com.megginson.sloop.model.impl.DataCollectionIO.java
com.megginson.sloop.model.impl.DataCollectionImpl.java
com.megginson.sloop.model.impl.DataEntryImpl.java
com.megginson.sloop.model.impl.DataRecordImpl.java
com.megginson.sloop.model.impl.EqualsStringFilter.java
com.megginson.sloop.model.impl.package-info.java
com.megginson.sloop.model.package-info.java
com.megginson.sloop.ui.BookmarkListAdapter.java
com.megginson.sloop.ui.DataCollectionLoader.java
com.megginson.sloop.ui.DataCollectionPagerAdapter.java
com.megginson.sloop.ui.DataCollectionResult.java
com.megginson.sloop.ui.DataRecordFragment.java
com.megginson.sloop.ui.DataRecordListAdapter.java
com.megginson.sloop.ui.package-info.java