Al Hobbs

Greenhorn
+ Follow
since Aug 30, 2017
Al likes ...
Netbeans IDE
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
1
Given in last 30 days
1
Forums and Threads
Scavenger Hunt
(keep public parts private until JForum day)
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt
Moderation Tools

Recent posts by Al Hobbs

So, if i change those id be able to turn it into a stateless static utility class as it is now ignoring edge cases.  The problem is that for the edge cases that i need to handle, it needs to know parts of the previous syllable, which would require a cache for which i planned on using an instance field.  Would that ruin its chance of becoming a static class or is there another way to remember to safely remember the previous syllable and make it a static method?
2 hours ago
Oh, I will probably change it then.  I don't really know how certain things will affect performance.  Do you think that would be the case in most cases where I should not global variables because declaring multiple times won't really affect performance?
5 hours ago
Instead of clearing the stringbuilders should I just declare in them in the methods, even if it means declaring them hundreds of times potentially?
5 hours ago
Well,
There are technically 11,000 characters, but 2,300 characters cover 99.9% of the most used ones.  So for the map/array I would have a map that contains the hangul characters like,한, for the key and the transliteration as han.  I could also use the unicode decimal number to act as a key in a string array.  The shear number of syllables and setting up the map/array seems like it would be extremely tedious. 
The characters are made up letters sort of so you can create the transliteration without having to look anything up.  Right now I wrote the code for that.  For the most part it covers everything except maybe a few edge that I need to handle once I figure out how to determine them.

What I have now(calculation method) is this:

I made it go backwards through the string because I thought handling the edge cases might be easier. Once I figure out the grammar I can just add a helper method to sort it out.

I also wasn't sure about making the Stringbuilders global variables.  I made them global variables so they only have to be created one time instead of for every single character, and i think stringbuilder is threadsafe.
6 hours ago
Hi,

I am writing some code to get romanization of hangul.  I originally thought of just having a map or String array with the unicode decimal numbers pointing to the romanization because there aren't that many syllables, but I found some code on github getting the romanization by doing some simple math on the unicode decimal number.  Which method would be faster to use, by map/array or by calculation?

thanks!!
11 hours ago
Hi,

I made a poker game that's uncoupled from UI.  I want to make something like a RESTful API that will allow me to put a website and an app on top of it, so that you can play with other people that are on a computer or their phone.  What I have in mind is having the server have the game state, and send and receive updates to the state which affect the UI on the app or website.  I'm thinking of setting up rest controllers for the server and have the app and website get updates when the state changes.  Does this seem plausible or would that even be considered a RESTful API?

thanks!
1 week ago

Stephan van Hulst wrote:You can also do this in a single reduction, if you're willing to use more memory during the reduction:


So you're saying that those two functions would give a list of winners with the highest hand?  I'll have to look over how you created the collector because I have never seen that before.


I changed how I got maxHand.  It looks a lot simpler than using Collections.max() on the map.
Sorry, the loop performs other operations in which an updated list is needed, so it's not directly part of the filtering process.
I don't plan on using orElse() because ideally it wouldn't get to that point if there is nobody playing.
Thanks!!
Sorry if my post was unclear.
Originally I thought it was because of the getHandStrength number being returned, but it must be maxHand.



The stream I want to use is in a while loop, and the scope of maxHand is only in one loop, so I initialized it and declared in final when it was being made.
(I just added final int.)  It seems to have gotten rid of the problem.
Is that an appropriate solution?

Thanks for your replies!
Hi,

I am trying to filter a list based on a number in the object matching another number.  I have this code:


It's telling me that the variable needs to be effectively final.  How should I approach this problem?
Okay so I figured out the problem after looking at the log.  I needed to have the bean config method static.
In the log this message popped up:
17:20:43.273 [http-nio-8080-exec-3] WARN  org.springframework.context.annotation.ConfigurationClassEnhancer - @Bean method ServletContextConfiguration.propertySourcesPlaceholderConfigurer is non-static and returns an object assignable to Spring's BeanFactoryPostProcessor interface. This will result in a failure to process annotations such as @Autowired, @Resource and @PostConstruct within the method's declaring @Configuration class. Add the 'static' modifier to this method to avoid these container lifecycle issues; see @Bean Javadoc for complete details

Thanks if you read it.
Anyone who finds this in the future I guess make sure to make the config method static in this case!!
4 weeks ago
Hi,
I am trying to get a value from a property file using @Value("${propertyName}")
Before it wasn't able to get the value, so I added a PropertySourcesPlaceholderConfigurer to my ServletConfiguration.  Doing this is throwing an exception that the ObjectMapper is null.  If I just delete the PropertySourcesPlaceholderConfigurer bean configuration then it doesn't throw the exception anymore.  The objectMapper is configured in the RootContextConfiguration.

The exception is being thrown when the ObjectMapper is being set down there at the bottom of configureMessageConverters.


I had never had any problem with the objectmapper until adding that propertysourceconfig bean in there.
Any guidance would be greatly appreciated!!!
thanks!!
4 weeks ago
I had redesigned it so it did one page at a time, so it would stream and filter 50 objects at a time.  This got rid of all of my problems. I'm not really sure if it's because of the size or not, but it works without a problem now. Thank you.
1 month ago
Hi Everyone,

I'm getting this IOException and I'm not really sure what it means.  I think maybe the problem is the size of the list?  When I run the program with less entries then it works alright.  When I input higher numbers(500) to check I start getting problems. 
Basically the program is getting links from a search and then turning them into an object.  The objects are put in a list and they are filtered in a stream which calls to another website to check them.  I think when it's entering the filter part it starts messing up, but this is only with higher numbers?  Should I redesign it so it does smaller chunks at a time?





Exception in thread "main" org.jsoup.UncheckedIOException: java.io.IOException: missing CR
at org.jsoup.parser.CharacterReader.bufferUp(CharacterReader.java:60)
at org.jsoup.parser.CharacterReader.current(CharacterReader.java:85)
at org.jsoup.parser.TokeniserState$8.read(TokeniserState.java:100)
at org.jsoup.parser.Tokeniser.read(Tokeniser.java:45)
at org.jsoup.parser.TreeBuilder.runParser(TreeBuilder.java:51)
at org.jsoup.parser.TreeBuilder.parse(TreeBuilder.java:45)
at org.jsoup.parser.Parser.parseInput(Parser.java:39)
at org.jsoup.helper.DataUtil.parseInputStream(DataUtil.java:151)
at org.jsoup.helper.HttpConnection$Response.parse(HttpConnection.java:832)
at org.jsoup.helper.HttpConnection.get(HttpConnection.java:289)
at com.aquino.webParser.Utilities.Connect.connectToURL(Connect.java:31)
at com.aquino.webParser.Book.<init>(Book.java:43)
at com.aquino.webParser.Book.retrieveBookArray(Book.java:199)
at com.aquino.webParser.OCLC.OCLCChecker.getBooks(OCLCChecker.java:33)
at com.aquino.webParser.OCLC.OCLCChecker.getOCLCTitles(OCLCChecker.java:48)
at com.aquino.test.AddNewLineTesting.main(AddNewLineTesting.java:35)
Caused by: java.io.IOException: missing CR
at sun.net.www.http.ChunkedInputStream.processRaw(ChunkedInputStream.java:405)
at sun.net.www.http.ChunkedInputStream.readAheadBlocking(ChunkedInputStream.java:572)
at sun.net.www.http.ChunkedInputStream.readAhead(ChunkedInputStream.java:609)
at sun.net.www.http.ChunkedInputStream.read(ChunkedInputStream.java:696)
at java.io.FilterInputStream.read(FilterInputStream.java:133)
at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(HttpURLConnection.java:3393)
at java.util.zip.InflaterInputStream.fill(InflaterInputStream.java:238)
at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158)
at java.util.zip.GZIPInputStream.read(GZIPInputStream.java:117)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:246)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:286)
at java.io.BufferedInputStream.read(BufferedInputStream.java:345)
at org.jsoup.internal.ConstrainableInputStream.read(ConstrainableInputStream.java:64)
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:284)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:326)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)
at java.io.InputStreamReader.read(InputStreamReader.java:184)
at java.io.BufferedReader.fill(BufferedReader.java:161)
at java.io.BufferedReader.read1(BufferedReader.java:212)
at java.io.BufferedReader.read(BufferedReader.java:289)
at java.io.Reader.read(Reader.java:140)
at org.jsoup.parser.CharacterReader.bufferUp(CharacterReader.java:54)
... 15 more
2 months ago
I redid it using DocumentFilter.




I figure I can reuse the class if I need to do the same thing in the future.   Is it improper to use System.lineSeparator() instead of just "\n"?
Thanks for the help!    
2 months ago