Search Results

Search found 24043 results on 962 pages for 'private methods'.

Page 103/962 | < Previous Page | 99 100 101 102 103 104 105 106 107 108 109 110  | Next Page >

  • Android - what's the difference between the various methods to get a Context?

    - by Alnitak
    In various bits of Android code I've seen: public class MyActivity extends Activity { public void method() { mContext = this; // since Activity extends Context mContext = getApplicationContext(); mContext = getBaseContext(); } } However I can't find any decent explanation of which is preferable, and under what circumstances which should be used. Pointers to documentation on this, and guidance about what might break if the wrong one is chosen, would be much appreciated.

    Read the article

  • [C#] Three System.Drawing methods manifest slow drawing or flickery: Solutions? or Other Options?

    - by Luke Mcneice
    Hi all, I am doing a little graphing via the System.Drawing and im having a few problems. I'm holding data in a Queue and i'm drawing(graphing) out that data onto three picture boxes this method fills the picture box then scrolls the graph across. so not to draw on top of the previous drawings (and graduly looking messier) i found 2 solutions to draw the graph. Call plot.Clear(BACKGOUNDCOLOR) before the draw loop [block commented] although this causes a flicker to appear from the time it takes to do the actual drawing loop. call plot.DrawLine(channelPen[5], j, 140, j, 0); just before each drawline [commented] although this causes the drawing to start ok then slow down very quickly to a crawl as if a wait command had been placed before the draw command. Here is the Code for reference: /*plotx.Clear(BACKGOUNDCOLOR) ploty.Clear(BACKGOUNDCOLOR) plotz.Clear(BACKGOUNDCOLOR)*/ for (int j = 1; j < 599; j++) { if (j > RealTimeBuffer.Count - 1) break; QueueEntity past = RealTimeBuffer.ElementAt(j - 1); QueueEntity current = RealTimeBuffer.ElementAt(j); if (j == 1) { //plotx.DrawLine(channelPen[5], 0, 140, 0, 0); //ploty.DrawLine(channelPen[5], 0, 140, 0, 0); //plotz.DrawLine(channelPen[5], 0, 140, 0, 0); } //plotx.DrawLine(channelPen[5], j, 140, j, 0); plotx.DrawLine(channelPen[0], j - 1, (((past.accdata.X - 0x7FFF) / 256) + 64), j, (((current.accdata.X - 0x7FFF) / 256) + 64)); //ploty.DrawLine(channelPen[5], j, 140, j, 0); ploty.DrawLine(channelPen[1], j - 1, (((past.accdata.Y - 0x7FFF) / 256) + 64), j, (((current.accdata.Y - 0x7FFF) / 256) + 64)); //plotz.DrawLine(markerPen, j, 140, j, 0); plotz.DrawLine(channelPen[2], j - 1, (((past.accdata.Z - 0x7FFF) / 256) + 94), j, (((current.accdata.Z - 0x7FFF) / 256) + 94)); } Is there any tricks to avoid these overheads? If not would there be any other/better solutions?

    Read the article

  • Does Restlet support parsing URLs into calling methods with parameters?

    - by John C
    Take the following example. I have a resource public class HelloWorldResource extends ServerResource { @Get public String represent(String arg) { return "hello, world (from the cloud!)" + arg; } } That is mapped by router.attach("/hi/{message}", HelloWorldResource.class); Is it possible to configure the routing such that accessing /hi/somestuffhere will make restlet fill in the arg parameter in the represent method?

    Read the article

  • Dynamic domain methods missing from grails service when injected into java service in grails app.

    - by Gordon C
    I had the idea that I would write my GroovyDao as a grails service. Next I would write a MyJavaService in java and locate it in the java sources dir in my grails app. MyJavaService contains a instance reference to groovyDao for spring injection. I would wire up in resources.groovy the MyJavaService with a groovyDao = ref("GroovyDao"). Everything starts up fine. However if I make call to MyJavaService any Domain method like Domain.list() returns a Method not found error. Any help is appreciated.

    Read the article

  • Are there .NET Framework methods to parse an email (MIME)?

    - by Neil C. Obremski
    Is there a class or set of functions built into the .NET Framework (3.5+) to parse raw emails (MIME documents)? I am not looking for anything fancy or a separate library, it needs to be built-in. I'm going to be using this in some unit tests and need only grab the main headers of interest (To, From, Subject) along with the body (which in this case will always be text and therefore no MIME trees or boundaries). I've written several MIME parsers in the past and if there isn't anything readily available, I'll just put together something from regular expressions. It would be great to be able to do something like: MailMessage msg = MailMessage.Parse(text); Thoughts?

    Read the article

  • How to override inner class methods if the inner class is defined as a property of the top class

    - by Maddy
    I have a code snippet like this class A(object): class b: def print_hello(self): print "Hello world" b = property(b) And I want to override the inner class b (please dont worry about the lowercase name) behaviour. Say, I want to add a new method or I want to change an existing method, like: class C(A): class b(A.b): def print_hello(self): print "Inner Class: Hello world" b = property(b) Now if I create C's object as c = C(), and call c.b I get TypeError: 'property' object is not callable error. How would I get pass this and call print_hello of the extended inner class? Disclaimer: I dont want to change the code for A class.

    Read the article

  • Multi-Column Join in Hibernate/JPA Annotations

    - by bowsie
    I have two entities which I would like to join through multiple columns. These columns are shared by an @Embeddable object that is shared by both entities. In the example below, Foo can have only one Bar but Bar can have multiple Foos (where AnEmbeddableObject is a unique key for Bar). Here is an example: @Entity @Table(name = "foo") public class Foo { @Id @Column(name = "id") @GeneratedValue(generator = "seqGen") @SequenceGenerator(name = "seqGen", sequenceName = "FOO_ID_SEQ", allocationSize = 1) private Long id; @Embedded private AnEmbeddableObject anEmbeddableObject; @ManyToOne(targetEntity = Bar.class, fetch = FetchType.LAZY) @JoinColumns( { @JoinColumn(name = "column_1", referencedColumnName = "column_1"), @JoinColumn(name = "column_2", referencedColumnName = "column_2"), @JoinColumn(name = "column_3", referencedColumnName = "column_3"), @JoinColumn(name = "column_4", referencedColumnName = "column_4") }) private Bar bar; // ... rest of class } And the Bar class: @Entity @Table(name = "bar") public class Bar { @Id @Column(name = "id") @GeneratedValue(generator = "seqGen") @SequenceGenerator(name = "seqGen", sequenceName = "BAR_ID_SEQ", allocationSize = 1) private Long id; @Embedded private AnEmbeddableObject anEmbeddableObject; // ... rest of class } Finally the AnEmbeddedObject class: @Embeddable public class AnEmbeddedObject { @Column(name = "column_1") private Long column1; @Column(name = "column_2") private Long column2; @Column(name = "column_3") private Long column3; @Column(name = "column_4") private Long column4; // ... rest of class } Obviously the schema is poorly normalised, it is a restriction that AnEmbeddedObject's fields are repeated in each table. The problem I have is that I receive this error when I try to start up Hibernate: org.hibernate.AnnotationException: referencedColumnNames(column_1, column_2, column_3, column_4) of Foo.bar referencing Bar not mapped to a single property I have tried marking the JoinColumns are not insertable and updatable, but with no luck. Is there a way to express this with Hibernate/JPA annotations? Thank you.

    Read the article

  • Style question: Writing "this." before instance variable and methods: good or bad idea?

    - by Uri
    One of my nasty (?) programming habits in C++ and Java is to always precede calls or accesses to members with a this. For example: this.process(this.event). A few of my students commented on this, and I'm wondering if I am teaching bad habits. My rationale is: 1) Makes code more readable — Easier to distinguish fields from local variables. 2) Makes it easier to distinguish standard calls from static calls (especially in Java) 3) Makes me remember that this call (unless the target is final) could end up on a different target, for example in an overriding version in a subclass. Obviously, this has zero impact on the compiled program, it's just readability. So am I making it more or less readable? Related Question Note: I turned it into a CW since there really isn't a correct answer.

    Read the article

  • [C#] Two System.Drawing methods manifest slow drawing or flickery: Solutions? or Other Options?

    - by Luke Mcneice
    Hi all, I am doing a little graphing via the System.Drawing and im having a few problems. I'm holding data in a Queue and i'm drawing(graphing) out that data onto three picture boxes this method fills the picture box then scrolls the graph across. so not to draw on top of the previous drawings (and graduly looking messier) i found 2 solutions to draw the graph. Call plot.Clear(BACKGOUNDCOLOR) before the draw loop [block commented] although this causes a flicker to appear from the time it takes to do the actual drawing loop. call plot.DrawLine(channelPen[5], j, 140, j, 0); just before each drawline [commented] although this causes the drawing to start ok then slow down very quickly to a crawl as if a wait command had been placed before the draw command. Here is the Code for reference: /*plotx.Clear(BACKGOUNDCOLOR) ploty.Clear(BACKGOUNDCOLOR) plotz.Clear(BACKGOUNDCOLOR)*/ for (int j = 1; j < 599; j++) { if (j > RealTimeBuffer.Count - 1) break; QueueEntity past = RealTimeBuffer.ElementAt(j - 1); QueueEntity current = RealTimeBuffer.ElementAt(j); if (j == 1) { //plotx.DrawLine(channelPen[5], 0, 140, 0, 0); //ploty.DrawLine(channelPen[5], 0, 140, 0, 0); //plotz.DrawLine(channelPen[5], 0, 140, 0, 0); } //plotx.DrawLine(channelPen[5], j, 140, j, 0); plotx.DrawLine(channelPen[0], j - 1, (((past.accdata.X - 0x7FFF) / 256) + 64), j, (((current.accdata.X - 0x7FFF) / 256) + 64)); //ploty.DrawLine(channelPen[5], j, 140, j, 0); ploty.DrawLine(channelPen[1], j - 1, (((past.accdata.Y - 0x7FFF) / 256) + 64), j, (((current.accdata.Y - 0x7FFF) / 256) + 64)); //plotz.DrawLine(markerPen, j, 140, j, 0); plotz.DrawLine(channelPen[2], j - 1, (((past.accdata.Z - 0x7FFF) / 256) + 94), j, (((current.accdata.Z - 0x7FFF) / 256) + 94)); } Is there any tricks to avoid these overheads? If not would there be any other/better solutions?

    Read the article

  • NLP: any easy and good methods to find semantic similarity between words?

    - by sadawd
    Dear Everyone, I don't know whether stackoverflow covers NLP, so I am gonna give this a shot. I am interested to find the semantic relatedness of two words from a specific domain, i.e. "image quality" and "noise". I am doing some research to determine if reviews of a cameras are positive or negative for a particular attribute of the camera. (like image quality in each one of the reviews). However, not everybody uses the exact same wording "image quality" in the posts, so I am out to see if there is a way for me to build something like that: "image quality" which includes ("noise", "color", "sharpness", etc etc) so I can wrap all everything within one big umbrella. I am doing this for another language, so Wordnet is not necessarily helpful. And no, I do now work for Google or Microsoft so I do not have data from people's clicking behavior as input data either. However, I do have a lot of text, pos-tagged, segmented etc. Thanks

    Read the article

  • Inherit all methods of object (including "constructor"), but modify some of them.

    - by Kirzilla
    Hello, Let's imagine that we have object Animal $.Animal = function(options) { this.defaults = { name : null } this.options = $.extend(this.defaults, options); } $.Animal.prototype.saySomething = function() { alert("I'm animal!"); } Now I'd like to create Cat object. It is absolutely similar to $.Annimal, but method saySomething() will look like this one... $.Cat.prototype.saySomething = function() { alert("I'm cat!"); } How can I inherit from Animal to create new object Cat and redefine saySomething() method? Thank you.

    Read the article

  • C# DLL Deployed in COM+. Error while accessing the methods.

    - by Dakshinamurthy
    I have the C# Dll (ABService) deployed in COM + and my os Is windows 2008. I have given the strong name for this dll and its dependent dll’s When I access the method of this dll through localhost or if I add the reference to the client project the method are executed successfully. Simply if I access the dll from the same machine with the reference it is working. So I think there is no problem with the way I deployed in the COM +. I have the doubt whether I have the problem in OS and Visual Studio 2008 combination. I have built all the dll with the Visual Studio 2008 with Target cpu as x86 and targert framework as 2.0. I have given in below the codes I have tried with and the errors. I need to create the object for the dll in server machine(64 bit) and access its method from the client(32 bit) Code : Type svr = Type.GetTypeFromProgID("ABService.Service", strserver1url[2],false); ABService.Service service1= (ABService.Service)Activator.CreateInstance(svr); strresult = service1.ExecuteService(orequest.xml); Error :{"Retrieving the COM class factory for remote component with CLSID {77BF00E0-41AC-3967-9E72-A4927CC0B880} from machine 10.105.138.64 failed due to the following error: 80040154."} Code Type svr = Type.GetTypeFromProgID("ABService.Service", strserver1url[2],true); object Service1 = null; Service1 = (ABService.Service)Activator.CreateInstance(svr, true); strresult = Convert.ToString(ReflectionHelper.Invoke(Service1, "ExecuteService", new object[] { orequest.xml })); Service1 = null; Error: Retrieving the COM class factory for remote component with CLSID {77BF00E0-41AC-3967-9E72-A4927CC0B880} from machine ftpsite failed due to the following error: 80040154. With the below code instead of C#.Net dll if i have the vb dll in Com + the method is executed successfully. Code ords = new RDS.DataSpace(); ords.InternetTimeout = 600000; object M_Service = null; ABService.Service oabservice = null; M_Service = ords.CreateObject("ABService.Service",url); strresult = Convert.ToString(ReflectionHelper.Invoke(M_Service, "ExecuteService", new object[] { orequest.xml })); Error : {"Object doesn't support this property or method 'ExecuteService'"} Code object obj=Interaction.CreateObject("ABService.Service", "10.105.138.64"); strresult = Convert.ToString(ReflectionHelper.Invoke(obj, "ExecuteService", new object[] { orequest.xml })); Error: {"Cannot create ActiveX component."} Code object obj = Activator.GetObject(typeof(ABService.Service), @"http://10.105.138.64:80/ABANET"); strresult = Convert.ToString(ReflectionHelper.Invoke(obj, "ExecuteService", new object[] { orequest.xml })); Error: InnerException {"The remote server returned an error: (405) Method Not Allowed."} System.Exception {System.Net.WebException} Message "Exception has been thrown by the target of an invocation.”

    Read the article

  • Is arithmetic overflow/underflow generally checked in .Net framework methods?

    - by YWE
    For example, let's use the Add method of the ArrayList class. If I am using the default compiler settings in Visual Studio C# project in which arithmetic overflow is not checked, would ArrayList.Add() throw an OverflowException if I added too many items? Would surrounding the method call with checked or unchecked make any difference? BTW, I would write a test program to determine the answer to this question if I had Visual Studio available to me right now.

    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

  • C# performance methods of receiving data from a socket?

    - by Daniel
    Lets assume we have a simple internet socket, and its going to send 10 megabytes (because i want to ignore memory issues) of random data through. Is there any performance difference or a best practice method that one should use for receiving data? The final output data should be represented by a byte[]. Yes i know writing an arbitrary amount of data to memory is bad, and if I was downloading a large file i wouldn't be doing it like this. But for argument sake lets ignore that and assume its a smallish amount of data. I also realise that the bottleneck here is probably not the memory management but rather the socket receiving. I just want to know what would be the most efficient method of receiving data. A few dodgy ways can think of is: Have a List and a buffer, after the buffer is full, add it to the list and at the end list.ToArray() to get the byte[] Write the buffer to a memory stream, after its complete construct a byte[] of the stream.Length and read it all into it in order to get the byte[] output. Is there a more efficient/better way of doing this?

    Read the article

  • how do i write action methods for partial views?

    - by ZX12R
    I rendering a view partially like this. <%= render(:partial => "index" ,:controller=>"controller_name") %> so this will partially render controller_name/_index.html.erb here is my doubt. can i write an action method for this _index. something like this? class ControllerNameController < ApplicationController def _index end end thanks.

    Read the article

  • MySQL & PHP: auto connect to DB or to properly way to pass host/db to MySQL methods

    - by SODA
    Hi, does anyone know of a known method in PHP to auto connect to MySQL db/table in case an app is using multiple databases on multiple hosts? Question 1: are there scripts around that allow to auto connect to necessary host/DB based on query? Question 2: if above is not possible, is there a known approach to properly passing host/DB info to make sure app is properly connected before executing the query?

    Read the article

  • Python:How to override inner class methods if the inner class is defined as a property of the top cl

    - by Maddy
    I have a code snippet like this class A(object): class b: def print_hello(self): print "Hello world" b = property(b) And I want to override the inner class 'b'(please dont worry about the lowercase name) behaviour. Say, I want to add a new method or I want to change an existing method, like: class C(A): class b(A.b): def print_hello(self): print "Inner Class: Hello world" b = property(b) Now if I create C's object as c = C(), and call c.b I get TypeError: 'property' object is not callable error. How would I get pass this and call print_hello of the extended inner class? Disclaimer: I dont want to change the code for A class.

    Read the article

  • Can someone explain the declaration of these java generic methods?

    - by Tony Giaccone
    I'm reading "Generics in the Java Programming Language" by Gilad Bracha and I'm confused about a style of declaration. The following code is found on page 8: interface Collection<E> { public boolean containsAll(Collection<?> c); public boolean addAll(Collection<? extends E> c); } interface Collection<E> { public <T> boolean containsAll(Collection<T> c); public <T extends E> boolean addAll(Collection<T> c); // hey, type variables can have bounds too! } My point of confusion comes from the second declaration. It's not clear to me what the purpose the <T> declaration serves in the following line: public <T> boolean containsAll(Collection<T> c); The method already has a type (boolean) associated with it. Why would you use the <T> and what does it tell the complier? I think my question needs to be a bit more specific. Why would you write: public <T> boolean containsAll(Collection<T> c); vs public boolean containsAll(Collection<T> c); It's not clear to me, what the purpose of <T> is, in the first declaration of containsAll.

    Read the article

  • Methods for making R plots look like Excel plots?

    - by brianjd
    I've been poking around with R graphical parameters trying to make my plots look a little more professional (e.g., las=1, bty="n" usually help). But not quite there. Started playing with tikzDevice. A huge improvement! Amazing how much better things look when the font sizes and styles in the figure match those of the surrounding document. Still, not quite there. What I'm ultimately looking for are those professional gradient shading, rounded corners, and shadow effects found in MS Excel plots. I know they're probably considered chart junk, but I like them. They're just nice looking. Q: How can I get these effects into my R plots? Do people usually just export to Inkscape and doodle over there? It would be nice if there were a literate programming approach. Is there an R package that handles these effects outright?

    Read the article

< Previous Page | 99 100 101 102 103 104 105 106 107 108 109 110  | Next Page >