-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Compare 2 strings
PostPosted: Thu Mar 03, 2005 12:54 pm 
Newbie

Joined: Mon Feb 28, 2005 6:11 pm
Posts: 6
Hello,

I am using this code... Why does method isInsert always return false???
It returns false if type variable is equal to "insert" too...

thanx, miso

Code:
package org.hlavki.diplo.data;

import java.io.Serializable;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;


/** @author Hibernate CodeGenerator */
public class ProblemContent implements Serializable {

    /** identifier field */
    private long id;

    /** persistent field */
    private String type;

    /** persistent field */
    private String content;

    /** persistent field */
    private boolean hidden;

    /** persistent field */
    private int order;

    /** persistent field */
    private org.hlavki.diplo.data.Problem problem;

    /** full constructor */
    public ProblemContent(String type, String content, boolean hidden, int order, org.hlavki.diplo.data.Problem problem) {
        this.type = type;
        this.content = content;
        this.hidden = hidden;
        this.order = order;
        this.problem = problem;
    }

    /** default constructor */
    public ProblemContent() {
    }

    public long getId() {
        return this.id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getType() {
        return this.type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getContent() {
        return this.content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public boolean isHidden() {
        return this.hidden;
    }

    public void setHidden(boolean hidden) {
        this.hidden = hidden;
    }

    public int getOrder() {
        return this.order;
    }

    public void setOrder(int order) {
        this.order = order;
    }

    public org.hlavki.diplo.data.Problem getProblem() {
        return this.problem;
    }

    public void setProblem(org.hlavki.diplo.data.Problem problem) {
        this.problem = problem;
    }

    public String toString() {
        return new ToStringBuilder(this)
            .append("id", getId())
            .toString();
    }

    public boolean equals(Object other) {
        if ( (this == other ) ) return true;
        if ( !(other instanceof ProblemContent) ) return false;
        ProblemContent castOther = (ProblemContent) other;
        return new EqualsBuilder()
            .append(this.getId(), castOther.getId())
            .isEquals();
    }

    public int hashCode() {
        return new HashCodeBuilder()
            .append(getId())
            .toHashCode();
    }

   public boolean isInsert() {
      return (type == "insert");
   }

}


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 03, 2005 1:12 pm 
Newbie

Joined: Tue Aug 10, 2004 3:20 pm
Posts: 11
Try:
return type.equals("insert");

_________________
Sincerely,
James.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.