The two classes are similar,who can help me to reduce the duplicate code

/./DoubleFilter Class
public class DoubleFilter {
    private Vector data = null;
    private String symbol = null;
    private Vector filterData = null;
    public DoubleFilter(Vector _data, String _symbol) {
        data = _data;
        symbol = _symbol;
        filterData = new Vector();
    public Vector filter(Double _value){
        if(_value==null){
            return null;
        if(symbol.equals(Symbol.LESS)){
            return less(_value);
        }else if(symbol.equals(Symbol.GREATER)){
            return greater(_value);
        }else if(symbol.equals(Symbol.EQUAL)){
            return equals(_value);
        }else if(symbol.equals(Symbol.NOT_EQUAL)){
            return notEquals(_value);
        }else if(symbol.equals(Symbol.NOT_LESS)){
            return notLess(_value);
        }else if(symbol.equals(Symbol.NOT_GREATER)){
            return notGreater(_value);
        }else{
            return null;
    private Vector less(Double _value) {
        for (int i = 0; i < data.size(); i++) {
            Double baseValue = (Double) data.get(i);
            if (baseValue.compareTo(_value) < 0) {
                filterData.add(data.get(i));
        return filterData;
    private Vector greater(Double _value) {
        for (int i = 0; i < data.size(); i++) {
            Double baseValue = (Double) data.get(i);
            if (baseValue.compareTo(_value) > 0) {
                filterData.add(data.get(i));
        return filterData;
    private Vector equals(Double _value) {
        for (int i = 0; i < data.size(); i++) {
            Double baseValue = (Double) data.get(i);
            if (baseValue.compareTo(_value) == 0) {
                filterData.add(data.get(i));
        return filterData;
    private Vector notLess(Double _value) {
        for (int i = 0; i < data.size(); i++) {
            Double baseValue = (Double) data.get(i);
            if (baseValue.compareTo(_value) <= 0) {
                filterData.add(data.get(i));
        return filterData;
    private Vector notGreater(Double _value) {
        for (int i = 0; i < data.size(); i++) {
            Double baseValue = (Double) data.get(i);
            if (baseValue.compareTo(_value) >= 0) {
                filterData.add(data.get(i));
        return filterData;
    private Vector notEquals(Double _value) {
        for (int i = 0; i < data.size(); i++) {
            Double baseValue = (Double) data.get(i);
            if (baseValue.compareTo(_value) > 0
                    || baseValue.compareTo(_value) < 0) {
                filterData.add(data.get(i));
        return filterData;
//IntegerFilter Class
public class IntegerFilter {
    private Vector data = null;
    private String symbol = null;
    private Vector filterData = null;
    public IntegerFilter(Vector _data, String _symbol) {
        data = _data;
        symbol = _symbol;
        filterData = new Vector();
    public Vector filter(Integer _value) {
        if (_value == null) {
            return null;
        if (symbol.equals(Symbol.LESS)) {
            return less(_value);
        } else if (symbol.equals(Symbol.GREATER)) {
            return greater(_value);
        } else if (symbol.equals(Symbol.EQUAL)) {
            return equals(_value);
        } else if (symbol.equals(Symbol.NOT_EQUAL)) {
            return notEquals(_value);
        } else if (symbol.equals(Symbol.NOT_LESS)) {
            return notLess(_value);
        } else if (symbol.equals(Symbol.NOT_GREATER)) {
            return notGreater(_value);
        } else {
            return null;
    private Vector less(Integer _value) {
        for (int i = 0; i < data.size(); i++) {
            Integer baseValue = (Integer) data.get(i);
            if (baseValue.compareTo(_value) < 0) {
                filterData.add(data.get(i));
        return filterData;
    private Vector greater(Integer _value) {
        for (int i = 0; i < data.size(); i++) {
            Integer baseValue = (Integer) data.get(i);
            if (baseValue.compareTo(_value) > 0) {
                filterData.add(data.get(i));
        return filterData;
    private Vector equals(Integer _value) {
        for (int i = 0; i < data.size(); i++) {
            Integer baseValue = (Integer) data.get(i);
            if (baseValue.compareTo(_value) == 0) {
                filterData.add(data.get(i));
        return filterData;
    private Vector notLess(Integer _value) {
        for (int i = 0; i < data.size(); i++) {
            Integer baseValue = (Integer) data.get(i);
            if (baseValue.compareTo(_value) <= 0) {
                filterData.add(data.get(i));
        return filterData;
    private Vector notGreater(Integer _value) {
        for (int i = 0; i < data.size(); i++) {
            Integer baseValue = (Integer) data.get(i);
            if (baseValue.compareTo(_value) >= 0) {
                filterData.add(data.get(i));
        return filterData;
    private Vector notEquals(Integer _value) {
        for (int i = 0; i < data.size(); i++) {
            Integer baseValue = (Integer) data.get(i);
            if (baseValue.compareTo(_value) > 0
                    || baseValue.compareTo(_value) < 0) {
                filterData.add(data.get(i));
        return filterData;
}

additionally I'd remove all but one of the for-loops and call a filter() method on a Filter object that chooses wether to select this item or not
public interface Filter {
  public boolean select(Object o);
public abstract class ComparableFilter {
  private Comparable base;
  public ComparableFilter(Comparable base) {
    this.base=base;
public class EqualComparableFilter {
  public EqualComparableFilter(Comparable base) {
    super(base);
  public boolean select(Object o) {
    return base.compareTo(o) == 0;
}

Similar Messages

  • Hi are there some who can help i am trying to update my programs in app store

    hi are there some who can help i am trying to update garageband ,iphoto and iMovie on my iMac, but it´s not my apple id  it will use to the update, so i dont now the email and the  password for the email used, and i cant change it to my apple id
    my problem started after i updated to maverick
    i hope there are someone who can help ???

    hi are there some who can help i am trying to update garageband ,iphoto and iMovie on my iMac, but it´s not my apple id  it will use to the update, so i dont now the email and the  password for the email used, and i cant change it to my apple id
    my problem started after i updated to maverick
    i hope there are someone who can help ???

  • Ratings and picks are not shown in the pictures in the filmstrip, although marked in the LR presets. Who can help?

    ratings and picks are not shown in the pictures in the filmstrip, although marked in the LR presets. Who can help?

    found the solution: the filmstrip was to small !!!

  • Dates in email all the same when older than 2 days. I saw similare questions but no solutions , who can help me ?

    All dates in my emails (on all my 4 apple computers) are on May 5 , when older than 2 days. Is there anyone who can help me out of this very annoying problem please?
    I saw simmilar questions from people in 2008  but no answers.
    Thanks in advance.

    solved

  • Is there anyone who can help me to contact the apple customer service? Because i want to know why they are diducted mt credit card more than the amount which is written on there apple store price? They are taken more!

    Why the apple store taken more amount more than the amount written on their prices? Is there any one who can help me to contact the apple customer services. Thanks!

    Some country's might not include tax in their prices, and if you changed or added your credit card details whilst making the purchase then a small temporary holding charge may also have been placed - in which case that should disappear within a few days (http://support.apple.com/kb/HT3702). Some apps also then allow you to make in-app purchases (though you can disable that via Settings > General > Restrictions)

  • We have a powermac PC G5, softwareversion 10.5.8 We are looking for a dongel for internet. Who can help us?

    We have a powermac PC G5, softwareversion 10.5.8. We need a dongel for internet. Who can help us?

    You will have to do the checking for what is available in The Netherlands, or else be very, very patient for somebody else in your area to come by who can tell you which store to go to.  I suggest looking for models similar to the one I indicated in the link.  Do make sure they are specified as being Mac compatible.  Mac drivers are usually built into a device so don't buy one one for a PC in the hope that you can find a Mac driver online.  Only in a few cases are Mac drivers featured as separate files.

  • Who can help me to submit this bug to the adobe indesign development team?

    I developed a indesing plug-in, and its function is to increase the two kinds of footnotes style,
    When the user selects this type of footnote style, and insert some footnote to the document
    The user then export the document to pdf。
    there is no  problem in indesign CS3 and indesign CS4.
    but in indesign CS5 and CS5.5,
    export pdf, there will be two kinds of format:
    Adobe PDF(Interaction)
    Adobe PDF(Print)
    If the user chooses to export a pdf(Interaction),there is no problem,
    but if user choose to export to pdf(print),
    All of the footnote is replaced by an ordinary Arabic numerals 1,2,3,4,......
    I think there is a bug in exported the pdf function in cs5 and cs5.5,
    so ,who can help me to submit this bug to the adobe indesign development team? thanks.
    Through the link below to download a trial version of this plugin for indesign cs5
    http://www.cppblog.com/Files/lyj2871/1380_CS5.rar

    who can help me?

  • I have a MacBook Pro, 15-inch, Mid 2009.  I would love to upgrade to a Solid State Drive.  What is the best possible upgrade I can buy.  I need the specs and even brand name.  Thank you to anyone who can help.

    I have a MacBook Pro, 15-inch, Mid 2009.  I would love to upgrade to a Solid State Drive.  What is the best possible upgrade I can buy.  I need the specs and even brand name.  Thank you to anyone who can help.

    A 15" mid-2009 MBP RAM specifications are: 204-pin PC3-8500 (1066 MHz) DDR3 SO-DIMM.
    As has been pointed out, OWC is an excellent source for Mac compatible RAM.  Crucial is another first rate source for Mac RAM.  RAM from either vendor will work just as well as any purchased from Apple with the bonus of being less expensive and having a lifetime guarantee.
    Ciao.

  • My Iphone 5s doesn't work. When i power on appear searching the sim card, but doesn't connect to the operator. Who can help me?

    Hy dear!
    My Iphone 5s doesn't work. When i power on appear searching the sim card, but doesn't connect to the operator. Who can help me? I reset the Iphone, but doesn't fix the probem.
    Thanks

    Hi dear!
    I'm very disappointed with Apple products! I was 15 days without my Iphone 5, because it stopped working and the had to be replaced by authorized apple. Then i bought an iphone 5s in two days it stopped working. Doesn't read the sim card. I call to Apple suport and discovery that the model A1533 is not warranted in Brazil and need to be replaced, because there is a hardware problem. In a moment i don't have anyone Phone. Why Apple does not send other equipment equal to authorized to exchange my Iphone, because in Brasil doesn't have the same model? I liked a lot this Apple phone, but i can't use, i have one brand new, but doen'st work. I don't have anybody in USA to exchange in one Apple store. Please help me!
    Thanks.

  • Made a form in which colleagues can add revisions(+1 row) and amendments (1a,b,c). Once filled in, and opened again the amendments disappear. Anyone who can help?

    Hi everyone,
    See picture below. Part of a large form I made for work. Got a little problem though. Adding a new row with the button 'add a new revision' is working perfect (also when saved and reopened). But when I add amendments with the + button on the right (a,b,c), these disappear when I save and reopen the file. Anyone who can help?
    Thanks!

    Ok, I've checked your form and there are some problem in your design.
    You should use better namings for your objects!
    It makes no sense to name to tables with repeatable instances the same.
    This can cause problems with repeated objects and also requires the usage of the slow resolveNode() method.
    I've changed a few object names and so I where able to shorten many of your current scripts.
    https://files.acrobat.com/a/preview/7b4655fb-feea-4d55-896e-83317605ee19

  • Entries on my I phone 4 in Calender are not pushed to I cloud so does not sync with my Mac and I pad. Reverse (from Mac to I pad and i phone works fine who can help me??

    Use Mac. I phone 4 and i Pad all latest software switched to i Cloud, works fine except entries in the Calender of the I Phone are not pushed to I Pad and Mac. reverse (from Mac to I phone and Ipad) it works ok. I pad entries in calender are pushed to Mac and IPhone Who can help me??

    On the iPhone open the Calendar app and on the top left conner tap the Calendar button and confirme that the calendars on your iPhone are under iCloud.
    If not that is the reason why they are not going.
    If  they are under iCloud try to toggle off and back on iCloud calendar options.

  • Error Message:"Cannot find or create the font 'WP-MathA'. Some characters may not display or print correctly."  Who can help me solve this problem?

    Some of the pdf files I work with (receive) come up with a comment: “Cannot find or create the font ‘WP-MathA’. Some characters may not display or print correctly.”  Who can help me solve this problem?
    Thank you in advance for  your time.
    Marlen

    Hello Anubha,
    I am having a similar problem on my machine.  I was using Word 2008 and I created a PDF inside Word.
    I am opening the file on the system itself and I am running Windows 8.1.  I am using Version 11 of Reader.
    When the PDF I created (my resume) attempts to open, it says:  cannot find or create the file Times, Bold.  Some characters may not display or print correctly. 
    However, the entire Reader keeps freezing and will not allow me to open or test print the document.  Also, it is not displaying any of the Bold Times New Roman Print.  Can you please help?  Thanks.

  • FCPX 10.1.1 freezes all the time, who can HELP?

    Hi,
    I am on a deadline with my project and FCPX won't move anymore. There must be a million reports at Apple now, because I forced a stop contiuously, but I don't expect any direct response that can help me. Perhaps the next update.
    I started a library, created events and projects. The latest project went slower and slower and came to a stand still. I discovered, that the project properties indicated 720p and 1280 x 720, both of them I never use. All my footage in this project is 1080p and 1920 x 1080. Could that be the reason of freezing? And if so, how can I get out of this corner? Does anybody know and is willing to help?
    Some details: I use iMac, late 2009, 16GB internal memory, 2,8GHz Intel Core i7, OSX 10.9.2 (13C64). Can't create a new event or project. Even tried to delete the affected event and project, tried to delete the original media in the event, but all I ever see is the colorful ball, turning like it is fun to be stuck while time ticks on.
    Luckily I still have a MacBookPro, which I didn't upgrade (still Lion), still on FCPX 10.0.9, so I can al least stumble on, but I am not amused.
    Who can help me?
    Paul
    BTW, I am a follower of this forum for a long time now, but could not sign in because of problems with my email addresses. Still unsolved, but I decided to create a brandnew email address, just to be able to finally participate in the forum discussions.

    You are probably bumping into the limitations imposed by your old-ish mac.
    16GB is good, but I am sure you'll be limited by your hard drive options...
    What kind of hard drive, and how is connected? How much free space does it have? These are likely to cause bottlenecks, especially dealing with HD material, like you are.
    If you are using the internal hard drive, or an external on USB2, I can see how your editing will likely crawl.
    Even the likely best option for your mac, FW800, is not fast by today's standards.

  • Is there any way to identify the two classes are compiled by same vm

    Is there any way to identify the two classes are compiled by same vm?
    Thank's a lot.

    I think this is the better forum than java compiler. The answer to the question you asked is no.
    But that question is not the best way to address your problem.
    If this were me, I'd use a tool like ASM (http://asm.objectweb.org/) to read in that file, and replace the getToday() method, with one like this
    long getToday() {
        return 20080101;
    }and replace the class file with this new one. (keep the old one, they might be using a class loader that verifies class signatures or something)
    (They said the code you are looking at could have been changed by you - so take the hint and change it back).
    If they've ripped you off, this will restore justice much more cheaply and effectively than involving the lawyers. If they then sue you for breaching the license agreement, that would probably force them to disclose their underhand tactics.
    OTOH, if you're lying to us about the purchase, and needing to pay for upgrades to fix the performance issue, and instead are trying to crack some trial software, then I hope they are using a custom class loader that checks the integrity of the classes.
    If you are being ripped off, why are you not telling us the name of the company? I am not sure who is being ripped off here.
    Bruce

  • Who can help me deal with the question?

    My JSP platform is JDK1.3+RESIN1.1.5,whern i write these code ,i found something wrong!
    <%@ page contentType="text/html;charset=gb2312"%>
    <%@ page info="database handler"%>
    <%@ page import="java.lang.*"%>
    <%@ page import="java.awt.*"%>
    <%@ page import="com.caucho.sql.*"%>
    <%@ page import="java.io.*"%>
    <%@ page import="java.util.*"%>
    <%@ page import="java.sql.*"%>
    <%@ page import="javax.servlet.*"%>
    <%@ page import="javax.servlet.http.*"%>
    <%! String username;%>
    <%! String password;%>
    <%! String sql;%>
    <%
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    String url="jdbc:odbc:jsptest";
    Connection conn=DriverManager.getConnection(url,"sa","hulachen");
    Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
    String username=request.getParameter("username");
    String password=request.getParameter("password");
    sql="select * from tbl_accounts where username='"+username+"' and password='"+password+"'";
    ResultSet rs=stmt.executeQuery(sql);
    while (rs.next())
    String name=rs.getString("username");
    out.print(name);
    if (name==null)
    out.print("error");
    else
    out.print("welcome");
    %>
    whether the name is null or not ,it will print error,i don't know why,who can help me?Thanks!

    I did the same as you said,but the same thing happened!
    the code is:
    while (rs.next())
    String name=rs.getString("username");
    out.print(name);
    if (name==null)
    out.print("True");
    else
    out.print("False");
    If the name is null,it printed False,but if the name is nothing,it didn't print True,but nothing!

Maybe you are looking for

  • How to delete Content Source in Sharepoint 2013 Search Service

    I want to delete Default Content Source in Search Service in SharePoint 2013 but delete button is disable?Please see the below image. Content Source Type=SharePoint Sites How to do it? If In Content Source type=Files than delete button enables but no

  • DVD Burn Error: too much motion menu content yet not much.

    hi Keep getting this when i try to burn my DVD, can anyone advise? +- The following warnings and errors were found during the validation of the current project:+ +- There seems to be too much motion menu content in your project. Correct this problem

  • Service entry sheet reversal

    Hi to All How to reverse a service entry sheet in MM module?

  • Resources to learn about console logs

    Howdy, As there is such a wealth of knowledge here i'm wondering if anyone can point me to some websites that really cover all the ins and outs of the Console app. I'd like to learn how to read crash logs, track down problems etc. Never really looked

  • Starting one process from another

    Hi, I want to wite a program which starts 2 java processes. One way is like , start.bat is a batch file , which contains two commands as , start.bat java start_program_1 java start_program_2 Use exec command to run batch file. I tried doing this , bu