Can someone please give me an example of using Attribute.isDefined() to check if a particular custom attribute has been applied to a given class?
I've checked msdn, but only see possiblities for attributes applied to assemblies, members etc. I'm also open to alternative methods for achieving the same thing!
Possible Duplicate:
How will I know when to create an interface?
Why do we need interfaces in Java?
Instead of interface can't we write the methods directly in the class itself?
Why do we need a separate interface?
Hi All,
I have a basic doubt. Internally how are events represented as methods or as (fields)objects. If event is a field then how one can still contain events in the interface definition.
Thanks
JeeZ
For instance:
private final Object o;
public void doSomething(){
final Object local = this.o;
//access methods of local;
}
This practice is followed in lots of java classes (such as ArrayBlockingQueue). What's the benefit of this?
Is there a manner in which to catch requests to a class which does not exist.
I'm looking for something exactly like __call() and __static(), but for classes as opposed to methods in a class.
I am not talking about autoloading. I need to be able to interrupt the request and reroute it.
Ideas?
I have a property
public ObservableCollection<string> Name
{
get
{
return _nameCache;
}
}
_nameCache is updated by multiple threads in other class methods. The updates are guarded by a lock. The question is: should I use the same lock around my return statement? Will not using a lock lead to a race condition?
I have a php page named import.php. while executing this file a lot of database operation is doing.So i need to show the progress to the user, by using a progres bar.How is it possible using any of these php ajax, javascript, jquery,css, flash... methods
Does anyone out there who's familiar with Scala know how I could use scala.collection.immutable.Set from Java? I can vaguely read the scaladoc, but am not sure how to call scala methods like "-" from java (I assume that I just need to include some scala .jar file in my classpath...?)
Hi,
I'm a Java developer starting with .Net development using VS.Net 2008. I would love to get the Eclipse style of navigating methods etc by pressing the Ctrl key, hover over a method then click it to got to that method's declaration. Does such a plugin exist for VS.Net 2008?
thanks
Consider you have the following class
public class OuterClass {
...
private static class InnerClass {
int foo;
int bar;
}
}
I think I've read somewhere (but not the official Java Tutorial) that if I would declare the static member classes attributes private, the compiler had to generate some sort of accessor methods so that the outer class can actually access the static member class's (which is effectively a package-private top level class) attributes.
Any ideas on that?
I'm creating a VB.NET application that includes two radio buttons inside of a groupbox. If the first radio button is selected, a certain tab on a tab form should be enabled. If the second radio button is selected, that tab should be disabled.
Is there a groupbox method that monitors both radio buttons and fires when the selection changes? Or do I need to set up individual methods for each radio button?
Hi All
I was wondering if there's a way to detect the response codes on a website using C#? Since C# .NET has HTTP-based methods, I'm assuming that it can be done?
Thank you
I have the following situation: I need to sort trees based by height, so I made the Tree's comparable using the height attribute. However, I was also told to overwrite the equals and hashCode methods to avoid unpredictable behaviour.
Still, sometimes I may want to compare the references of the roots or something along those lines using ==. Is that still possible or does the == comparison call the equals method?
I wondering is there any way to set restrictions on template class?
Specify that every type substituted in template must have specific ancestor (realize some interface).
template < class B > //and every B must be a child of abstract C
class A {
public:
B * obj;
int f() {
return B::x + this->obj->f();
}
};
Like = in haskell
func :: (Ord a, Show b) => a -> b -> c
Hi there, this is a quick question:
I have JPA entities where some properties are annotated with @Transient.
Shall I use these properties in equals/hashCode/toString methods?
My first thought is NO but.... I don't know why.
Tips?
Ideas?
Explanations?
Thanks in advance
I have the following class:
public abstract class MyClass<T extends Object> {
protected T createNewFromData(Reader reader){
GSON.fromJSON(reader,T.class); // T.class isn't allowed :(
}
}
How do I pass a Class<T instance into there? Is there some wierd and wacky work around?
Is there a way to get a Class<T reference other than from a pre-instantiated Object of type T? It won't let me do this either:
T t = new T();
Class<T> klass = t.class;
ANSWER BELOW
Thanks to the accepted answer, here is the solution:
Type type = new TypeToken<T>(){}.getType();
return gson.fromJson(reader, type);
I have writed this function:
function news_array()
{
$sql = "SELECT * FROM content WHERE home=1";
$query = mysql_query($sql);
$i = 0;
while($row = mysql_fetch_array($query)){
$row_array[$i] =
array(
TITLE => $row['title'],
ABSTRACTT => $row['abstract'],
BODY => $row['body'],
ID => $row['conID']
);
$i++;
}
return $row_array;
}
When using this function like this:
<?php
$row_array = news_array();
for($i = 0 ; $i < count($row_array) ; $i++){
echo $row_array[$i][TITLE];
}
?>
There no output in html. What is wrong in my function?
Thanks in advance
I am writing an abstract matrix class (and some concrete subclasses) for use on very differing hardwares/architectures, etc. and I want to write a row and column type that provides a transparent reference to the rows and columns of the matrix.
However, I want to tune for performance, so I'd like this class to be essentially a compiler construct. In other words, I'm willing to sacrifice some dev time to making the overhead of these classes as small as possible.
I assume all (small) methods would want to be virtual? Keep the structure small? Any other suggestions?
class UserClass{
#region Class properties which are binding from DB
.
.
.
#endregion
#region Constructor Methods
public UserClass(int _iUser_id)
{
// of course this is wrong but how can i quickly set properties
// which are coming from DB by extension method over context class?
this = DAO.context.GetById<UserClass>(_iUser_id);
}
#endregion
}
Hi,
i have these methods in module1/actions/actions.class.php:
public function executeMethod1(sfWebRequest $request){
$a = 10;
sfContext::getInstance()->set('a', $a);
return $this->redirect('module1/method2');
}
public function executeMethod2(sfWebRequest $request){
echo sfContext::getInstance()->get('a');
}
When i execute module1/method1 i get this error:
"The "a" object does not exist in the current context."
Any idea?
Javi
I'd like to write a simple ostream which wraps an argument ostream and changes the stream in some way before passing it on to the argument stream. The transformation is something simple like changing a letter or erasing a word
What would a simple class inheriting from ostream look like? What methods should I override?
I'm developing a plugin for Wordpress, and I need to store some information from a form into a table in the DB.
There are probably lots of pages explaining how to do this, but I can't find them.
What are the best methods for storing data in WP using WP function?
I'm currently including my AppDelegate.h and all of my category headers into every one of my source files using the MyApp_Prefix.pch prefix header, instead of manually #importing them only where they are used. The category methods and lots of compiler #define's in my app delegate are used in lots of places in my code.
Is there any down side to this? Is it just that compilation will take longer?