Search Results

Search found 456 results on 19 pages for 'getter'.

Page 12/19 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • How do you use Java 1.6 Annotation Processing to perform compile time weaving?

    - by Steve
    I have created an annotation, applied it to a DTO and written a Java 1.6 style annotationProcessor. I can see how to have the annotationProcessor write a new source file, which isn't what I want to do, I cannot see or find out how to have it modify the existing class (ideally just modify the byte code). The modification is actually fairly trivial, all I want the processor to do is to insert a new getter and setter where the name comes from the value of the annotation being processed. My annotation processor looks like this; @SupportedSourceVersion(SourceVersion.RELEASE_6) @SupportedAnnotationTypes({ "com.kn.salog.annotation.AggregateField" }) public class SalogDTOAnnotationProcessor extends AbstractProcessor { @Override public boolean process(final Set<? extends TypeElement> annotations, final RoundEnvironment roundEnv) { //do some stuff } }

    Read the article

  • Java: how to name boolean properties

    - by NoozNooz42
    I just had a little surprise in a Webapp, where I'm using EL in .jsp pages. I added a boolean property and scratched my head because I had named a boolean "isDynamic", so I could write this: <c:if test="${page.isDynamic}"> ... </c:if> Which I find easier to read than: <c:if test="${page.dynamic}"> ... </c:if> However the .jsp failed to compile, with the error: javax.el.PropertyNotFoundException: Property 'isDynamic' not found on type com... I turns out my IDE (and it took me some time to notice it), when generating the getter, had generated a method called: isDynamic() instead of: getIsDynamic() Once I manually replaced isDynamic() by getIsDynamic() everything was working fine. So I've got really two questions here: is it bad to start a boolean property's name with "is"? wether it is bad or not, didn't IntelliJ made a mistake here by auto-generating a method named isDynamic instead of getIsDynamic?

    Read the article

  • Is this an UITableView -beginUpdates documentation error?

    - by mystify
    I can't wrap my head around what they tried to say here in the docs for -beginUpdate: Call this method if you want subsequent insertions, deletion, and selection operations (for example, cellForRowAtIndexPath: and indexPathsForVisibleRows) to be animated simultaneously. Let's see... cellForRowAtIndexPath: and indexPathsForVisibleRows are both GETTER methods. They do not update anything and do not change anything. So why should I call -beginUpdates before calling these? And what's animated regarding these? Well, nothing, huh? Just want to make sure this is really an error in the docs and I didn't miss something.

    Read the article

  • Why are only some of my attributes shown in the response xml of jaxws?

    - by Andreas
    I created a jaxws webservice, but it returns only some of the attributes of my objects in the response xml. E.g. public class MyObject { private String attribute1; private String attribute2; //getter and setter } But the returned XML only contains <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <ns2:getVariantsResponse xmlns:ns2="mynamespace"> <myObject> <attribute1>stringcontent</attribute1> </myObject> ....

    Read the article

  • Using Property Builtin with GAE Datastore's Model

    - by ejel
    I want to make attributes of GAE Model properties. The reason is for cases like to turn the value into uppercase before storing it. For a plain Python class, I would do something like: Foo(db.Model): def get_attr(self): return self.something def set_attr(self, value): self.something = value.upper() if value != None else None attr = property(get_attr, set_attr) However, GAE Datastore have their own concept of Property class, I looked into the documentation and it seems that I could override get_value_for_datastore(model_instance) to achieve my goal. Nevertheless, I don't know what model_instance is and how to extract the corresponding field from it. Is overriding GAE Property classes the right way to provides getter/setter-like functionality? If so, how to do it? Added: One potential issue of overriding get_value_for_datastore that I think of is it might not get called before the object was put into datastore. Hence getting the attribute before storing the object would yield an incorrect value.

    Read the article

  • How to use Sleep in the application in iphone

    - by Pugal Devan
    Hi, I have used to loading a default image in my appication. So i have set to, Sleep(3); in my delegate.m method. But sometimes it will take more than 6 to 7 minutes. So i want to display the image 3 seconds only and then it goes to my appilcation based on my requirements. Which one is best way to do that? Sleep(3) or [NSThread sleepForTimeInterval:3.0] or something else; And i must display the image 3 seconds only. Please explain me. (Note: And I declared setter and getter methods only in my deleagte class.) Please explain me.

    Read the article

  • How to specify a different column for a @Inheritance JPA annotation

    - by Cue
    @Entity @Inheritance(strategy = InheritanceType.JOINED) public class Foo @Entity @Inheritance(strategy = InheritanceType.JOINED) public class BarFoo extends Foo mysql> desc foo; +---------------+-------------+ | Field | Type | +---------------+-------------+ | id | int | +---------------+-------------+ mysql> desc barfoo; +---------------+-------------+ | Field | Type | +---------------+-------------+ | id | int | | foo_id | int | | bar_id | int | +---------------+-------------+ mysql> desc bar; +---------------+-------------+ | Field | Type | +---------------+-------------+ | id | int | +---------------+-------------+ Is it possible to specify column barfo.foo_id as the joined column? Are you allowed to specify barfoo.id as BarFoo's @Id since you are overriding the getter/seeter of class Foo? I understand the schematics behind this relationship (or at least I think I do) and I'm ok with them. The reason I want an explicit id field for BarFoo is exactly because I want to avoid using a joined key (foo _id, bar _id) when querying for BarFoo(s) or when used in a "stronger" constraint. (as Ruben put it)

    Read the article

  • Is the a pattern for iterating over lists held by a class (dynamicly typed OO languages)

    - by Roman A. Taycher
    If I have a class that holds one or several lists is it better to allow other classes to fetch those lists(with a getter) or to implement a doXList/eachXList type method for that list that take a function and call that function on each element of the list contained by that object. I wrote a program that did a ton of this and I hated passing around all these lists sometimes with method in class a calling method in class B to return lists contained in class C, B contains a C or multiple C's (note question is about dynamically typed OO languages languages like ruby or smalltalk) ex. (that came up in my program) on a Person class containing scheduling preferences and a scheduler class needing to access them.

    Read the article

  • What is a good practice to access class attributes in class methods?

    - by Clem
    I always wonder about the best way to access a class attribute from a class method in Java. Could you quickly convince me about which one of the 3 solutions below (or a totally different one :P) is a good practice? public class Test { String a; public String getA(){ return this.a; } public setA(String a){ this.a = a; } // Using Getter public void display(){ // Solution 1 System.out.println(this.a); // Solution 2 System.out.println(getA()); // Solution 3 System.out.println(this.getA()); } // Using Setter public void myMethod(String b, String c){ // Solution 1 this.a = b + c; // Solution 2 setA(b + c); // Solution 3 this.setA(b + c); } }

    Read the article

  • Does it make a difference in performance if I use self.fooBar instead of fooBar?

    - by mystify
    Note: I know exactly what a property is. This question is about performance. Using self.fooBar for READ access seems a waste of time for me. Unnecessary Objective-C messaging is going on. The getters typically simply pass along the ivar, so as long as it's pretty sure there will be no reasonable getter method written, I think it's perfectly fine to bypass this heavy guy. Objective-C messaging is about 20 times slower than direct calls. So if there is some high-performance-high-frequency code with hundreds of properties in use, maybe it does help a lot to avoid unnessessary objective-c messaging? Or am I wasting my time thinking about this?

    Read the article

  • avoid duplication with auto increment key in Hibernate

    - by Lily
    I am trying to use Hibernate to auto increment the id, however, I try to avoid duplication. class Service { Long id; // auto increment String name; String owner; // setter and getter } What I want to achieve is, whenever name and owner are the same, it will be a duplicated entry. In this case, I don't want to add another entry into the Database anymore. How to revise the hbm.xml files to avoid this issue?

    Read the article

  • In a binary search Tree

    - by user1044800
    In a binary search tree that takes a simple object.....when creating the getter and setter methods for the left, right, and parent. do I a do a null pointer? as in this=this or do I create the object in each method? Code bellow... This is my code: public void setParent(Person parent) { parent = new Person( parent.getName(), parent.getWeight()); //or is the parent supposed to be a null pointer ???? This is the code it came from: public void setParent(Node parent) { this.parent = parent; } Their code takes a node from the node class...my set parent is taking a person object from my person class.....

    Read the article

  • How do I get the border-radius from an element using jQuery?

    - by S Pangborn
    I've got a div, with the following HTML and CSS. In an attempt to make my Javascript code more robust, I'm attempting to retrieve certain CSS attributes from the selected element. I know how to use the .css() getter to get elements, but how to get the border-radius using that method? jQuery's documentation is sparse. HTML: <div id="#somediv"></div> CSS: #somediv { -moz-border-radius: 5px; -webkit-border-radius: 5px; }

    Read the article

  • Giving proper credit to a projects contributors

    - by Greg B
    I've recently been working with an opensource library for a commercial product. The opensource code is distributed from the website of the company who sells the proprietary product as a zip file. The library is a (direct) port to C# of the original library which is in Java. As such, it uses methods instead of getter/setter properties. The code contains copyright notices to the supplier of the product. The C# port was originally provided to the company by a 3rd party individual. I have modified the source to be more C# like and added a couple of small features. I want to put my version of the code out there (Google code or where ever) so that C# users of the software can benefit from a more native feeling library. How can I and/or how should I amend the copyright notice to give proper credit to The comercial owner of the original source The guy who provided the original C# port Myself and anyone else who contributes to the project in the future The source is provided under the LGPL V2.1,

    Read the article

  • default value for a static property

    - by Blitzz
    I like c#, but why can I do : public static bool Initialized { private set; get; } or this : public static bool Initialized = false; but not a mix of both in one line ? I just need to set access level to my variable (private set), and I need it set at false on startup. I wouldn't like to make that boring private _Initialized variable, which would be returned by the getter of the public Initialized var. I like my code to be beautiful. (NB: my variable is static, it can't be initialized in the constructor). Thanks

    Read the article

  • How can I ignore properties of a component using Fluent Nhibernate's AutoPersistenceModel?

    - by Jason
    I am using Fluent NHibernate AutoMappings to map my entities, including a few component objects. One of the component objects includes a property like the following: public string Value { set _value = value; } This causes an NHibernate.PropertyNotFoundException: "Could not find a getter for property 'Value'..." I want to ignore this property. I tried creating an IAutoMappingOverride for the component class but I couldn't use AutoMapping<.IgnoreProperty(x = x.Value) for the same reason. "The property or indexer 'MyComponent.Value' cannot be used in this context because it lacks the get accessor" I've also looked at IComponentConvention but can't see anyway of altering the mappings with this convention. Any help would be appreciated... Thanks

    Read the article

  • Gwt-ext. Bean to record and record to bean.

    - by den bardadym
    I write a RIA application and my JPA beans must be decoded to push it in Store. My decisions are: Brute Force. If I have property 'aProp' in bean (and getter/setter for it) i create RecordDef, then Record, then Recrod.set('aProp', bean.getAProp()) and so on.. (it is terrible) I can write generator for creating a Factory of Records (it is my desision and i write it). For example: RecordFactory<User> factory = GWT.create(User.class); //User is entity I now that i need a reflection, BUT GWT have no implementation of reflection (some libraries emulates this, but they builds on generators) Exists the best way? Thanks, Den Bardadym.

    Read the article

  • How to use intent between tabs in java/Android?

    - by Praveen Chandrasekaran
    I would need to know how to handle the intent between tabs. For example, I have a tab activity with two tabs. First on content is a text view. another one is a map view. When i click that text view it redirects to the tab2. it can be easily achieved by setCurrentTab(1) or setCurrentTabByTag("tab2") methods. But i want to pass lat and long values to that Map Activity to drop pin. What is the better way to use intents or getter/setter in java? What do you prefer? if your answer is "Intents". How?

    Read the article

  • Is there a Java unit-test framework that auto-tests getters and setters?

    - by Michael Easter
    There is a well-known debate in Java (and other communities, I'm sure) whether or not trivial getter/setter methods should be tested. Usually, this is with respect to code coverage. Let's agree that this is an open debate, and not try to answer it here. There have been several blog posts on using Java reflection to auto-test such methods. Does any framework (e.g. jUnit) provide such a feature? e.g. An annotation that says "this test T should auto-test all the getters/setters on class C, because I assert that they are standard". It seems to me that it would add value, and if it were configurable, the 'debate' would be left as an option to the user.

    Read the article

  • What does :this means in Ruby on Rails?

    - by Marco
    Hi, I'm new to the Ruby and Ruby on Rails world. I've read some guides, but i've some trouble with the following syntax. I think that the usage of :condition syntax is used in Ruby to define a class attribute with some kind of accessor, like: class Sample attr_accessor :condition end that implicitly declares the getter and setter for the "condition" property. While i was looking at some Rails sample code, i found the following examples that i don't fully understand. For example: @post = Post.find(params[:id]) Why it's accessing the id attribute with this syntax, instead of: @post = Post.find(params[id]) Or, for example: @posts = Post.find(:all) Is :all a constant here? If not, what does this code really means? If yes, why the following is not used: @posts = Post.find(ALL) Thanks

    Read the article

  • what is serialization and how it works

    - by Rozer
    I know the serialization process but have't implemented it. In my application i have seen there are various classes that has been implemented serilizable interface. consider following class public class DBAccessRequest implements Serializable { private ActiveRequest request = null; private Connection connection = null; private static Log log = LogFactory.getLog(DBAccessRequest.class); public DBAccessRequest(ActiveRequest request,Connection connection) { this.request = request; this.connection = connection; } /** * @return Returns the DB Connection object. */ public Connection getConnection() { return connection; } /** * @return Returns the active request object for the db connection. */ public ActiveRequest getRequest() { return request; } } just setting request and connection in constructor and having getter setter for them. so what is the use of serilizable implementation over here...

    Read the article

  • Adapting non-iterable containers to be iterated via custom templatized iterator

    - by DAldridge
    I have some classes, which for various reasons out of scope of this discussion, I cannot modify (irrelevant implementation details omitted): class Foo { /* ... irrelevant public interface ... */ }; class Bar { public: Foo& get_foo(size_t index) { /* whatever */ } size_t size_foo() { /* whatever */ } }; (There are many similar 'Foo' and 'Bar' classes I'm dealing with, and it's all generated code from elsewhere and stuff I don't want to subclass, etc.) [Edit: clarification - although there are many similar 'Foo' and 'Bar' classes, it is guaranteed that each "outer" class will have the getter and size methods. Only the getter method name and return type will differ for each "outer", based on whatever it's "inner" contained type is. So, if I have Baz which contains Quux instances, there will be Quux& Baz::get_quux(size_t index), and size_t Baz::size_quux().] Given the design of the Bar class, you cannot easily use it in STL algorithms (e.g. for_each, find_if, etc.), and must do imperative loops rather than taking a functional approach (reasons why I prefer the latter is also out of scope for this discussion): Bar b; size_t numFoo = b.size_foo(); for (int fooIdx = 0; fooIdx < numFoo; ++fooIdx) { Foo& f = b.get_foo(fooIdx); /* ... do stuff with 'f' ... */ } So... I've never created a custom iterator, and after reading various questions/answers on S.O. about iterator_traits and the like, I came up with this (currently half-baked) "solution": First, the custom iterator mechanism (NOTE: all uses of 'function' and 'bind' are from std::tr1 in MSVC9): // Iterator mechanism... template <typename TOuter, typename TInner> class ContainerIterator : public std::iterator<std::input_iterator_tag, TInner> { public: typedef function<TInner& (size_t)> func_type; ContainerIterator(const ContainerIterator& other) : mFunc(other.mFunc), mIndex(other.mIndex) {} ContainerIterator& operator++() { ++mIndex; return *this; } bool operator==(const ContainerIterator& other) { return ((mFunc.target<TOuter>() == other.mFunc.target<TOuter>()) && (mIndex == other.mIndex)); } bool operator!=(const ContainerIterator& other) { return !(*this == other); } TInner& operator*() { return mFunc(mIndex); } private: template<typename TOuter, typename TInner> friend class ContainerProxy; ContainerIterator(func_type func, size_t index = 0) : mFunc(func), mIndex(index) {} function<TInner& (size_t)> mFunc; size_t mIndex; }; Next, the mechanism by which I get valid iterators representing begin and end of the inner container: // Proxy(?) to the outer class instance, providing a way to get begin() and end() // iterators to the inner contained instances... template <typename TOuter, typename TInner> class ContainerProxy { public: typedef function<TInner& (size_t)> access_func_type; typedef function<size_t ()> size_func_type; typedef ContainerIterator<TOuter, TInner> iter_type; ContainerProxy(access_func_type accessFunc, size_func_type sizeFunc) : mAccessFunc(accessFunc), mSizeFunc(sizeFunc) {} iter_type begin() const { size_t numItems = mSizeFunc(); if (0 == numItems) return end(); else return ContainerIterator<TOuter, TInner>(mAccessFunc, 0); } iter_type end() const { size_t numItems = mSizeFunc(); return ContainerIterator<TOuter, TInner>(mAccessFunc, numItems); } private: access_func_type mAccessFunc; size_func_type mSizeFunc; }; I can use these classes in the following manner: // Sample function object for taking action on an LMX inner class instance yielded // by iteration... template <typename TInner> class SomeTInnerFunctor { public: void operator()(const TInner& inner) { /* ... whatever ... */ } }; // Example of iterating over an outer class instance's inner container... Bar b; /* assume populated which contained items ... */ ContainerProxy<Bar, Foo> bProxy( bind(&Bar::get_foo, b, _1), bind(&Bar::size_foo, b)); for_each(bProxy.begin(), bProxy.end(), SomeTInnerFunctor<Foo>()); Empirically, this solution functions correctly (minus any copy/paste or typos I may have introduced when editing the above for brevity). So, finally, the actual question: I don't like requiring the use of bind() and _1 placeholders, etcetera by the caller. All they really care about is: outer type, inner type, outer type's method to fetch inner instances, outer type's method to fetch count inner instances. Is there any way to "hide" the bind in the body of the template classes somehow? I've been unable to find a way to separately supply template parameters for the types and inner methods separately... Thanks! David

    Read the article

  • the use of private keyword

    - by LAT
    Hi everyone I am new to programming. I am learning Java now, there is something I am not really sure, that the use of private. Why programmer set the variable as private then write , getter and setter to access it. Why not put everything in public since we use it anyway. public class BadOO { public int size; public int weight; ... } public class ExploitBadOO { public static void main (String [] args) { BadOO b = new BadOO(); b.size = -5; // Legal but bad!! } } I found some code like this, and i saw the comment legal but bad. I don't understand why, please explain me.

    Read the article

  • The member [class] has no supported translation to SQL

    - by Code Sherpa
    Hi, I am getting the following error: Error Message:The member 'Company.ProductCore.Core.Domain.Account.Email' has no supported translation to SQL. My method looks like this: public Account GetAccountByEmail(string email) { Account account; using (WorkbookDataContext dc = _conn.GetContext()) { account = ( from a in dc.Accounts join em in dc.Emails on a.AccountId equals em.AccountId where a.Email.EmailAddress == email select a).FirstOrDefault(); } return account; } My Account class has a getter / setter that exposes Email: public Email Email { get { return _email; } set { _email = value; } } And my Email is a LINQ object. I have a feeling that the problem is that I am using a LINQ object for me Email property? I am new to LINQ and am not really sure why this is happening. Help appreciated, thanks...

    Read the article

  • Why would I want to have a non-standard attribute?

    - by dontWatchMyProfile
    The documentation on Core Data entities says: You might implement a custom class, for example, to provide custom accessor or validation methods, to use non-standard attributes, to specify dependent keys, to calculate derived values, or to implement any other custom logic. I stumbled over the non-standard attributes claim. It's just a guess: If my attribute is anything other than NSString, NSNumber or NSDate I will want to have a non-standard Attribute with special setter and getter methods? So, for example, if I wanted to store an image, this would be a non-standard Attribute with type NSData and a special method, say -(void)setImageWithFileURL:(NSURL*)url which then pulls the image data from the file, puts in in an NSData and assigns it to core data? Or did I get that wrong?

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >