Say I have a ClassWithManyDependencies. I want to write a Guice Provider for this class, in order to create a fresh instance of the class several times in my program (another class will depend on this Provider and use it at several points to create new instances).
One way to achieve this is by having the Provider depend on all the dependencies of ClassWithManyDependencies. This is quite ugly.
Is there a better way to achieve this?
Note - I certainly don't want the Provider to depend on the injector. Another option I considered is having ClassWithManyDependencies and ClassWithManyDependenciesProvider extend the same base class, but it's butt ugly.
I have a java primitive type at hand:
Class c = int.class; // or long.class, or boolean.class
I'd like to get a 'default value' for this class - specifically the value is assigned to fields of this type if they are not initialized. E.g., '0' for a number, 'false' for a boolean.
Is there a generic way to do this? I tried
c.newInstance()
But I'm getting an InstantiationException, and not a default instance.
What is the standard nowadays when one needs a thread safe collection (e.g. Set).
Do I synchronize it myself, or is there an inherently thread safe collection?
I know Java's generics are somewhat inferior to .Net's.
I have a generic class Foo<T>, and I really need to instantiate a T in Foo using a parameter-less constructor. How can one work around Java's limitation?
"Prefer to design UI that guides the user to provide correct input before submitting a form over presenting an error message when he submits it incorrectly"
Is there a canonical link that explains this (similar to KISS)?
A certain open source project is hosted at Gitorious. Suppose that at some future point X they decide to close source / delete their project from Gitorious.
Will there exist a public archive of the source code, in something like The Wayback Machine?
I have an eclipse's .classpath file that looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="test"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
<classpathentry kind="lib" path="/libraries/jee/servlet-api.jar"/>
<classpathentry kind="lib" path="/libraries/junit/junit-4.6.jar"/>
<classpathentry kind="lib" path="/libraries/log4j/log4j-1.2.15.jar"/>
</classpath>
I'd like to add a whole directory of jars to the classpath - I like eclipse (or more precisely, our ant-based build process that uses .classpath format) to know several jars that reside in a single directory, without specifying them directly. How can I do that?
I never remember how to do this properly - can you help me fix this query?
SELECT * from log where now() - EventTime < '1 day'
Note - this question seems identical but there's no solution there for mysql.
I'm using "visibility:hidden" to hide certain elements, but they still take up space on the page while hidden.
How can I make them totally disappear visually, as though they are not in the DOM at all (but without actually removing them from the DOM)?
I have the following html code:
<div class="outer ui-draggable" style="position: relative;">
<div class="inner">Foo bar</div>
</div>
With this CSS:
.outer
{
background-color: #F7F085;
margin: 5px;
height: 100px;
width: 150px;
text-align:center;
vertical-align:text-bottom;
}
.outer .inner
{
display:inline;
vertical-align:middle;
height: 100px;
width: 150px;
}
I would like the inner div to fill the outer div completely - the text block should be an entire 100X150 box.
The problem is that this code doesn't produce the desired effect. The outer div is indeed the correct size, but the inner div seems to only fill a small area at the top of the outer div.
I also tried using height:inherit and width:inherit instead of specifying a size.
When I run the following javascript in IE, I get "Error: Object doesn't support this property or method" on "data.every(...)".
It works in Chrome/Firefox.
ZipeFile file = new ZipFile(filename);
ZipEntry folder = this.file.getEntry("some/path/in/zip/");
if (folder == null || !folder.isDirectory())
throw new Exception();
// now, how do I enumerate the contents of the zipped folder?
I have the following code block code when the document is ready:
$(document).ready(function() {
createDivs(); // creates some divs with class 'foo';
// iterate
$(".foo").each(function(index) {
alert(index + " - " + $(this).text());
});
}
I find that the "iterate" part misses the divs I created in the createDivs() method entirely! Is there some timing issue I'm not aware of? Why doesn't jquery see the divs that were just created?