/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package yafft.FFModel.ModelItems;

import java.sql.Timestamp;
import javafx.beans.property.*;

public class CookieValue {
    private final StringProperty domain;
    private final StringProperty path;
    private final StringProperty key;
    private final StringProperty value;
    private final ObjectProperty<Timestamp> expiry;
    private final ObjectProperty<Timestamp> creationTime;
    private Boolean isRoot = false; 
    
      public CookieValue(String domain, String path, String key, String value, Timestamp expiry, Timestamp creationTime) {
        this.path = new SimpleStringProperty(path);
        this.key = new SimpleStringProperty(key);
        this.value = new SimpleStringProperty(value);
        this.expiry = new SimpleObjectProperty<>(expiry);
        this.creationTime = new SimpleObjectProperty<>(creationTime);
        this.domain = new SimpleStringProperty(domain);
    }
      
      public CookieValue(String domain, Boolean isRoot) {
          this.domain = new SimpleStringProperty(domain);
          this.isRoot = isRoot;
          
          this.path = null;
          this.key = null;
          this.value = null;
          this.expiry =null;
          this.creationTime = null;
          
      }
    
    public void setRoot(Boolean b) {
        this.isRoot = b;
    }
    
    public Boolean isRoot() {
        return this.isRoot;
    }
        
      
    public StringProperty getDomain() {
        if(!this.isRoot) {
            return new SimpleStringProperty("  ");
        } else {
            return this.domain;
        }
    }
    
    public StringProperty getDomainValue() {
        return this.domain;
    }
      

    public StringProperty getPath() {
        return path;
    }

    public StringProperty getKey() {
        return key;
    }

    public StringProperty getValue() {
        return value;
    }

    public ObjectProperty<Timestamp> getExpiry() {
        return expiry;
    }

    public ObjectProperty<Timestamp> getCreationTime() {
        return creationTime;
    }

    @Override
    public String toString() {
        return "CookieValue{|"+this.isRoot  + "|" + this.getDomain().getValue() + " path=" + path.getValue() + ", key=" + key.getValue() + ", value=" + value.getValue() + '}';
    }
    
    
    
}

