Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!
Working on a Java web project with servlets, and getting some really strange behavior. A bit of sample code works when run from a main() method, regardless of whether it's in a servlet class or a back-end class. When the same code is actually called in a servlet from the webpage, it fails.

What this code does is connect to a secure webservice using client/server certificates for authentication, sends a query, and returns the result. In the case where this fails, I'm pretty sure it's because the client certificate isn't being sent properly (though the error message is vague, and it's possibly something else) - javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure

Is there any reason why identical code could behave differently in these two contexts?

Adbot
ADBOT LOVES YOU

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!

Lazlo posted:

I'm trying to create an arrayList of an object. The object is composed of three strings, and some simple methods.

Constructor for my Calc object.
code:
public class Calc 
{

    private String Name;
    private String Quantity;
    private String Units;
...
}
If I create an arrayList of Calcs in main, the compiler will let me feed Calcs in, but all I get back when I use arrayList.get(index) are memory locations.

System.out.println("This is the Calc Object: " + al.get(arrayCount));

//Output is similar: This is the Calc Object: Calc@1fb8ee3


You need a toString() method in your Calc class, then when you print it out it should be:
System.out.println("This is the Calc Object: " + al.get(arrayCount).toString()); // Don't actually need the .toString() part - it's automatically called.

Something vaguely like this:

code:
public String toString() {
  String output = "Calc[Name: " + Name +
      ", Quantity: " + Quantity + ", "Units: " + Units + "]";
  return output;
}

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!
^^ I thought that what the question was referring to was something more like this:

public boolean substring(String sub) - Determines whether the given substring can be found in this string.
Or perhaps:
public int substring(String sub) - returns the starting index where the substring can be found in this string, or else -1;

Thus, this would return true or 8, depending on which function existed:
code:
"Check this out.".substring("is");
However, it definitely does not work that way.

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!
I have a problem, and absolutely no idea what the cause could be. Code is essentially like this:

code:
public void someMethod() {
...
  try {
    doThing1();
    doThing2();
    ...
  } catch (Throwable t) {
    log(t);
  }
...
}

public void doThing1() {
  log(...);
  doSomeStuff();
  ...
  log(<more stuff>);
}

etc.
I can see the code entering doThing1(), because of the log statement. However, at some point in doThing1(), something is happening to cause all the rest of the code to be skipped. All remaining code in doThing1(), and even all remaining code in someMethod() is simply not executed. I tried the catch(Throwable) to see if I was missing something, but there's nothing.

Is there any possible explanation for such behavior? I could try to give some more specific details, but I don't know if they'd really be helpful.

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!

Jethro posted:

Can you step through it in a debugger?

Not easily (this is a part of a big application that depends on third-party jar files and communication with multiple external servers to produce the error). I'll certainly try to set all this up locally and see if I can get it to work.

quote:

Alternatively, pepper in some more log statements to narrow down the problem.

I know exactly which line of my code that's the last one to be executed. Beyond that, it goes into a third-party jar to do some axis communication. That still leaves me questioning exactly how this can cause my problem. It's as if the entire callstack is being obliterated and the program is silently continuing on its merry way. Any kind of problem should either be caught (by catch(Throwable t)) or cause a program crash, right?

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!

Jethro posted:

Unless he did a fantastically bad job of explaining his problem, I think he was saying that the program was dieing, but even once he added in the try...catch no exceptions were being caught.

If this was actually his problem, then you have some excellent question deciphering skills.

You are correct. If there's an exception thrown in doThing1(), I'm not expecing doThing2() to be executed. I'm expecting the exception to be caught where it should be caught, and for execution of the main method to continue.

The problem is that even with catch(Throwable t), there's nothing being caught. The execution simply stops. Furthermore, anything in the main method AFTER the try/catch block is also not getting executed.

As I said, it makes no sense whatsoever, which is why I'm asking if anyone has ever seen anything like it, or has any ideas of what I can try.

(I haven't had a chance to seriously try the debugger yet, been working on on-site interop testing all week :puke:)

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!
It doesn't stop or exit, it just continues running (after skipping whatever code it skips) as if nothing ever happened.

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!

Publius_Maximus posted:

4. (10 pts) Write a static method named ex1() that returns a BinaryTree object representing the expression (2 + 4) * 8"

Once I have an example for how to do number 4, I think I can handle the rest of the code, but I'm just having issues getting things working from the start.

Anyway, the code I'm working with is here, the driver is at the bottom of the code. Can anyone give me some advice/help me out in any way?

http://pastebin.com/m2edfc556

Do you know what the binary tree for that expression should look like? If you know that, it should be trivial.

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!

UberJumper posted:

3. The system does some work with threads, i know nothing about java threads, anyways i looked at the credited example that was used as the basis for distribution of data between threads:

:words:

Personally i think this system is dumb, lets say you have 100 threads who call get(), and only two threads are currently calling put() (theres a lack of data or something). So when something puts() it will wake all the threads, and they will all race for the lock.

It's kind of bad, but I don't think (though I'm definitely no expert here) that this code will cause any problems. All the threads will wake up, but the synchronized nature of the method will prevent multiple threads from actually obtaining the lock. You might want to look into the SynchronousQueue class though (or any of the other java.util.concurrent structures), since it seems to do about the same thing the code you pasted is doing.

quote:

Does anyone have any good recommendations for links about threading for java? I found some but alot of them are about java.util. concurrent, which seems alot more intelligent for doing this stuff. Since it gives better control.

You may have already read this, but it's decent as an introduction: http://download.oracle.com/docs/cd/E17409_01/javase/tutorial/essential/concurrency/index.html

Searching for 'java concurrency' provides several other tutorials.(http://tutorials.jenkov.com/java-concurrency/index.html has some pretty good stuff near the end, at least)

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!

Two Percent posted:

I'm really sorry for barging into a subforum I never participated in just to ask for help. I've been trying to work around this for days and Google isn't helping. I'm a complete newbie to Java who barely got started and I'm having trouble with what I feel is a trivial issue but it has stumped.

Simply put, I want the String result of a Matcher search collapse the Unicode escape sequences, instead of presenting the whole String literally. For example, if I would simply use:

code:
String test = "@}~g0XQq}{?u{ah4ef'u xbzmrjym{4RtTuTp\023rSg\037u\030zIs\ntWuC}F:@zH B;g{srrf0|}ghtqw}{";
System.out.println(test);
It would properly replace the 4 escape sequences and show me the result I want:

code:
@}~g0XQq}{?u{ah4ef'u xbzmrjym{4RtTuTprSguzIs
tWuC}F:@zH B;g{srrf0|}ghtqw}{

Those aren't unicode escape characters, they're octal escape characters. You convert them by finding the base10 representation and looking in the ASCII table, basically.

This seems to do what you want, though it will require some modification to fit in with your stuff (since I couldn't really figure out what some of that code was doing).

code:
  public static void main(String[] args) {
    String test = "@}~g0XQq}{?u{ah4ef'u xbzmrjym{4RtTuTp\\023rSg\\037u\\030zIs\\ntWuC}F:@zH B;g{srrf0|}ghtqw}{";
    test = test.replace("\\\\", "\\").replace("\\n", "\n");
    test = clean(test);
    System.out.println(test);
  }

  private static String clean(String s) {
    Pattern p = Pattern.compile("\\\\(\\d{3})");
    Matcher m = p.matcher(s);
    StringBuffer sb = new StringBuffer();
    while (m.find()) {
      String test = m.group(1);
      m.appendReplacement(sb, Matcher.quoteReplacement("" + (char)Integer.parseInt(test, 8)));
    }
    m.appendTail(sb);
    return sb.toString();
  }
output:
code:
@}~g0XQq}{?u{ah4ef'u xbzmrjym{4RtTuTprSguzIs
tWuC}F:@zH B;g{srrf0|}ghtqw}{

Kilson fucked around with this message at 09:15 on Jul 21, 2010

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!

Two Percent posted:

Told you I'm a newbie...

To be honest, I had to look that up as well. It's not a terribly common construction.

quote:

Yeah, I was trying to mean exactly what you said, I wanted them parsed to ASCII.

And this worked perfectly. I just had to tweak it to accept more escape sequences like \t or \f and so on and it's working flawlessly. God bless you.

Funny that replace("\\\\", "\\") works but replaceAll("\\\\", "\\") doesn't. Gotta pay more attention to the docs.

I think you can do replaceAll("\\\\\\\\", "\\") and it works the same way (yeah, it's stupid - gently caress you Java for not having a non-escaped regex syntax). I can't be 100% sure here, because this Linux machine I'm using seems to handle these characters strangely and outputs only characters that look like empty boxes, and won't allow me to copy/paste them here. :sigh:

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!

Cukel posted:

I'm trying to have a Vector array with four Vectors containing four different types of objects that are all subclasses to the same superclass, so that I could refer to the Vectors with index numbers. This is how I'm trying to do it:
code:
Vector<SuperClass> vectors[] = new Vector[] { new Vector<SubClassOne>(),
                                              new Vector<SubClassTwo>(),
                                              new Vector<SubClassThree>(),
                                              new Vector<SubClassFour>()  };
However, this gives me a type safety warning. I've tried several different ways of expressing this and reading Java Generics tutorials and such, but it just keeps giving some kind of type mismatch error/warning and confusing me.

I'm very new to this whole Java thing - actually to programming in general - so I could be missing something obvious or trying to do this in a completely retarded way, I just don't know! Is this even possible, or is the type safety warning harmless?

edit: the exact type safety warning is "Type safety: The expression of type Vector[] needs unchecked conversion to conform to Vector<SuperClass>[]" :confused:

You can't create generic arrays in Java. The warning isn't something to be terribly worried about, as long as you're sure you're putting correctly subclassed vectors into the array.

More specifically, you probably should do something like:

code:
Vector<? extends SuperClass> vectors[] = new Vector[4];
vectors[0] = new Vector<SubClassOne>();
...
The way you've done it, on the RHS, you're creating a Vector[], and you could put anything in there. You could be putting { new Vector<Dick>(), new Vector<Butt>()... } on the RHS, and it wouldn't complain. But when you go to use it, you'd get some kind of runtime error.

However, if you do this:

code:
Vector<SuperClass>[] vectors = new Vector[4];
vectors[0] = new Vector<NotSubClass>();
vectors[1] = new Vector<SubClassOne>();
It gives you a type mismatch error on both lines 2 and 3. Using <? extends SuperClass> will allow line 3, but throws a type mismatch error on line 2.

Kilson fucked around with this message at 16:26 on Aug 26, 2010

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!

Cukel posted:

Why is it a generic array? Just because I'm using Vectors? Because this gives the exact same warning:

See my longer response above. A generic array would be something like

code:
new Vector<Blah>[];
Since you can't do that, but you have specified on the LHS that the array is of type Vector<SuperClass>[], you get the unchecked conversion warning.

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!

Kaltag posted:

I am only researching the feasibility of this idea.

I know that this is ridiculously low level stuff for Java and I'll probably get laughed out of here but has anyone here ever heard of using Java to bit-bang a SPI interface or interfaced with a USB to SPI adapter? Would it be possible to control single I/O pins in a serial port or other general I/O pin? Could Java supply an appropriate clock of ~48kHz?

From my research the best bet would be to use a C or assembly library wrapped in JNI to do the dirty stuff.

We did something like this recently, using RXTX (new version/info here). It uses JNI internally, but it's pretty easy for the programmer. We used it for both direct serial connections and serial/USB adapters, and it worked fine for both. We probably used an older version too, but I don't remember for sure.

I can't say it has exactly what you want, because it seems like you want something possibly even more low level.

Kilson fucked around with this message at 21:33 on Aug 30, 2010

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!
That error code seems to have something to do with Java not always being able to properly determine when a running process exits (or something along those lines) on Windows. It seems to be fairly common, but I've also seen claims that it doesn't happen anymore. What version of Java are you running?

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!

MariusMcG posted:

I'm building a project in Eclipse that uses some third-party libraries. I've placed those libraries in my GlassFish domain/lib directory so that they're getting auto-loaded when the server starts. Is there a way to configure my Eclipse project so that it will expect to use the libraries on the server instead of bundling the libraries inside of the WAR file?

In asking this question I should acknowledge that I have very little experience with GlassFish. I've mostly worked with WebLogic, where this can be accomplished by configuring the dependencies as WebLogic shared libraries.

Don't tell Eclipse to bundle them into the WAR. Or just do what you're doing, it doesn't matter. By default, Glassfish searches for jars in this order: main library (glassfish/lib), domain library (domain/lib), and then application library (j2ee-applications/modules/<app>/WEB-INF/lib (or something like this)).

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!

Paolomania posted:

As with other languages ...

C# has no fallthrough, and requires an explicit break, even for the default case. However, you can goto another case. :eng101:

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!

Shavnir posted:

Its this way in Ada as well, except the compiler just about comes out and kicks you in the balls if you use a goto. :eng101:

That's probably good. Everyone knows COME FROM is way better than silly goto anyway.

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!

Jewbert Jewstein posted:

I had finally finished this program that I was writing for work, but my boss wanted me to upload it under a different name than what I had called it originally (ie- adding an "_2"). Ever since doing that this red exclamation mark won't go away and any changes that I make to the code don't get made whenever I compile and test it. I'm working in Eclipse on a Vaadin project titled "AddressSearch_2".

Can any goons tell me how to fix this?

ninja edit: Black bars are covering my company's name. Ignore them.

I have the same problem occasionally in Netbeans. The way to fix it there is to delete the cache folder where it stores all the information about source files and restart. When it restarts, it will have to rebuild the cache, and the issue should go away. I would guess there's a similar procedure you can follow for Eclipse.

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!

UltraPenguinX posted:

Hi thread! I had a question regarding threading in Java. What I'm doing is rather simple: I have a method in which I am creating a network-listener object, which runs in its own thread, and stands ready and waits to receive an incoming packet, then does stuff with it, then goes back to being ready to receive. What I would like to be able to do is have the listener object let the method (or by extension the "main" thread, as right now I only have 2) know that it is waiting to, or very readily about to receive a connection. I read up on wait() and notify(), as I had a feeling that is what I should be using, but I'm afraid after much experimenting it was all for naught. Can someone point me in the right direction?

EDIT: Wow a Thread.sleep() would fix that problem right up. That's what I get for coding at 5:00am... However if I'm wrong here please do let me know.

You might try a BlockingQueue. Put packets in the queue and have the handler .take() them from it.

quote:

DOUBLE EDIT: I'm also having an issue with the DatagramPacket class. I can implement it fine and it works wonderfully, except when I put it into another thread, like so:
code:
if(!p.getAddress().equals(home))
{
  new Thread(new PacketHandler(p)).start();
}
The address detection works fine, but any time I call one of its methods inside the PacketHandler object (a class I wrote), it appears to hang. I'm not catching any errors either. Is this a common problem that I'm not aware of? Once again, thank you in advance!

I don't think you can just say new Thread(<some object>).start() and have it do what you want. You have to create some subclass of thread that handles the type of data you want. If PacketHandler already does extend Thread, then you'd just say new PacketHandler(p).start().

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!
Using basic string manipulation shouldn't be too much harder. substring, indexOf, etc.

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!

Rohaq posted:

I wrote a semi-retarded HTML tag stripper, it doesn't recognise <script> tags though:

http://pastebin.com/fTf60HyR

Instead of <char> == "<char>".toCharArray()[0], you can just do == '<char>'.

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!

Thermopyle posted:

I'm really new to the Java language, but it's my understanding that ArrayLists aren't thread-safe.

I think you can wrap an ArrayList with Collections.synchronizedList to make it thread-safe. Not sure what the performance characteristics are, or even the exact behavior.

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!
I'm trying to write an application that uses TCAP network transport. The problem is that TCAP seems to be inextricably linked to SS7, whereas we're supposed to be using IP. Are there any libraries that allow me to use TCAP over IP?

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!

FamDav posted:

I want to use a ThreadPoolExecutor to maintain processes sent to the server. However, I would like the logging output to show which thread in the pool performed which actions.

Log4j (and I assume other logging frameworks?) can tell you which thread in a pool is logging which output.

If you have a pool named 'foo', the output could look something like this:
code:
 2011-02-23 15:31:14,450 [foo-0] INFO blahblahblah
 2011-02-23 15:31:14,662 [foo-1] INFO feefeefeefee
                          ^^  ^
                   pool-name  thread-number

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!

Seafea posted:

So, I'm dealing with a String that could be in one of two formats. Either ABC or BC, where A/C are a positive integer, and B is the letter S.

I need a way to split the String into it's pieces. I've tried using String.trim().split("S"), but for the Array I get from that, .size() returns 2, even if the format is AX.

My best guess right now, is to use .split, because it at least gives me the correct pieces, and I count them manually with an int to know how many there are. Any ideas better than that?

BTW, the goal of this is to return an ArrayList containing the A instances of the String "BC".

So you want to return the ones that are <number>S<number> in a list, and not the ones that are S<number>? Or you want to return only the first number from the instances that have an S in the middle? (I'm a little confused about your change in lettering, from ABC/BC to AX to 'the A instances of the String "BC"')

Why not just just use .startsWith("S") to determine which case you're in, then you can do .substring(0, .firstInstance("S")) or whatever to get the first number (if that's what you're looking for??)?

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!
I'm trying to extract a bodypart from a MIME Multipart message. I get the correct bodypart and everything, but this code isn't working as I understand it should.

code:
MimeMultipart mmp = (MimeMultipart) req1.getContent();
for (int i = 0; i < mmp.getCount(); i++) {
  MimeBodyPart bp = (MimeBodyPart) mmp.getBodyPart(i);
  if (bp.isMimeType(PIDF_LO_MIME_TYPE)) {
    bp.setDataHandler(new DataHandler(bp, "text/plain"));
    String content = (String) bp.getContent();
    ...
  }
}
I'm getting:
java.lang.ClassCastException: javax.mail.internet.MimeBodyPart cannot be cast to java.lang.String

I don't understand why bp.getContent() would give me back a MimeBodyPart. Setting the DataHandler as text/plain is supposed to give me back a String. Also, I'm pretty sure this code used to work. Is there a proper way to do this?

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!
Also, don't use the default Stack, because it extends from Vector, and is retarded. (Unless you need a stack with random access, which means you really should be using some other structure anyway)

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!
Or in Netbeans, you add the res folder as a source folder in the project properties, then you don't have to have it under source, but it still gets copied into the jar properly, and you can run from within the IDE.

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!
I've used the RXTX library a bunch, but I'd say the same thing as Contra Duck. Just synchronize the method doing the writing, or acquire a lock, or put writes in a shared queue to be written serially, or something.

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!
Having a really stupid problem that I can't figure out. I'm hoping it's completely dumb and that I'm dumb.

I have a TreeSet, and I insert 10 objects into it. When I then print the contents, there are only 4 items in the set.

This is basically the class I'm using.

code:
public class PuntRule implements Comparable<PuntRule> {

	private List<Integer> trunkGroups;
	private String extensionCode;
	private String prefix;
	private int extensionLength;
	private int outputLength;

// getters + setters are defined

	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		final PuntRule other = (PuntRule) obj;
		if (this.trunkGroups != other.trunkGroups && (this.trunkGroups == null || !this.trunkGroups.equals(other.trunkGroups))) {
			return false;
		}
		if ((this.prefix == null) ? (other.prefix != null) : !this.prefix.equals(other.prefix)) {
			return false;
		}
		if (this.extensionLength != other.extensionLength) {
			return false;
		}
		if ((this.extensionCode == null) ? (other.extensionCode != null) : !this.extensionCode.equals(other.extensionCode)) {
			return false;
		}
		if (this.outputLength != other.outputLength) {
			return false;
		}
		return true;
	}

	public int hashCode() {
		int hash = 7;
		hash = 61 * hash + (this.trunkGroups != null ? this.trunkGroups.hashCode() : 0);
		hash = 61 * hash + (this.prefix != null ? this.prefix.hashCode() : 0);
		hash = 61 * hash + this.extensionLength;
		hash = 61 * hash + (this.extensionCode != null ? this.extensionCode.hashCode() : 0);
		hash = 61 * hash + this.outputLength;
		return hash;
	}

	@Override
	public int compareTo(PuntRule other) {
		int thisLen = this.extensionCode.length();
		int otherLen = other.extensionCode.length();
		if (thisLen > otherLen) {
			return -1;
		} else if (thisLen < otherLen) {
			return 1;
		} else {
			return 0;
		}
	}
}
The 10 instances I'm trying to add to the TreeSet look like this:

code:
PuntRule{prefix=3125551003, trunkGroups=[20, 21], extensionLength=4, extensionCode=2006, outputLength=10}

PuntRule{prefix=3124321000, trunkGroups=[], extensionLength=5, extensionCode=22001, outputLength=10}

PuntRule{prefix=, trunkGroups=[60], extensionLength=4, extensionCode=2008, outputLength=4}

PuntRule{prefix=555, trunkGroups=[], extensionLength=11, extensionCode=212, outputLength=10}

PuntRule{prefix=3124325000, trunkGroups=[], extensionLength=11, extensionCode=1, outputLength=10}

PuntRule{prefix=216702, trunkGroups=[], extensionLength=4, extensionCode=2000, outputLength=10}

PuntRule{prefix=3124325000, trunkGroups=[], extensionLength=5, extensionCode=5, outputLength=10}

PuntRule{prefix=312432, trunkGroups=[], extensionLength=4, extensionCode=1, outputLength=10}

PuntRule{prefix=312555, trunkGroups=[], extensionLength=4, extensionCode=2, outputLength=10}

PuntRule{prefix=31243, trunkGroups=[], extensionLength=5, extensionCode=7, outputLength=10}
As you can see, they are all different, so they shouldn't be eliminated by set uniqueness constraints.

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!

Lysidas posted:

You should read up on the Comparable interface. Your defined natural ordering is not consistent with equals.

Here's a hint: You're getting four objects back. You have four distinct values for extensionCode.length() as referenced in compareTo.

*sigh* I read that earlier, but I kind of stopped after the part where it said:

Comparable posted:

It is strongly recommended (though not required) that natural orderings be consistent with equals.

I thought it was just recommended for some sort of ivory-tower reason, not because the difference would have real effects.

Thanks for pointing out my failure to RTFM.

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!

Aleksei Vasiliev posted:

why are you using ternaries inside if statements

Those were methods generated by the IDE. :effort:

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!
I find XOM 1000 times easier than JDOM.

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!

GodIsInTheTrees posted:

*Edit - I actually think it's Hibernate causing the initial problem, but all Googling turns up is that I need to update j2ee.jar, which is fine and all, but I can't seem to get an updated version anywhere without grabbing the version WAS provides, which is NOT current enough. gently caress you, company who likes to use frameworks from 2004 and app servers not much more recent.

Can't you just download a new Tomcat/Glassfish/Jboss/??? and get the j2ee.jar from that? There's a WAS v8 you can download a trial for - it probably contains some sort of j2ee jar as well. I don't know if any of these things will work, but it's worth a shot I guess.

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!

Newf posted:

I'm getting an 'incompatible types' error on the last return statement, even though qSort seems to me to consistently return ArrayList<Integer> objects.

Any suggestions on how I'm misreading this?

addAll() doesn't return what you think it returns.

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!
The only time I've run into permgen space problems is when using a lot of Spring/CGLib stuff in a web container. Redeploy the application(s) several times, and the JVM starts puking, because it has some problems cleaning up after proxy classes or something.

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!
If you really want to work with xml, I recommend using a library like XOM (my favorite) or JDOM (the most well-known).

It will make your life a billion times easier.

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!

DholmbladRU posted:

code:
   homeObject = new homeObj();
   homeObj.setLocation(node.getChildText("location"));
Why do I get an error message saying 'cannot make a static reference t non-static method' on the last line. None of the methods being called are static, and I believe I have properly created the homeObj reference in this method.

Your class is called 'homeObj', and your last line is 'homeObj.<method>', which looks like a static call. The last line should say 'homeObject.setLocation...' instead.

Also, class names should start with an upper-case letter in Java. It helps avoid things like this.

Adbot
ADBOT LOVES YOU

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!
When you use "<@ page import", you're not importing a file, you're importing a java class. If you open the .java file, it will say "package x.y.z" at the top somewhere. Your import should look like 'import="x.y.z.<classname>"'.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply