Assigning a value to a class member

I need to use reflection, and I cant set the value of an attribute of the class of type string;
Class Song{
string Author;
Class Test{
Song song = new Song();
String myAuthor= "Kim"
song.getClass().getDeclaredField().getName("Author").set?????(song, myAuthor);
Edited by: andromaque on Aug 13, 2008 6:10 AM

I should create getters/setters in the Song class. Example:
public class Song {
    String Author;
    public String getAuthor() {
        return Author;
    public void setAuthor(final String author) {
        Author = author;
    public static void main(final String[] args) {
        final Object o = new Song();
        final String author = "Kim";
        try {
            o.getClass().getMethod("setAuthor", String.class).invoke(o, author);
        } catch (final Exception e) {
            e.printStackTrace();
        // try if it succeed
        System.out.println("Author: " + ((Song) o).getAuthor());
}Output:
Author: Kim

Similar Messages

  • Error when assigning a value to a class

    Hi,
    Here's what I have:
    package com.myprograms.tools1;
    public class A
    public long orderId;
    public int nameId;
    public int carId;
    public int anId;
    package com.myprograms.tools1;
    public class B
    public A classOfA;
    //MAIN Program
    import com.myprograms.tools1;
    public class getClass
    B b= new B();
    b.classOfA.orderId = 10029292;
    I get a Null Pointer Exception when I assign a value to the var.
    Can anybody help point out the problem?
    Thanks!

    What exactly is the error message... i.e. line numbers and class names...
    Example: Full thread dump Java HotSpot(TM) Client VM (1.5.0-beta2-b51 mixed mode, sharing
    "SIGINT handler" daemon prio=10 tid=0x03264410 nid=0xea0 waiting for monitor ent
    ry [0x080bf000..0x080bfa68]
            at java.lang.Shutdown.exit(Unknown Source)
            - waiting to lock <0x2b31a868> (a java.lang.Class)
            at java.lang.Terminator$1.handle(Unknown Source)
            at sun.misc.Signal$1.run(Unknown Source)
            at java.lang.Thread.run(Unknown Source)Okay, that was too funny... LOL...
    This example error is courtesy of me being a complete... Well, let's just say, that was dumb...
    It has almost been an hour since I launched off that little app...
    You know you did something wrong when you can actually hear the HardDrive and Fan slow down...
    Anyway... LOL... what are the errors, and what is the rest of the code ? or is it fixed now...
    - MaxxDmg...
    - ' He who never sleeps... '

  • How to assign a value to a member with computed name ?

    Is there a way to assign a value to a member whose name is built dynamically in a calculation script ?For instance, my calculation script needs to do this :In the ACCOUNT dimension, the values of some (source) accounts must be added to their associated (destination) account and cleared from the source account.I can't use shared members.Each source account has a DESTINATION attribute, whose value is the associated destination account nameIs there a way to add the source value to the destination account? or some kind of dynamic solution without attribute ?Any help or suggestion greatly appreciated. ThanksPhilippe

    I forgot to mention that the assignation is conditional (if the value to assign is < 0).I tried this part of script with Essbase 6.5.1 (server and client):VAR var_dynamic_name;VAR var_value; ...FIX (...) ... var_dynamic_name = @MEMBER (@SUBSTRING( @ATTRIBUTESVAL( bilan ), 3 )); var_value = some formula; ... /*#### 2 Errors on next line : "This function must be a macro" and then"A variable can be only be used in a calcmember block or the rigth side of an assignement" ####*/ FIX (@MEMBER(var_dynamic_name)) cyg_bilan( IF ( var_value < 0 ) cyg_bilan = var_value; ENDIF );...ENDFIX ...

  • Assign a value to class variable

    I want to define a class variable in class. And I want all subclasses of that class ot have a different value for that class variable. How can I do that?
    public class BaseClass {
      public static String tableName = "";
    }Now if I have a ClassA and I want to assign a value like this :
    public class ClassA extends BaseClass {
      tableName = "location";
    } I got an error message.
    I can move it in a static initializer block but then it will only work when the class is loaded. In my case its possible i want to get this value without loading the class.
    Ditto if i move it to constructor.
    Any input? Thanks

    Are you saying that if i have 2 classes ClassA and
    ClassB inherited from BaseClass, then both are
    sharing the same copy of 'tableName' staticvariable?
    If yes then I should go with an instance variable.No, I am saying that you can easily declare a
    tablName in A and another tableName in B.
    A.tableName will be shared between all the instances
    s of A. B.tableName will be shared between all the
    instances of B. And BaseClass.tableName is
    irelevant. I think you try to use
    BaseClass.tableName as some kind of template for
    sub-classes, but this does not happen: you need to
    declare tableName again and again in each subclass.
    IThanks for clarifying. Each class needs to have a variable "tableName" and it needs to have one copy of this variable for all of that class's objects. 2 classes will not have the same value of this tableName variable.
    Thats why I was defining it as static variable. And I define it in BaseClass so that I dont have to define it again in each subclass.
    Is there any better way? Thanks

  • FM/BAPI for assigning a class and value for the class instead of manually d

    Hi guys,
    Instead of manually adding equipment class and assigning value for the class added can i get a FM or BAPI.
    this is for transaction IE02.
    rewards will be given.

    Hi
    I hope this thread can help you
    Characteristic Value
    Re: Equipment Characteristic Value
    Change Equipment Using Transaction IE02
    Regards
    pavan

  • Assign collector to a profile class

    hi all,!
    just trying to assign collector to a profile class in receivables.. but cant find where to do it or any documentation that tells me!
    any advice?
    cheers!

    As the local variable has a lifetime of the executing method's
    duration, you must ensure the innerclass (which has a longer lifetime)
    has access to it by declaring it final.This is not quite exact. All this is due to the way inner classes are implemented. An inner class maintains the contents of the outer local variables used in two ways:
    - If it is primitive, use the value verbatim (so the class has no relationship to the outer variable, it just uses the same number, so the local var needs to be final or else there could be surprises for a programmer who would think that changing the local var would also change the value used in the inner class)
    - If it is a reference, copy it as a class member, and use that one wherever needed. For similar reasons as above, the two references have to be in sync, so the local var has to be final (the inner var can't change anyway)
    This apply only to local variables because class members are accessible through a secret reference of the enclosing object passed in the constructor of the inner class. Static members are anyway accessible.
    <teacher's mode off/>
    <sorry for that, but someone might find the explanation useful :-)/>
    By the way, the OP can get the value "t" out of the inner class by providing a special Thread subclass, ie
    class MyThread extends Thread {
      public void run() {
        t = something;
      trythis t;
    MyThread thread = new MyThread();
    thread.start();
    thread.join();
    thread.t; //This is accessibleI'm not sure if this would be preferable to the array approach (which is ), but it is useful to know your alternatives

  • Jsp:useBean and assigning a value to that bean

    Hello,
    I have a type called Country and I have declared a bean using the "jsp:useBean" syntax.
    I then try to assign a value to that bean in a scriptlet. Eventually I try to retrieve the values using "jsp:getProperty". The problem is that it appears to null.
    Here is the code of the jsp
    <%@ page language="java" %>
    <%@ page import="com.parispano.latinamericaguide.*" %>
    <%
    /* We retrieve the Countries object from the servlet context. */
    ServletContext sc = getServletContext();
    Countries cs = (Countries)sc.getAttribute("countries");
    %>
    <jsp:useBean id="country" class="com.parispano.latinamericaguide.Country"/>
    <%
    /* If the request contains a country id, then we set the variable. */
    country = cs.getCountryFromId(Integer.parseInt(request.getParameter("countryID")));
    %>
    <html>
    <head>
    <title>Country details</title>
    </head>
    <body>
    <table>
    <tr><td>Name</td><td><jsp:getProperty name="country" property="name"/><!-- This is not working--></td></tr>
    <table>
    <%
    out.println(country.getName());//This is working
    %>
    </body>
    </html>This is the code for the bean
    package com.parispano.latinamericaguide;
    * @author Julien Martin
    * Represents a country.
    public class Country implements Comparable {
         private int id;
         private String name;
         private int landArea;
         private String capital;
         private String currency;
         private String flag;
         private String internet_domain;
         private String dialling_code;
         private float literacy;
         private float male_life_expectancy;
         private float female_life_expectancy;
         private String map;
         private int population;
         private int population_year;
         private float birth_rate;
         private int birth_rate_year;
         private float death_rate;
         private int death_rate_year;
         private int gdp;
         private int gdp_per_head;
         private int gdp_year;
         private float unemployment_rate;
         private int unemployment_rate_year;
         public Country() {
         public Country(
              int id,
              String name,
              int landArea,
              String capital,
              String currency,
              String flag,
              String internet_domain,
              String dialling_code,
              float literacy,
              float male_life_expectancy,
              float female_life_expectancy,
              String map,
              int population,
              int population_year,
              float birth_rate,
              int birth_rate_year,
              float death_rate,
              int death_year_rate,
              int gdp,
              int gdp_year,
              float unemployment_rate,
              int unemployment_rate_year) {
              this.id = id;
              this.name = name;
              this.landArea = landArea;
              this.capital = capital;
              this.currency = currency;
              this.flag = flag;
              this.internet_domain = internet_domain;
              this.dialling_code = dialling_code;
              this.literacy = literacy;
              this.male_life_expectancy = male_life_expectancy;
              this.female_life_expectancy = female_life_expectancy;
              this.map = map;
              this.population = population;
              this.population_year = population_year;
              this.birth_rate = birth_rate;
              this.birth_rate_year = birth_rate_year;
              this.death_rate = death_rate;
              this.death_rate_year = death_year_rate;
              this.gdp = gdp;
              this.gdp_year = gdp_year;
              this.unemployment_rate = unemployment_rate;
              this.unemployment_rate_year = unemployment_rate_year;
         public float getBirth_rate() {
              return birth_rate;
         public int getBirth_rate_year() {
              return birth_rate_year;
         public String getCapital() {
              return capital;
         public String getCurrency() {
              return currency;
         public float getDeath_rate() {
              return death_rate;
         public int getDeath_rate_year() {
              return death_rate_year;
         public String getDialling_code() {
              return dialling_code;
         public float getFemale_life_expectancy() {
              return female_life_expectancy;
         public String getFlag() {
              return flag;
         public int getGdp() {
              return gdp;
         public int getGdp_per_head() {
              return gdp / population;
         public int getGdp_year() {
              return gdp_year;
         public int getId() {
              return id;
         public String getInternet_domain() {
              return internet_domain;
         public float getLiteracy() {
              return literacy;
         public float getMale_life_expectancy() {
              return male_life_expectancy;
         public String getMap() {
              return map;
         public String getName() {
              return name;
         public int getPopulation() {
              return population;
         public int getPopulation_year() {
              return population_year;
         public int getLandArea() {
              return landArea;
         public float getUnemployment_rate() {
              return unemployment_rate;
         public int getUnemployment_rate_year() {
              return unemployment_rate_year;
         public void setBirth_rate(float f) {
              birth_rate = f;
         public void setBirth_rate_year(int i) {
              birth_rate_year = i;
         public void setCapital(String string) {
              capital = string;
         public void setCurrency(String string) {
              currency = string;
         public void setDeath_rate(float f) {
              death_rate = f;
         public void setDeath_rate_year(int i) {
              death_rate_year = i;
         public void setDialling_code(String string) {
              dialling_code = string;
         public void setFemale_life_expectancy(float f) {
              female_life_expectancy = f;
         public void setFlag(String string) {
              flag = string;
         public void setGdp(int i) {
              gdp = i;
         public void setGdp_per_head(int i) {
              gdp_per_head = gdp/population;
         public void setGdp_year(int i) {
              gdp_year = i;
         public void setId(int i) {
              id = i;
         public void setInternet_domain(String string) {
              internet_domain = string;
         public void setLiteracy(float f) {
              literacy = f;
         public void setMale_life_expectancy(float f) {
              male_life_expectancy = f;
         public void setMap(String string) {
              map = string;
         public void setName(String string) {
              name = string;
         public void setPopulation(int i) {
              population = i;
         public void setPopulation_year(int i) {
              population_year = i;
         public void setlandArea(int i) {
              landArea = i;
         public void setUnemployement_rate(float f) {
              unemployment_rate = f;
         public void setUnemployment_rate_year(int i) {
              unemployment_rate_year = i;
         public String toString() {
              return name;
         public int compareTo(Object o) {
              Country c = (Country)o;
              int cmp = name.compareTo(c.name);
              System.out.println(cmp);
              return cmp;
    }Can anyone please help?
    Thanks in advance,
    Julien.

    Thanks,
    I have added scope="application". It still show "null" indicating that the bean is not initialized with the properties. I would like a quicker way to initialize a bean property than invoking the setProperty tag for each property.
    Here is a simple example that demonstrates the problem:
    <%@ page language="java" %>
    <%@ page import="com.tests.*" %>
    <jsp:useBean id="monBean" class="com.tests.MonBean" scope="application"/>
    <%
    MonBean mb = new MonBean();
    mb.setName("toto");
    monBean= mb;
    %>
    <html>
    <head>
    <title>Lomboz JSP</title>
    </head>
    <body bgcolor="#FFFFFF">
    <jsp:getProperty name="monBean" property="name"/>
    </body>
    </html>And the bean
    package com.tests;
    public class MonBean {
    private String name;
    public String getName() {
         return name;
    public void setName(String name) {
         this.name = name;
    }This show "null".
    Any other idea why this is not working?
    Thanks,
    Julien

  • Assigning of values to the charecteristics while doing GR

    Dear Gurus
    I have created a charecteristic and assigned it to a class of classtype 23 (batch class).I assigned this class to a material.Now while doing GR of this material through TCODE MB1C and movement type 561 the system is giving the automatic batch number.But it is not giving any options for assigning  the values for the charecteristic that I have kept in the class.How to assign the value while doing GR ?.I am able to assign the value by going to TCODE MSC2N.
    Regards
    Sandip Sarkar

    Hi Sandip,
    One option will be mark all those characteristics as Entry Required in T.code CT04.
    So that you will get a warning msg. during GR if value is not maintain.
    Msg. No is LB045 and msg is,
    The characteristic values for the batch are incomplete.
    If required you can convert that warning msg to Error also.
    You can do it by using T.code OCHS.
    But keep notice that you have to go that Classification tab manually - there is no other option in
    Regards,
    Dhaval

  • How to change the value of Valuation class.

    dear friends:
    i want to change the value of Valuation class in the material master .but system  warning info occurs .
    The valuation class cannot be changed
    Message no. M3 368
    Diagnosis
    You wanted to change the valuation class. However, this is not possible because one or more of the following already exist for the material:
    Valuated stocks in the current period or in the previous period
    Open purchase orders or delivery schedule lines
    Production orders for which a goods movement has already taken place
    System Response
    Your change is reset by the system.
    Procedure
    If valuated stocks already exist, you can change the valuation class only as follows:
    a) Post the stocks of the material to an interim account.
    b) Change the valuation class in the material master record.
    c) Post the stocks of the material back to their original account.
    If open purchase orders already exist, you can only change the valuation class if you first flag the corresponding purchase order items for deletion.
    If production orders exist for which a goods movement has already taken place, you can only change the valuation class if you first set the status of the production orders to Deleted.
    Procedure for System Administration
    In Customizing for the Material Master, you can switch the check for open purchase orders and/or for production orders to a warning. You do this in Define Attributes of System Messages by assigning the message type Warning to message MM 326 and/or MM 327 respectively. However, first ensure organizationally that further processing of the open purchase orders or production orders cannot result in inconsistencies.

    To resolve SAP error message M3 368 I would suggest that you refer to SAP note number 1967543. This note outlines the issue and a resolution to it:
    Please have a look at the description of the error M3 368. This error may occur if one or more of the following already exist for the material:
    1. Valuated stocks in the current period or in the previous period
    2. Open purchase orders or delivery schedule lines
    3. Production orders for which a goods movement has already taken place
    Resolution:
    If you have valuated stocks in the current period or in the previous period, you will get message "Stocks already exist.". You have to clear all the stocks both in current period and previous period. Please have a look at SAP Note 30656, it shows an example on how to clear the stocks in
    previous period. You can use transaction MIGO to execute this step.
    If you have open purchase orders or delivery schedule lines, you will get message "Purchase orders already exist.". You can find related purchase orders after you click 'Display Error' button. Please delete them in transaction ME22N.
    If you have production orders for which a goods movement has already taken place, you will get message "Production orders already exist.". Please archive these production orders. You need to set deletion flag for these orders firstly and go to SARA, use archiving object PP_ORDER to archive
    these orders.
    Kind regards,
    James

  • Class/member variables usage in servlets and/or helper classes

    I just started on a new dev team and I saw in some of their code where the HttpSession is stored as a class/member variable of a servlet helper class, and I was not sure if this was ok to do or not? Will there be problems when multiple users are accessing the same code?
    To give some more detail, we are using WebLogic and using their Controller (.jpf) files as our servlet/action. Several helper files were created for the Controller file. In the Controller, the helper file (MyHelper.java) is instantiated, and then has a method invoked on it. One of the parameters to the method of the helper class is the HttpServletRequest object. In the method of the helper file, the very first line gets the session from the request object and assigns it to a class variable. Is this ok? If so, would it be better to pass in the instance of the HttpServletRequest object as a parameter to the constructor, which would set the class variable, or does it even matter? The class variable holding the session is used in several other methods, which are all invoked from the method that was invoked from the Controller.
    In the Controller file:
    MyHelper help = new MyHelper();
    help.doIt(request);MyHelper.java
    public class MyHelper {
        private HttpSession session;
        public void doIt(HttpServletRequest request) {
            session = request.getSession();
            String temp = test();
        private String test() {
            String s = session.getAttribute("test");
            return s; 
    }In the past when I have coded servlets, I just passed the request and/or session around to the other methods or classes that may have needed it. However, maybe I did not need to do that. I want to know if what is being done above will have any issues with the data getting "crossed" between users or anything of that sort.
    If anyone has any thoughts/comments/ideas about this I would greatly appreciate it.

    No thoughts from anyone?

  • Pass a value to a class that extends AbstractTableModel

    Hi
    I have a problem with a table model that I cannot find a way of overcoming.
    I have created a class called MyTableModel that extends AbstractTableModel.
    MyTableModel creates and uses another class that I have defined in order to retrieve records from a database, MyTableModel fills the table with these records.
    However, I wish to alter my class in order to provide an int parameter that will act as a �where� value in the classes sql query.
    The problem is this, I cannot work out how to pass a value into MyTableModel. I have tried creating a simple constructor in order to pass the value but it doesn�t work.
    My code is shown below:
    import BusinessObjects.JobItemClass;
    import DBCommunication.*;
    import java.util.ArrayList;
    import javax.swing.table.AbstractTableModel;
    public class MyJobItemTableModel extends AbstractTableModel
      public MyJobItemTableModel(int j)
          jobNo = j;
      int jobNo;
      JobAllItems jobItems = new JobAllItems(jobNo);
      ArrayList items = jobItems.getItems();
      String columnName[] = { "Item Number", "Item Description", "Cost per item", "Quantity" };
      int c = items.size();
      Class columnType[] = { Integer.class, String.class, Double.class, Integer.class };
      Object table[][] =  new Object[c][4];
      public void fillTable()
          if(c > 0)
            for (int i = 0; i < c; i = i + 1)
              this.setValueAt(((JobItemClass) items.get(i)).getItemNumber(), i, 0);
              this.setValueAt(((JobItemClass) items.get(i)).getDescription(), i, 1);
              this.setValueAt(((JobItemClass) items.get(i)).getCostPerItem(), i, 2);
              this.setValueAt(((JobItemClass) items.get(i)).getQuantity(), i, 3);
      public void setJobNo(int s)
          jobNo = s;
      public int getColumnCount()
          if(c > 0)
            return table[0].length;
          else
              return 0;
      public int getRowCount()
        return table.length;
      public Object getValueAt(int r, int c)
        return table[r][c];
      public String getColumnName(int column)
        return columnName[column];
      public Class getColumnClass(int c)
        return columnType[c];
      public boolean isCellEditable(int r, int c)
        return false;
      public void setValueAt(Object aValue, int r, int c)
          table[r][c] = aValue;
    }Any advice will be appreciated.
    Many Thanks
    GB

    your JobAllItems is created before constructor code is run (since it is initialized in class member declaration)
    use something like
    public MyJobItemTableModel(int j)
          jobNo = j;
          items = (new JobAllItems(jobNo)).getItems();
          c = items.size();
          table =   new Object[c][4];
      int jobNo;
      ArrayList items;
      String columnName[] = { "Item Number", "Item Description", "Cost per item", "Quantity" };
      int c;
      Class columnType[] = { Integer.class, String.class, Double.class, Integer.class };
      Object table[][] ;instead of
    public MyJobItemTableModel(int j)
          jobNo = j;
      int jobNo;
      JobAllItems jobItems = new JobAllItems(jobNo);
      ArrayList items = jobItems.getItems();
      String columnName[] = { "Item Number", "Item Description", "Cost per item", "Quantity" };
      int c = items.size();
      Class columnType[] = { Integer.class, String.class, Double.class, Integer.class };
      Object table[][] =  new Object[c][4];

  • Property not a class member... why?

    I'm looking at this sample code... metronome.h:
    ===== IMPORTANT =====
    This is sample code demonstrating API, technology or techniques in development.
    Although this sample code has been reviewed for technical accuracy, it is not
    final. Apple is supplying this information to help you plan for the adoption of
    the technologies and programming interfaces described herein. This information
    is subject to change, and software implemented based on this sample code should
    be tested with final operating system software and final documentation. Newer
    versions of this sample code may be provided with future seeds of the API or
    technology. For information about updates to this and other developer
    documentation, view the New & Updated sidebars in subsequent documentation
    seeds.
    =====================
    File: MetronomeView.h
    Abstract: MetronomeView builds and displays the primary user interface of the
    Metronome application.
    Version: 1.6
    Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc.
    ("Apple") in consideration of your agreement to the following terms, and your
    use, installation, modification or redistribution of this Apple software
    constitutes acceptance of these terms. If you do not agree with these terms,
    please do not use, install, modify or redistribute this Apple software.
    In consideration of your agreement to abide by the following terms, and subject
    to these terms, Apple grants you a personal, non-exclusive license, under
    Apple's copyrights in this original Apple software (the "Apple Software"), to
    use, reproduce, modify and redistribute the Apple Software, with or without
    modifications, in source and/or binary forms; provided that if you redistribute
    the Apple Software in its entirety and without modifications, you must retain
    this notice and the following text and disclaimers in all such redistributions
    of the Apple Software.
    Neither the name, trademarks, service marks or logos of Apple Inc. may be used
    to endorse or promote products derived from the Apple Software without specific
    prior written permission from Apple. Except as expressly stated in this notice,
    no other rights or licenses, express or implied, are granted by Apple herein,
    including but not limited to any patent rights that may be infringed by your
    derivative works or by other works in which the Apple Software may be
    incorporated.
    The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO
    WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
    WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
    COMBINATION WITH YOUR PRODUCTS.
    IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
    GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR
    DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF
    CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
    APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    Copyright (C) 2008 Apple Inc. All Rights Reserved.
    #import <UIKit/UIKit.h>
    #import <QuartzCore/QuartzCore.h>
    #import "MetronomeViewController.h"
    #import "Constants.h"
    @class SoundEffect, MetronomeViewController;
    @interface MetronomeView : UIView {
    IBOutlet MetronomeViewController *metronomeViewController;
    UIImageView *metronomeArm;
    UIImageView *metronomeWeight;
    UILabel *tempoDisplay;
    NSThread *soundPlayerThread;
    SoundEffect *tickSound;
    SoundEffect *tockSound;
    CGFloat duration;
    NSUInteger beatNumber;
    BOOL armIsAnimating;
    BOOL tempoChangeInProgress;
    BOOL armIsAtRightExtreme;
    CGPoint lastLocation;
    // Property for beats per minute. Getting and setting this property alters the duration.
    // The accessors for this property are implemented, rather than synthesized by the compiler.
    @property NSUInteger bpm;
    @property (nonatomic, retain) NSThread *soundPlayerThread;
    @property (nonatomic, assign) MetronomeViewController *metronomeViewController;
    // Invoked when the user changes the time signature
    - (IBAction)updateAnimation:(id)sender;
    @end
    I'm looking at the property bpm. It isn't a class variable. I'm confused why this is... does it still work like the other class variables? I see that the the getter and setter methods are implemented rather than synthesized... But I still don't understand why it isn't a class member...
    Thanks.

    First, in Objective-C there is no "class member", only instance variable (and no class variable).
    Second, @property allows you to declare accessor methods without writing those :
    - (void)setName:(NSString *)aName;
    - (NSString *)name;
    That's just some line economizing.
    On the implementation side. @synthesize allows you to implement methods without writing those :
    - (void)setName:(NSString *)aName {
    if(name != aName)
    [name release];
    name = [aName retain];
    - (NSString *)name {
    return [[name retain] autorelease];
    Here it economize code again... Nothing more.
    @synthesize creates a default implementation for a specific property. However if you want to make specific modifications in your getter/setter you're forced to implement the methods yourself. In this case the reason is that there's no bpm ivar to link the properties to.
    But it could be another possibility, like, for example, when the user set the name, you want a nick-name ivar to be set as well. Here you need to use a specific method implementation and @synthesize can't help you.
    However, that are just implementation things... It doesn't change the behavior of the properties... And you can even use the dot-syntax on non-property methods if you want, it's just need to be KVC-compliant.

  • Please comment to support basic ADF library  like assignment of values :)

    Hello,
    I am asking Oracle to develop a library for basic operations like assigning values.
    This is for newbies and for new components.
    Reason: Java is not like pl/sql, visual basic, etc. I had bee studying for get certified on Java it takes time, once you create your own library then there is no problem the main reason is to accelerate the learning of adf programming and programming in new components
    There are some examples in JSFUTIL and ADFUTIL libraries, but they are only examples.
    the idea is Oracle to create
    1) libraries supported and maintained by oracle for ALL the ADF components
    2) same function for all components, in example, to set a value to any adf item to have the same function, and that function make the conversion, suggest the import of the correct libraries (in example to use adf number instead of java number to get autoboxing)
    etc.
    If you agree with this requirement to Oracle, please comment :) Thank you.

    Thank you Frank I don't find it so difficult,
    This is what I think, what do you think about.
    The first concept I think and is the base for this "project" is "ADF Framework is here to make easier programming", this means if Oracle can create a library to make it easier then it makes sense with Oracle's Strategy of course; this is not because only because I'm asking. :)
    If you want we can start analyzing the most basic example: assigning values.
    If I execute
    JSFUtils.setExpressionValue("#{bindings.Hora0.inputValue}",2);
    JSFUtils.setExpressionValue("#{bindings.Hora0.inputValue}","2");
    JSFUtils.setExpressionValue("#{bindings.Hora0.inputValue}",nValue); -- no matter what type of value nValue is
    You get assigned, if there is a limitation to the type of the variable, then I should receive a message like "you can't use native Integer , you have to use int to get autoboxing", some message very specific to help me to solve the problem.
    Why I'm asking this, because I created a simple example and I couldn't get a value assigned to that item, it was an (ADF Faces. Text an Selection)
    My opinion is I should had got a better error message, so I can't fix my assignment, because for me it was all "ok", this is one of my first applications, but I think It should be easier to assign a value in adf framework.
    And I'm asking a function I'll have to do myself to work using adf framework, there is no choice.
    I include the example below showing I had problems assigning values, maybe it was a very obvioius mistake causes , so I started to modify it. (I'm starting on java I'm on the process to get certification).
    public static void setExpressionValue(String expression, Object newValue) {
    FacesContext facesContext = getFacesContext();
    Application app = facesContext.getApplication();
    ExpressionFactory elFactory = app.getExpressionFactory();
    ELContext elContext = facesContext.getELContext();
    ValueExpression valueExp =
    elFactory.createValueExpression(elContext, expression,
    Object.class);
    //Check that the input newValue can be cast to the property type
    //expected by the managed bean.
    //If the managed Bean expects a primitive we rely on Auto-Unboxing
    Class bindClass = valueExp.getType(elContext);
    System.out.println("0 setExpressionValue");
    String tipoVar = valueExp.getType(elContext).toString();
    System.out.println("1 setExpressionValue:"+tipoVar);
    String TipoOJDN = "class oracle.jbo.domain.Number";
    System.out.println("1 IGUALDAD TipoOJDN:"+(tipoVar.equals(TipoOJDN)));
    if (tipoVar.equals(TipoOJDN))
    {System.out.println("Es Número");  
            System.out.println("1 setExpressionValue TipoOJDN");
            String ojdn =  newValue.toString() ;
            System.out.println("2 setExpressionValue TipoOJDN");
            Number variable = null;
            System.out.println("3 setExpressionValue TipoOJDN"+ojdn);
          //  variable = Integer.parseInt(ojdn);
            System.out.println("4.1dddd setExpressionValue TipoOJDN num");
            /*    String a1 = newValue.toString();
                Integer i1 = Integer.valueOf(a1);
                int i2;*/
                Number num;
                try {
                    num = new Number(newValue);
                System.out.println("4.2 setExpressionValue TipoOJDN num:"+num);
                    valueExp.setValue(elContext, num);
                    System.out.println("5 setExpressionValue TipoOJDN");           
                } catch (SQLException e) {
    System.out.println("exception convertin number"+newValue);
    // oracle.jbo.domain.Number.formattedTextToNumber(arg0, arg1, arg2) a = (oracle.jbo.domain.Number)newValue;
    else
    {System.out.println("tipoVar:"+tipoVar);
    // if (bindClass.isPrimitive() || bindClass.isInstance(newValue)) {
    System.out.println("3 setExpressionValue:");
    valueExp.setValue(elContext, newValue);
    System.out.println("4 setExpressionValue:"+valueExp.getValue(elContext));
    ViewObjectImpl view = this.getSomeView();
    VariableValueManager vm = view.ensureVariableManager();
    vm.setVariableValue("bindVariableName", value);
    view.executeQuery();
    */

  • Static class member is beying destroyed inside a Controller - Why?

    Hello,
    I need to manage a certain BigDecimal class member in a Dynpro application which will not be destroyed. This class member represents a key in a database which from few reasons I would like to manage on my own.
    In order to implement that, I have created a private static class member at the Controller and a get method in order for the other views to get it's value.
    The get method checks if the value is null.
    In case it is it queries the Database for the maximum value and return it + 1 to the requestor.
    In case it is not null it simply increments the current value by 1 and returns it to the requestor.
    According to my assumption, a DB query should happen only once since this member is static, yet when I monitor the application I see it queries the Database occasionally, which mean that the member has been destroyed.
    I tried solving that by setting the expirationTime of the application to few hours but even inside this range the variable is being destroyed.
    My questions are:
    1. What am I missing here?
    2. How and where should I manage a static variable in a Web dynpro application in order to assure it won't be destroyed during the lifetime of the application?

    Hello Valery,
    Here is the relevant code:
    At the controller I declare this static member:
    private static BigDecimal globalRequest = null;
    And here is the method:
    public java.lang.String getNewRequestNumber( java.sql.Statement statement )
        //@@begin getNewRequestNumber()
        try
              if (globalRequest == null)
                   ResultSet rs = statement.executeQuery("SELECT MAX(record_number) AS maxRecord FROM COMMITTEES_REQUEST");
                   if (rs.next())
                        BigDecimal maxRequest = rs.getBigDecimal("maxRecord");
                        globalRequest = maxRequest.add(new BigDecimal(1));
                        rs.close();
                        return (globalRequest.toString());     
                   else
                        rs.close();
                        return null;
              else
                   globalRequest = globalRequest.add(new BigDecimal(1));
                   return (globalRequest.toString());
        catch (SQLException e)
             return null;
        //@@end
    Thank you in advance,
    Roy

  • Internal error while overwriting a charecteristic value in a class

    Hi,
    I am overwriting a charecteristic value in a class with a change master.
    In CL02 I entered the class and the chnage number and entered in edit mode.
    Then I selected the charecteristic view and selected the specific charectristic which value I need to overwrite and then clicked on "Overwrite Value" button.
    Now the system has found an internal error: the required characteristic data was not found in characteristics maintenance.
    Charecteristic data not found: Internal Error
    Please tell me how can I get out of this error.

    hi,
    Please check whether the overwriting indicator check box in character tab is select or not.
    It should be flagged.
    Thanks & regards
    Reddiy.

Maybe you are looking for

  • Where is the "Manage" Bookmarks option in Firefox 19.0.2 so I can rename or delete a folder?

    I have tried the "wheel" icon to manage / delete/ rename the bookmark folders as the tutorial suggests but it will not allow me to select the "delete" option (I can see "delete", won't work ) and it offers no option for renaming folders. Before I cou

  • IPhone5 bluetooth in car not finding phone

    Hi, I am trying to pair my iPhone 5 with the bluetooth in my car.  It was connected, and worked just great. Somehow, the connection was lost.  I try to pair, and I get a message saying "Unable to find device" and it suggests that I am out of range (I

  • "Out of Disk Space" Error When there are 198GB available

    We are attempting to capture a two hour video from VHS through an ADVC-300 box. We can capture short videos easily. For some reason we keep getting an "out of disk space" error even though there are 198GB free on the scratch disk which is an external

  • Disable Faulty FireWire Ports In 10.4.11

    my powermac's firewire ports are fried, and it causes all kinds of problems (slow startup, random freezes, computer won't sleep). i found this: sudo -s Password: (enter admin password) cd /System/Library/Extensions cd IOFireWireFamily.kext/Contents/P

  • Frame rate control

    Hi This is want I want to achieve: (1) capture video from web cam (2) process video in higest resolution and frame rate (eg motion detection) (3) transmit video on RTP on low resolution and frame rate High quality is required for (2) to improve detec