background preloader

Java

Facebook Twitter

Log4j. Apache log4j is a Java-based logging utility.

log4j

It was originally written by Ceki Gülcü and is now a project of the Apache Software Foundation. log4j is one of several Java logging frameworks. Gülcü has since started the SLF4J and Logback[1] projects, with the intention of offering a successor to log4j. The log4j team has created a successor to log4j with version number 2.0, which is currently in beta release. log4j 2.0 was developed with a focus on the problems of log4j 1.2, 1.3, java.util.logging and logback, and addresses issues which appeared in those frameworks. In addition, log4j 2.0 offers a plugin architecture which makes it more extensible than its predecessor. log4j 2.0 is not backwards compatible with 1.x versions,[2] although an "adapter" is available.

Log level[edit] The following table defines the log levels and messages in log4j, in decreasing order of severity. ANN: BatchFB, a new Facebook Java SDK with automatic batching. I just released the first public version of BatchFB, a somewhat different approach to interacting with the Facebook API. The main purpose is to provide a convenient Java interface that automatically groups and batches requests into the minimal number of Facebook backend calls. Opensource, MIT license. The user guide has many more details: Here's the introduction, including a quick code sample: BatchFB is a Java library that provides a power-user's interface to Facebook's modern (Graph + Old REST) API. * Automatically groups queries and REST calls into multiquery and batch.run. * Provides a unified set of exceptions from both Graph and Old REST API calls. * Deeply integrates with Jackson to map Facebook results to your typesafe objects.

Before you read the UserGuide, here is a quick example: /** You write your own Jackson user mapping for the pieces you care about */ public class User { long uid; @JsonProperty("first_name") String firstName; String pic_square; Batchfb - Java API for Facebook with automatic batching. Note: BatchFB 2.0 supports FB's new Graph Batch API and removes all support for the Old REST API.

batchfb - Java API for Facebook with automatic batching

If you still require the Old REST API, use BatchFB v1.x. BatchFB is a Java library that provides a power-user's interface to Facebook's Graph API. Automatically groups requests into the minimum number of remote calls to Facebook: FQL queries are combined into a single multiquery. FQL and Graph requests are combined into a single Graph Batch API request. Provides a unified, coherent, and programmer-friendly set of exceptions from Graph and FQL calls. Additional bonus for Google App Engine users: Oversized batches are automatically split and executed in parallel, rather than serially. Before you read the UserGuide, here is a quick example: /** You write your own Jackson user mapping for the pieces you care about */public class User { long uid; @JsonProperty("first_name") String firstName; String pic_square; String timezone;}

RestFB - A Lightweight Java Facebook Graph API and Old REST API Client. Contents of Interface Design: Best Practices in Object-Oriented API Design in Java. Using Regular Expressions in Java. Java 4 (JDK 1.4) and later have comprehensive support for regular expressions through the standard java.util.regex package.

Using Regular Expressions in Java

Because Java lacked a regex package for so long, there are also many 3rd party regex packages available for Java. I will only discuss Sun's regex library that is now part of the JDK. Its quality is excellent, better than most of the 3rd party packages. Unless you need to support older versions of the JDK, the java.util.regex package is the way to go. Java 5 fixes some bugs and adds support for Unicode blocks. Quick Regex Methods of The String Class The Java String class has several methods that allow you to perform an operation using a regular expression on that string in a minimal amount of code. MyString.matches("regex") returns true or false depending whether the string can be matched entirely by the regular expression. Regular Expressions Reference - Basic Syntax. The regular expressions reference on this website functions both as a reference to all available regex syntax and as a comparison of the features supported by the regular expression flavors discussed in the tutorial.

Regular Expressions Reference - Basic Syntax

The reference tables pack an incredible amount of information. To get the most out of them, follow this legend to learn how to read them. The Set Interface (The Java™ Tutorials > Collections > Interfaces) A Set is a Collection that cannot contain duplicate elements.

The Set Interface (The Java™ Tutorials > Collections > Interfaces)

It models the mathematical set abstraction. The Set interface contains only methods inherited from Collection and adds the restriction that duplicate elements are prohibited. Set also adds a stronger contract on the behavior of the equals and hashCode operations, allowing Set instances to be compared meaningfully even if their implementation types differ. Two Set instances are equal if they contain the same elements. The Java platform contains three general-purpose Set implementations: HashSet, TreeSet, and LinkedHashSet. Here's a simple but useful Set idiom. Collection<Type> noDups = new HashSet<Type>(c); It works by creating a Set (which, by definition, cannot contain duplicates), initially containing all the elements in c. Or, if using JDK 8 or later, you could easily collect into a Set using aggregate operations: