Class methods, (sqlite)
Hey,
I'm working on a sqlite database application and I need to declare class variables (or something similar) to use within a class method.
what i'm trying to do is compile and run some sql queries throughout my app. Now all the instance methods I call for class objects are fine because they are being called by a specific object of that class.
I need to call a method (which is actually a sql query) at any time even tho there are no objects presently in the database to pass the method to. Therefore, i've created a class method to do this so I can call this method anytime I want on the class itself.
Problem is, I don't know where/how to declare class variables to use in this query (such as the handler for the database itself, statement handler, etc...
Also I want these variables to be accessible by other classes so that way I can pass the data from the result set into an array or whatever.
Anyone know how I can do this?
yeah, when I was looking into this yesterday I came across a "Cocoa Design Guidelines" guide and they were talking a little about singletons....
I've never used them.....do you know of any examples where one is used so I can see how it's used in an actual app (maybe one of the sample apps from Dev portal??)
Thanks
Frank
Similar Messages
-
In webdynpro ,Passing field symbols as values to class methods
Hi
Please tell me the ways of accessing database in webdynpro abap(not directly). I am calling Class method for accessing database. As currently I am directly accessing database in my webdynpro application. I have created a class and method for the same.
In my method I want to use select statement which will return table with values to webdynpro application. So for select statement(Calling Method) I need to use my field symbol values as where in clause .
Could anyone please help with example code?
Thanks,
Ujjwaldata: in_line type ref to data.
CREATE DATA in_line LIKE LINE OF <dyn_tab>.
ASSIGN in_line->* TO <dyn_wa>.
You can create a data reference and assign it to a field symbol and change the values. direclty passing field symbols is not possible.
Abhi -
Need Help with command line arguments for a class method
Hey guys,
I'm fairly new to programming in java.
I want to a write a class method that adds up its command line arguments which are numbers. For example, if the input was .... 5 2 3....then the output would be 10.
I have been told to use the Convert to convert a string to a double. I'm ok for writing the class method but I have no idea how to use Convert and why I need it in the method.
Can anybody help please?Hey guys,
I'm fairly new to programming in java.
I want to a write a class method that adds up its
command line arguments which are numbers. For
example, if the input was .... 5 2 3....then the
output would be 10.Okay. So you would receive the numbers to add as the String[] argument to a main method. The steps are simple:
1) declare a variable for the count
2) for each String in the array:
2.1) extract the value as a double
2.2) add this to the count
3) output the resulting count
I have been told to use the Convert to convert a
string to a double.
I'm ok for writing the class
method but I have no idea how to use ConvertThere is no class Convert in the Java API.
and why
I need it in the method. Do you understand you need to somehow convert each String to a double (step 2.1)? Since Convert is unknown to me, maybe you should just take a look at class Double. It can help you do step 2.1, the rest should be trivial enough.
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Double.html
Give it a go and feel free to post back with a specific problem you are having, accurately described if you please :-) -
Whats the difference between a class method and a instance method.
I have a quiz pretty soon and one of the questions will be: "How does an instance method differ from a class method." I've tried looking this up but they gave me really complicated explanations. I know what a instance method is but not really sure what a class one is. Can someone post an example of a class method and try to explain what makes it so special?
Edited by: tetris on Jan 30, 2008 10:45 PMJust have a look:
http://forum.java.sun.com/thread.jspa?threadID=603042&messageID=3246191 -
How to find out which class/method is calling System.gc
Hi
I am seeing frequent FULL GC and not able to locate which particular class/method is calling the System.gc(). I have disabled it using -XX:DisableExplicitGC and performance issues have been resolved. Also, I noticed that it does not happen periodically, so it is not RMI GC. How to find out who exactly is doing this? Does any of of the profilers like Optimizeit/Jprobe help find out this.
ThanksHi
I am seeing frequent FULL GC This is because you are creating and destroying objects VERY frequently. Try to look at your design and see where you can reuse objects (i.e. object pooling) if possible, that is if this is adversely affecting performance.
and not able to locate
which particular class/method is calling the
System.gc(). Classes don't call GC. The VM handles that automagically.
I have disabled it using
-XX:DisableExplicitGC and performance issues have
been resolved. Also, I noticed that it does not
happen periodically, so it is not RMI GC. How to find
out who exactly is doing this? Does any of of the
profilers like Optimizeit/Jprobe help find out this.OptimizeIt will tell you everything you need to know. However, NetBeans offers a free profiler now! -
How to call inner class method in one java file from another java file?
hello guyz, i m tryin to access an inner class method defined in one class from another class... i m posting the code too wit error. plz help me out.
// test1.java
public class test1
public test1()
test t = new test();
public class test
test()
public int geti()
int i=10;
return i;
// test2.java
class test2
public static void main(String[] args)
test1 t1 = new test1();
System.out.println(t1.t.i);
i m getting error as
test2.java:7: cannot resolve symbol
symbol : variable t
location: class test1
System.out.println(t1.t.geti());
^There are various ways to define and use nested classes. Here is a common pattern. The inner class is private but implements an interface visible to the client. The enclosing class provides a factory method to create instances of the inner class.
interface I {
void method();
class Outer {
private String name;
public Outer(String name) {
this.name = name;
public I createInner() {
return new Inner();
private class Inner implements I {
public void method() {
System.out.format("Enclosing object's name is %s%n", name);
public class Demo {
public static void main(String[] args) {
Outer outer = new Outer("Otto");
I junior = outer.createInner();
junior.method();
} -
How to get a int value from another class method?
Hi,
how can I get a value of another class method variable value.
example,
class elist
int a;
ArrayList<Event> eventArray;
void addEvent(Event e);
Event getEvent(int index);
void removeEvent(int index);
void orderEventByTime();
interface Event
void Command();
class servo implements Event
String ip;
int time = 10;
void Command();
class servo_2 implements Event
String ip;
int time = 20;
void Command();
[\code]
I want to get the time value in elist variable a;
and want to compare each class time?.Hi,
1) this foum provides means to format/tag code, no need to manually add -tags
2) by default, classname start with a capital letter, method names with a lower case letter
3) where do you want to get the time value to Elist.a? During addEvent()?
4) what do you want to do with the time value of each event? Sum all values up to make a an overall sum?
5) where do you want to compare the time value(s)?
To put it in one sentence: please be more specific with your description and answer.
Bye. -
Calling the super class method from the subclass
Hi all,
I have a question about inheritence and redefinition of methods. Is it possible to call the superclass implementation of a method which is redefined in the subclass in another method of the subclass?There are possbilities like creation of an explicit super class instance or delegating the super class method implementation to another method which is also protected etc. What i mean is, is there a direct way of calling it?We have ,me, as the reference for the instance we have(which is the subclass instance in this case), is there also a way of pointing the superclass implementation(with super we can reference in the subclass redefinition, my question is if we have such a parameter in other methods of the subclass too)
Thanks in advance
SukruHi,
The super reference can only be used in redefined methods to call superclass implementation . So probably what you can do is use upcasting and access the required superclass implementation. I can think of only this way...;-)
Ex data lr_super type ref to cl_superclass
lr_super = lr_subclass.
lr_super->method().
~Piyush Patil -
A function module or class/method to look up repository objects?
Hi,
Does anyone know of a class/method or a function module that returns back objects of a namespace in the integration repository.
For example, I would like to be able to retrieve all the message interfaces of a particular namespace.
Thanks in advance,
DukeHi Duke,
I am not sure about the function module. But you can look up all the objects with their IDs using transaction sxi_cache.
Regards,
Ramesh P -
Can't navigate to a page when using a class method
I am working on windows phone 8.1 universal app where I have created a class method and placed it in the NavigationHelper_LoadState method of one of the pages in my app. My navigation is as follows, I click on a link on my Mainpage and that takes me
to the page in question, where I have placed the class method in LoadState.
The class method checks the authentication state of the user. If the user is not logged in, it is supposed to take him to a separate login page (SHDSignIn from the snippet below).
The problem I am running into is that when I hit that part of the code in my class method, it just steps through the redirect code but doesn't take me to the login page but rather takes me to the page that was clicked from mainpage.
From the troubleshooting I have done up to this point seems like an issue probably because I am calling the method from NavigationHelper_LoadState and the system doesn't like it?? Can someone please explain and also provide a workaround for this?
Here is my code for the class function:
public async void SHDAuthState(string errormessage, ProgressBar myprogressbar, TextBlock mytextblock, TextBlock myservernetworkerror)
//Get the values for the userID and password from the settings....
string shdLoggedInValue = (string)appRoamingSettings.Values["shdLoggedIn"];
//If not logged in, redirect to the SHD sign in page...
if (shdLoggedInValue != "Yes")
this.rootFrame.Navigate(typeof(SHDSignIn));
//Getting the cookie if it has expired..
else
//Get the cookie value...
string myCookieValue = (string)appRoamingSettings.Values["MyCookie"];
//Get the original cookie obtain time....
long CookieObtainedTimeValue = (long)appRoamingSettings.Values["CookieObtainedTime"];
//Convertig date/time back to DateTime object....
origCookieObtainedTime = DateTime.FromBinary(CookieObtainedTimeValue);
currentDateTime = DateTime.Now;
//Check to see if cookie has expired....
cookieTimeElasped = currentDateTime - origCookieObtainedTime;
cookieTimeElapsedMins = cookieTimeElasped.TotalMinutes;
// 2 days = 2880 mins but we give a margin of 1 minute
//Get a new cookie if it has expired and save to settings
if (cookieTimeElapsedMins >= 2879)
// Start showing the progress bar...
mycontrols.progressbarShow(myprogressbar, mytextblock);
//Get the values for the userID and password from the settings....
string UserIDValue = (string)appRoamingSettings.Values["UserID"];
string PasswordValue = (string)appRoamingSettings.Values["Password"];
//Update the requestData string before sending.....
requestData = "{" + string.Format(RegisterRequestData, UserIDValue, PasswordValue) + "}";
string registerResults = await SHDAPI(registerUrl, requestData, errormessage);
if (registerResults != null)
// Get the cookie and the time and save it to settings
var shdCookie = JsonConvert.DeserializeObject<SHDHelper.SHDObject>(registerResults).RegistrationCookie;
//Save cookie to the app settings
appRoamingSettings.Values["MyCookie"] = shdCookie;
// build the UI
// Stop showing the progress bar...
mycontrols.progressbarNoShow(myprogressbar, mytextblock);
else
// Stop showing the progress bar...
mycontrols.progressbarNoShow(myprogressbar, mytextblock);
//Show the error message...
myservernetworkerror.Visibility = Windows.UI.Xaml.Visibility.Visible;
Also, I have the rootFrame defined as follows in my class:
Frame rootFrame = Window.Current.Content as Frame;
I am calling the class method from the LoadState method as follows
SHD_helper.SHDAuthState(errorMessage, pgbar, pgText, ServerNetworkError);
thanks
mujnothat is correct. I wanted to keep the login page redirect inside my class method so that I could do the check every time someone came to pages that require authentication. I wanted it in the LoadState method so I can do a check there, redirect
them to login page or just get a cookie and then pass that cookie to page to build the UI for the page
I can do what you are suggesting and have actually tried it but then I have to track which page to take the user to after they log in...
I have multiple clicks in the appbar and pages from where the user can come to these authentication-bound pages..
Suggestions?
Also, what am I doing wrong in my class method that it doesn't navigate to the login page in the LoadState method?
Thanks
mujno -
Class method for XI data into R/3????
Hi Experts,
I have a very big problem..please help me!!!!
We need to create a program that will call data from XI interface and populate the internal table in R/3?
Can any1 of u give me the steps to go forward with it?
I read some documents and found that we need to use Class METHOD.. but I am new to OOPS and dont know anything in it.
Its about server proxies I guess!!!
I need to finish this in 1 day...
Please help.. answers will be rewarded with points...Hi, Thanks for the reply. I cannot use IDOC.
I have data in XI interface in form of XML data and i want to populate internal table in R/3 with this XML data(From XI).
If anybody can give me the steps to do the same, it will be very helpful.
my mail id is [email protected]
please try to send me the steps with an example... -
Is it possible to call a class method using pattern in ABAP editor.
Hi,
Is it possible to call a class method using pattern in ABAP editor.
Thank U for Ur time.
Cheers,
SamYes,
Click patterns.
Then choose Abap objects patterns.
Click on the Tick
It will give a new screen
Here Give the name of the class first.
Then the object (instance of the calss)
And finally the method ..
it will give you the pattern
Hope this helps. -
Hi pls go through the below code, can any one give me solution how to access the Derived class method in this Point.
Note: In the below code , only in runtime we will come to know which Derived class method is going to invoke(So in runtime we will get Derived class name in the form of String). So Iam trying to Use Class.forName("Clas name") to create the instance of the Derived class and then type casting to base class.
Why iam casting to base class is , since only in the run time we are geting the Derived class name.
Result : iam geting the compiletime error says that no valid method fond in Mybase though it contains the reference of derived.
abstract class MyBase
public void display(int i)
System.out.println(" Base class Method");
class MyDerived extends MyBase
public void display(String str)
System.out.println("Derived class Mthode");
class MyMain
public static void main(String arg[])
String DrivObj=arg[0];
MyBase baseObj=(MyBase) Class.forName("DrivObj").newInstance();
baseObj.display("SomeString"); }
}The problem is, can not have subclass reference bcoz
iam geting the subclass name only in the runtime and
one more thing is cant touch my base and subclass to
do changes as u said Your design is then definately very bad.
, is there any other way to do
it.Yes, you can use reflection to invoke the method.
Kaj -
Code to call friends class method
Hello,
Please can someone help me with friends class method call. in global classes
Thanks
Megh
Moderator message: please search for available information/documentation before asking.
Edited by: Thomas Zloch on Nov 2, 2010 5:29 PMWhat is your exact problem?
The class whose private and protected section you want to use, needs declaration of its friends. You do it in Friends tabstrip. All these classes are allowed then to access these "hiden" sections from outside of the class. Below example how it works with local classes. For global ones the principle stays the same
CLASS lcl_main DEFINITION DEFERRED.
CLASS lcl_other DEFINITION FRIENDS lcl_main. "only LCL_MAIN can use may hiden sections
PROTECTED SECTION.
METHODS prot_meth.
PRIVATE SECTION.
METHODS priv_meth.
ENDCLASS.
CLASS lcl_other IMPLEMENTATION.
METHOD prot_meth.
WRITE / 'This is protected method of class lcl_other'.
ENDMETHOD. "prot_meth
METHOD priv_meth.
WRITE / 'This is private method of class lcl_other'.
ENDMETHOD. "priv_meth
ENDCLASS.
CLASS lcl_main DEFINITION.
PUBLIC SECTION.
METHODS call_friends_methods.
PRIVATE SECTION.
DATA mr_my_friend TYPE REF TO lcl_other.
ENDCLASS.
CLASS lcl_main IMPLEMENTATION.
METHOD call_friends_methods.
CREATE OBJECT mr_my_friend.
mr_my_friend->prot_meth( ).
mr_my_friend->priv_meth( ).
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA gr_main TYPE REF TO lcl_main.
CREATE OBJECT gr_main.
gr_main->call_friends_methods( ).
Regards
Marcin -
Class-data versus data and methods versus class-methods in OO ABAP
Hi
I was going thorugh following OO ABAP code.
CLASS vessel DEFINITION.
PUBLIC SECTION.
METHODS: constructor,
drive IMPORTING speed_up TYPE i,
get_id RETURNING value(id) TYPE i.
CLASS-METHODS: start,
objects,
inheritance,
interfaces,
events.
PROTECTED SECTION.
DATA: speed TYPE i,
max_speed TYPE i VALUE 100.
PRIVATE SECTION.
CLASS-DATA object_count TYPE i.
DATA id TYPE i.
ENDCLASS.
Whats is difference between methods and class-methods ?
What is the difference between data and class-data ?Hi Rajesh,
There are two types of componenets in a class
1)Static components
2) Instance components
Instance components exist for every instance of the class, while static exist only once for any number of instances of the class.
Components of the class are methods, attributes, events etc.
static attributes are represented by CLASS-DATA and instance attributes are represented by DATA.
static methods hence are done by CLASS-METHODS and can access only static attributes.
Instance methods are done by METHODS and can access any attribute.
For eg: supposing that in a class, there is a static attribute. Suppose after one instance is created, we are setting this static attribute value as 10. Now we are creating another instance of the same class. Now when you try to display the value of this attribute, it will be 10.ie. it needs to be initialized once and can be shared between instances.
Just go through this document..You will get nice info from this.
http://esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt
http://esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
If you want to go deeper, like object persistence and all, just refer this document.
http://esnips.com/doc/92be4457-1b6e-4061-92e5-8e4b3a6e3239/Object-Oriented-ABAP.ppt
Regards,
SP.
Maybe you are looking for
-
Issue importing Word document with notes
Hello everyone, I have a Word document that has about 80 short sections to it. Each section has endnotes, and the note numbering restarts with 1 at the beginning of each section. I have tried to import this document into CS3, but each time the notes
-
Zipping files/Compressing files in BizTalk 2010
Hi all! I have a BizTalk solution that needs to pick up all files in a directory, zip them up, and send them to a customer. I'm using BizTalk 2010. I tried using a 3rd party adapter I found on CodeProject but it would not work reliably. Are there oth
-
Oracle.jdbc.driver.T4CPreparedStatement -Locked
We are seeing lock on oracle.jdbc.driver.T4CPreparedStatement and rest of the threads are waiting for the lock to release. Each thread uses a different preparedStatement or a single preparedstatement???? How to resolve the problem? "ExecuteThread: '4
-
When I take a picture it saves it upside down
help, it always saves it in my photo album upside down.
-
I am creating a calendar here in Australia for my Mother in Germany. Is it possible to have it posted to Germany by Apple?