Chinese Remainder theorem : Looking for an implementation

Weill it's not as if it's a difficult theorem but I don't really know the algorith to make it work, though I need the result obtained by it, so I searched an already done implementation of this algorith but couldn't find it. So if anyone has an idea of where I could find it, I would be grateful...
Thanks!

The only way you could need this is if it has been set as homework. In which case YOU need to program the algorithm, not us. I suggest you do some more research because Google produced 'about 658,000' hits.

Similar Messages

  • Looking for Java Input Method implementations

    Hi,
    I have developed a Java-based research application for computational linguistics. I'm currently internationalizing this application. I'm looking for FREE implementations of the Java Input Method Framework. Could you please give me a hint?
    Thanks in advance,
    Wolfgang Lezius
    University of Stuttgart, Germany

    http://forum.java.sun.com/thread.jsp?forum=16&thread=270024 contains few useful links.

  • How's this for a first attempt? Looking for feedback.

    I previously created a database in MS Excel for my Son's business.  It was "normalized" with lots of Application.Vlookup... commands building Listviews.  Everything was working fine until I upgraded my Office 2003 to Office 2010. 
    Since I got the 64-bit version of Office I can no longer use Treeview or Listview controls in Office forms.  Office will not allow both versions to be on the same computer.  So, I figured I'd convert the whole thing over to VB.NET.
    Anyway, I'm part of the way done with converting ONE of my userforms to VB.Net and I wanted to see if I was headed in the write direction or if I am moving toward a train wreck.
    I started with the Customers form because the table it connects too doesn't have any foreign keys.  The difficulties I ran into along the way were:
    trying to learn how to navigate through a dataset (used to be easy with the Recordset)
    Virtually all the references I found teach you to use the Wizard to connect to a database then drop it into a grid control.
    trying to populate the treeview control without being able to use "Keys".  This was an incredible nightmare.
    There were many other small hurdles along the way
    Oddly enough one of the most helpful books I found was for learning VB.NET 2005.  It was old enough so that the author made comparisons of .NET to VB6, highlighting the functionality lost with .NET.  Don't get me wrong, he wasn't bashing .NET but
    his book was where I discovered that the Treeview no longer uses "Keys".  I'm dreading the Listview struggle yet to come. </End Whining>
    Here is the form.  As it stands right now, the treeview on the left gets populated, when the user clicks on a node, the textboxes on the right are populated.
    Below is the Code I've written so far.
    Public Class frmCustomers
    Dim con As New OleDb.OleDbConnection
    Dim ds As New DataSet
    Dim da As OleDb.OleDbDataAdapter
    Dim inc As Integer
    Dim dbProvider As String
    Dim dbSource As String
    Dim sql As String
    Private Sub frmcustomers_load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    dbProvider = "PROVIDER=Microsoft.ACE.OLEDB.12.0;"
    dbSource = "Data Source = E:\TW DB Development\TWDB.accdb"
    con.ConnectionString = dbProvider & dbSource
    con.Open()
    sql = "SELECT * FROM Customers ORDER BY Customer_Name"
    da = New OleDb.OleDbDataAdapter(sql, con)
    da.Fill(ds, "Customer_List")
    con.Close()
    PopulateTreeview()
    End Sub
    Private Sub PopulateTreeview()
    Dim objLetterNode As TreeNode
    Dim objFirstNameNode As TreeNode
    Dim objCustomerTable As DataTable
    Dim iLastRecord As Integer
    Dim iRecordCount As Integer
    Dim sCustomerFullName As String
    Dim sCurrentAlpha As String
    Dim sCurrentFirstName As String
    Dim sNewAlpha As String
    Dim sNewFirstName As String
    objCustomerTable = ds.Tables("Customer_List")
    iLastRecord = objCustomerTable.Rows.Count - 1
    iRecordCount = 0
    ' Get Fullname, Firstname, and First Letter for first row of table
    sCustomerFullName = objCustomerTable.Rows(iRecordCount).Item("Customer_Name")
    sCurrentAlpha = FirstLetter(sCustomerFullName)
    sCurrentFirstName = GetFirstName(sCustomerFullName)
    tv.Nodes.Clear()
    ' Create Nodes for first letter, first name
    With tv.Nodes
    objLetterNode = .Add(sCurrentAlpha)
    With objLetterNode.Nodes
    objFirstNameNode = .Add(sCurrentFirstName)
    With objFirstNameNode.Nodes
    .Add(sCustomerFullName)
    End With
    End With
    End With
    ' Process remainder of table
    For iRecordCount = 1 To iLastRecord
    With tv.Nodes
    sCustomerFullName = objCustomerTable.Rows(iRecordCount).Item("Customer_Name")
    sNewAlpha = FirstLetter(sCustomerFullName)
    sNewFirstName = GetFirstName(sCustomerFullName)
    ' Is first letter the same
    If sNewAlpha = sCurrentAlpha Then
    ' Is first name the same
    With objLetterNode.Nodes
    If sNewFirstName = sCurrentFirstName Then
    With objFirstNameNode.Nodes
    .Add(sCustomerFullName)
    End With
    Else
    ' first name changed
    With objLetterNode.Nodes
    objFirstNameNode = .Add(sNewFirstName)
    With objFirstNameNode.Nodes
    .Add(sCustomerFullName)
    End With
    End With
    sCurrentFirstName = sNewFirstName
    End If
    End With
    Else
    ' first letter changed, therefore so did first name
    objLetterNode = .Add(sNewAlpha)
    sCurrentAlpha = sNewAlpha
    With objLetterNode.Nodes
    '.Add(sNewFirstName)
    objFirstNameNode = .Add(sNewFirstName)
    sCurrentFirstName = sNewFirstName
    With objFirstNameNode.Nodes
    .Add(sCustomerFullName)
    End With
    End With
    End If
    End With
    Next iRecordCount
    End Sub
    Private Function FirstLetter(str As String)
    ' Returns first letter of first name
    FirstLetter = Strings.Left(str, 1)
    End Function
    Private Function GetFirstName(str As String)
    ' Returns text before first space in fullname as First name
    GetFirstName = Strings.Left(str, Strings.InStr(str, " ") - 1)
    End Function
    Private Sub DisplayRow(r As DataRow)
    txtCustomerName.Text = r.Item("Customer_Name")
    txtAddressLine1.Text = r.Item("Address_Line_1")
    txtAddressLine2.Text = "" & r.Item("Address_Line_2")
    txtAddressLine3.Text = "" & r.Item("Address_Line_3")
    txtCountry.Text = "" & r.Item("Country")
    txtCity.Text = "" & r.Item("City")
    txtState.Text = "" & r.Item("Region")
    txtPostalCode.Text = "" & r.Item("Postal_Code")
    txtCustomerEmail.Text = "" & r.Item("email_Address")
    txtCustomerPhone.Text = "" & r.Item("Phone_Number")
    txtCustomerComments.Text = "" & r.Item("Comments")
    txtCustomerID.Text = r.Item("Customer_ID")
    End Sub
    Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
    Me.Close()
    End Sub
    Private Sub tv_AfterSelect(sender As Object, e As TreeViewEventArgs) Handles tv.AfterSelect
    Dim sNodeText As String
    Dim table As DataTable = ds.Tables("Customer_List")
    Dim dr As DataRow()
    sNodeText = tv.SelectedNode.Text
    dr = table.Select("Customer_Name = '" & sNodeText & "'")
    If dr.Length > 0 Then
    DisplayRow(dr(0))
    End If
    End Sub
    End Class
    Previously I could populate the treeview in whatever random order the records were in the table.  With the new treeview I had to devise a way to add, Letters, First Names, and Full Names all in sorted order.
    Thanks,
    Ken

    Thanks :).
    This is essentially a "local" database as only one person will access it at a time.  We are placing the file in an area where it can accessed from more than one computer, but never more than one at a time.
    To be honest I would use SQL Express (mainly to bring myself into the 21st century) if I wasn't already finding VB.NET so frustrating.
    Ken,
    I thought that I’d "give you a taste" of this alternate. It’s a long route, but you might want to consider it because
    everything you do is very much tailored to what you want it to do. As it stands right now, it’s very simple - too much so - but this might give you food for thought.
    If you want to pursue it, I’m happy to help.
    I set up the beginnings of a namespace that I’m calling “Ken”. The main class in that namespace is a class named “CustomerInfo”.
    It needs a LOT of embellishing, including the ability to disallow duplicate entries (we’d need to discuss just how it should detect a duplicate entry – it’s not as straightforward as you might think) and other things, but it’s a start and it’ll do ok for this
    example.
    Before I get started here, I have the project folder zipped up and uploaded for you. I hope you’ll download it and take a look
    at the code that it’s that namespace.
    I have that
    uploaded
    to my website here.
    You’ll see that it’s about 700 lines of code so far and I’d venture to say that by the time we finished, it would be many THOUSANDS
    of lines of code. I bring this up because I want to emphasize that it’s a lot of work - but - it would be all customized to do what you want and it would be reusable by simply adding the namespace into another program.
    All of this is based around your screenshot from a few days ago:
    I only have, so far, the ability to “Add” via a method in the main class named “AddNewCustomer” which is overloaded; that is,
    there are several implementations of it, varying in the parameters used. I’ll demonstrate some of them in the examples that follow shortly.
    When you open the project in Visual Studio you’ll be asked to convert it because I use a much older version than you have. Just
    follow the prompts and it should convert fine. Once that’s done, it should open to the code view of Form1:
    Option Strict On
    Option Explicit On
    Option Infer Off
    Public Class Form1
    Private customerList As New List(Of Ken.CustomerInfo)
    Private Sub Form1_Load(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) _
    Handles MyBase.Load
    ' Example01()
    ' Example02()
    ' Example03()
    ' Example04()
    ' Example05a()
    ' Example05b()
    ' Example05c()
    Stop
    End Sub
    End Class
    Hey, where are those subs??
    Actually I broke Form1 apart so that I could show you the start of it above, and I have the subs mentioned in a Partial Class
    Form1 (partial just means that it will compile as all one). I’ll step through each sub below and explain what it’s demonstrating:
    I have the “Address” set up somewhat special. I have it so that you can’t have a second address line unless there’s a first
    line and you can’t have a third address line unless there’s both a first AND a second line. I think you agree with that thinking?
    Example01 is a demonstration of just one single line for the address:
    Private Sub Example01()
    Try
    Ken.CustomerInfo.AddNewCustomer(customerList, _
    "ABC Hardware Company", _
    "123 Main Street", _
    Ken.CountryName.USA, _
    "Charleston", _
    "South Carolina", _
    "29412", _
    "8138992347")
    MessageBox.Show(customerList(0).ToString, _
    "Example01")
    Stop
    Catch ex As Exception
    MessageBox.Show("An exception was thrown:" & _
    vbCrLf & vbCrLf & ex.Message, _
    "Program Error", MessageBoxButtons.OK, _
    MessageBoxIcon.Warning)
    End Try
    End Sub
    Notice above that the parameters for the sub give you an idea about how it’s set up. This includes the use of an Enum (enumerator)
    for the country. This may or may not be a good idea, it really just depends on how many countries there could be. I have it currently set up with just three countries. I also have it set up for what I’m regarding “minimum required” – you’ll notice that there’s
    no place for the customer’s e-mail address or a comment. They are there though – set up as options (and I’ll demonstrate that in a bit also).
    Give thought about the countries to include, in particular questions about what the minimum required needs to be.
    For example, currently it REQUIRES a postal code. Do all of the countries you’ll be dealing with always have that? Further,
    the phone number MUST be ten (exactly ten) digits. For other countries maybe it should include the country code? Maybe some of them aren’t digits? I don’t know – but certainly you need to know this even if you stick with the database route.
    At any rate I had to start with some assumptions so that’s what I used.
    Example 2, below, shows using two lines for the address:
    Private Sub Example02()
    Try
    Ken.CustomerInfo.AddNewCustomer(customerList, _
    "ABC Hardware Company", _
    "123 Main Street", _
    "Building 'E'", _
    Ken.CountryName.USA, _
    "Charleston", _
    "South Carolina", _
    "29412", _
    "8138992347")
    MessageBox.Show(customerList(0).ToString, _
    "Example02")
    Stop
    Catch ex As Exception
    MessageBox.Show("An exception was thrown:" & _
    vbCrLf & vbCrLf & ex.Message, _
    "Program Error", MessageBoxButtons.OK, _
    MessageBoxIcon.Warning)
    End Try
    End Sub
    Example 3, below, shows using three lines for the address:
    Private Sub Example03()
    Try
    Ken.CustomerInfo.AddNewCustomer(customerList, _
    "ABC Hardware Company", _
    "123 Main Street", _
    "Building 'E'", _
    "Suite 4", _
    Ken.CountryName.USA, _
    "Charleston", _
    "South Carolina", _
    "29412", _
    "8138992347")
    MessageBox.Show(customerList(0).ToString, _
    "Example03")
    Stop
    Catch ex As Exception
    MessageBox.Show("An exception was thrown:" & _
    vbCrLf & vbCrLf & ex.Message, _
    "Program Error", MessageBoxButtons.OK, _
    MessageBoxIcon.Warning)
    End Try
    End Sub
    If you’re wondering about how all of those textual outputs shown in the MessageBox got formatted like that, look through the
    code of the namespace. Any “work” like that which the class can do, the class
    should
    do – that way it’s replicated when you reuse the class and it’s code that your form’s code doesn’t have to perform.
    Example 4, below, shows adding a comment BUT skipping the option for the e-mail:
    Private Sub Example04()
    Try
    Ken.CustomerInfo.AddNewCustomer(customerList, _
    "ABC Hardware Company", _
    "123 Main Street", _
    Ken.CountryName.USA, _
    "Charleston", _
    "South Carolina", _
    "29412", _
    "8138992347", _
    comments:="Customer pays slowly - be careful with credit!")
    MessageBox.Show(customerList(0).ToString, _
    "Example04")
    Stop
    Catch ex As Exception
    MessageBox.Show("An exception was thrown:" & _
    vbCrLf & vbCrLf & ex.Message, _
    "Program Error", MessageBoxButtons.OK, _
    MessageBoxIcon.Warning)
    End Try
    End Sub
    Note the use of “comments:=”
    in the code above. That’s a very handy way of selecting the options that you want and leaving the other options as they default to (all options have to have a default).
    Example 5a, below, shows what happens if the e-mail is used but it’s malformed:
    Private Sub Example05a()
    Try
    Ken.CustomerInfo.AddNewCustomer(customerList, _
    "ABC Hardware Company", _
    "123 Main Street", _
    Ken.CountryName.USA, _
    "Charleston", _
    "South Carolina", _
    "29412", _
    "8138992347", _
    "someone.com@somewhere")
    MessageBox.Show(customerList(0).ToString, _
    "Example05a")
    Stop
    Catch ex As Exception
    MessageBox.Show("An exception was thrown:" & _
    vbCrLf & vbCrLf & ex.Message, _
    "Program Error", MessageBoxButtons.OK, _
    MessageBoxIcon.Warning)
    End Try
    End Sub
    I am a strong advocate of data validation – on any and all levels that it can be done. Look at the code in the namespace to
    see how it was able to detect that what was entered wasn’t in correct format.
    Example 5b, below, shows entering the e-mail correctly:
    Private Sub Example05b()
    Try
    Ken.CustomerInfo.AddNewCustomer(customerList, _
    "ABC Hardware Company", _
    "123 Main Street", _
    Ken.CountryName.USA, _
    "Charleston", _
    "South Carolina", _
    "29412", _
    "8138992347", _
    "[email protected]")
    MessageBox.Show(customerList(0).ToString, _
    "Example05b")
    Stop
    Catch ex As Exception
    MessageBox.Show("An exception was thrown:" & _
    vbCrLf & vbCrLf & ex.Message, _
    "Program Error", MessageBoxButtons.OK, _
    MessageBoxIcon.Warning)
    End Try
    End Sub
    Lastly, example 5c, below, shows entering both a comment and an e-mail address:
    Private Sub Example05c()
    Try
    Ken.CustomerInfo.AddNewCustomer(customerList, _
    "ABC Hardware Company", _
    "123 Main Street", _
    Ken.CountryName.USA, _
    "Charleston", _
    "South Carolina", _
    "29412", _
    "8138992347", _
    "[email protected]", _
    "Customer pays slowly - be careful with credit!")
    MessageBox.Show(customerList(0).ToString, _
    "Example05c")
    Stop
    Catch ex As Exception
    MessageBox.Show("An exception was thrown:" & _
    vbCrLf & vbCrLf & ex.Message, _
    "Program Error", MessageBoxButtons.OK, _
    MessageBoxIcon.Warning)
    End Try
    End Sub
    Try it out. Download the project folder, let VS convert it and run it. Try entering something invalid in, for example, characters
    in the phone number, things like that. It needs a lot of improvement, but this might give you an idea of what I mean by “customized to what you want it to be”.
    For instance, your TreeView – have one or more methods in the class to build that and hand you (the consumer of the class) back
    the data to use to be able to quickly generate the TreeView showing anything you want it to show, any way you want it to show it.
    That’s the power of all of this.
    Also do know that “database or classes” isn’t accurate; they’re not mutually exclusive and in fact, most really involved programs
    which use a database back-end have many classes right along with it.
    Food for thought and I hope you found this helpful. :)
    Still lost in code, just at a little higher level.

  • Looking for help - Company is going to Mobile Asset Management service that does not support BB - especially BB 10.

    Hello,
    I am looking for ideas/help. I currently have a BB Z10 (10.1.0.2039) with Verizon Wireless.  The company has a BB Enterprise Server for older devices (I previously was on that).  I bought a Z10 several months ago and have been connecting to the corporate network through Lotus Traveler. They do not have and will not implement a BB 10 Enterprise Server. Some in IT informed that if the company used the BB software they could manage all devices..... not accepted.
    All my contacts, calendar, and company email is funneled to the BB Hub.....
    So my company is implementing a Mobile Asset Management Service that I have to sign up for (Airwatch?).  They only support Android and IPhone.
    Will future versions of the BB OS support Android Apps.... Soon (I have less than 2 weeks)
    I have read where it is possible to put the device in development mode to run Android Apps.  I don't know if that will work with this and have no idea how stable the phone is in that mode. I travel internationally so I don't know how a development mode would work overseas. Any thoughts?
    I like my Z10 but will need to switch to keep functionality if I can't find a work around 
    Any assistance ????
    Thanks for any help.

    Hi and Welcome to the Community!
    BB10 devices have the ability to run .apk apps via special methods. Development Mode is used only for installing the app...not for normal operation. So you install (side-load) the app in Development Mode, then go back to normal mode for normal operations.
    If a .bar file for the .apk app already exists somewhere, you can side load it to the BB10 device and see if it works or not. If there is not yet any .bar file, there is an app called SideSwype that can convert many .apk apps to .bar and install it to your device.
    Good luck!
    Occam's Razor nearly always applies when troubleshooting technology issues!
    If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
    Join our BBM Channels
    BSCF General Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • Looking for some assurances that I haven't made a mistake switching to Mac.

    Bought an intel-powered IMac 9 days ago and love everything about it's look, functionality, etc.. Only problem: I've had a bout of "Application has closed unexpectedly" occcurrances while using Safari (while at AOL.com deleting emails from aol account) and while editing pics in iPhoto. As this happened time and again, I got a sad, sinking feeling that I'm headed for the same frustrations that I've had w/ every Windows machine I've ever owned. Ugh!..I switched to Apple for the specific purpose of avoiding crashes!!! Apple support walked me through steps to fix (removed/updated Quicktime, and check a few other things..). They were very helpful, but... I absolutely detest having to do this. Other than Office:Mac, i've added nothing to this machine! I'm really stressed about this. I paid far more for this than I would have for a Windows machine simply because I had heard that Apple machines don't do this sort of thing!!
    Please tell me that this is normal and expected with a new machine and not a harbinger of more complicated problems to come!! I'm hoping that once resolved, I won't much more of this.. On the other hand, if many of you feel that this issue is a bad omen, I'll take the machine back while I still can. ..What a pity though, it's truly been a joy to use so far.
    IMAC (early 2006)   Mac OS X (10.4.4)  

    Hi syd123! And Welcome to Discussions!
    No you haven't made a mistake! You will love your Mac!
    Deleting AOL Mail, crashes Safari (Consolidation)
    It seems the most recent Safari, and or 10.4.4, update has created this problem.
    Apple & AOL are both aware of this, but, as far as I know, no correction has been implemented.
    Here are some of the work arounds, that I have been able to discern from the various posts regarding this issue.
    Use the FIREFOX BROWSER.
    Use your AOL Mail program.
    Use this utility AOL SERVICES ASSISTANT, to set up Apple Mail, to access AOL Mail.
    Access the AOL Mail thru Classic AOL Webmail.
    And here are links, to the various threads, discussing this issue.
    <a href="http://discussions.apple.com/thread.jspa?threadID=314479&start=0&tstart=0 "Safari and AOL</a>
    AOL/ Delete/ Safari crash
    safari crashing with aol.com mail deletion
    AOL Webmail and Safari on 10.4.2 crashes on delete mail
    Update 10.4.4 causes crash
    Safari crashes when deleting email on AOL
    Safari Update
    Safari Crashes AOL mail
    Safari Crashes when Deleting or Reporting E-Mail as SPAM on AOL Web Mail
    Looking for some assurances that I haven't made a mistake switching to Mac. This Thread
    Good Luck!
    ali b

  • Table to look for change documents for users

    Hi friends,
    Is there any standard table to look for change documents for a user?change document through SUIM does not give the correct log.
    Thanks for you support.

    Julius
    Looking at another of Tracy's other post (http://scn.sap.com/thread/3598947) she's trying to use ACL. Hence needing to know the tables to write joins/queries to hit tables within ACL
    I've seen ACL used and have had the fun experience of Auditors using Google to find tables to perform checks on without context of what has actually been implemented in their particular system.
    Regards
    Colleen

  • Upgrading to uber SDO_GEOMETRY, looking for comments

    Good morning folks,
    I see the new thread from Dalibor discussing an issue with what I am calling "uber" SDO_GEOMETRY - anyone got a better name?
    Uber SDO_GEOMETRY is described here
    http://download.oracle.com/docs/cd/E11882_01/appdev.112/e11830/sdo_migrat.htm#CHDBCHBG
    Dalibor wins some kind of prize for the first time anyone has brought up uber SDO on the forum since the old thread ran its course years back
    Re: SDO_GEOMETRY size limits here to stay?
    Coincidentally this past week was my first shot at trying out the upgrade script and I thought I might post my experiences and see if anyone would have comments. This was just a test machine and I agree that each major error could have been followed up with a SR. But my overall goal is to determine if installing and running uber SDO_GEOMETRY is feasible in my production environment, so for better or worse these experiences are building those recommendations.
    So I am not much interested in going much in length why anyone would want to upgrade. I think the old thread covers it. For my work at least, the issues have not gone away. No question a polygon with millions of vertices is nutty, but they are out there all over the place and growing in number each year. Here are two additional datasets I am working with that are "over the top" for normal SDO:
    * National Wetlands Inventory (http://www.fws.gov/wetlands/data/DataDownload.html) - Largest polygon has 1,210,907 vertices.
    * FEMA National Flood Hazard Layer (http://www.msc.fema.gov/webapp/wcs/stores/servlet/info?storeId=10001&catalogId=10001&langId=-1&content=nfhlResources&title=NFHL%20Resources) - Largest polygon has 1,537,698 vertices.
    My current procedure is to load the datasets using ESRI's geometry format, identify the biggies, export the remainder and then reimport them as SDO_GEOMETRY.
    E.g. toss the big polygons away and explain to my clients that Oracle Spatial cannot handle this type of thing.
    My production instances remain on 10g so uber SDO is not yet a possibility but I am trying to think ahead.
    So back to the present. I started with a fresh 11gR2 (no upgrade history) running PSU 11.2.0.1.2 on OpenSUSE on a rather modest machine with two processors and four gig of RAM. I have about 100 gig of Oracle Spatial data on this machine. Basically I ended up running the upgrade script four times of the course of about 5 days, each run required about 30 hours to process. Here are some notes:
    * Make sure you spool the results! The script is quite "verbose" and does not have any error checking so the ALTER TYPE CASCADE part can fail but the script continues recompiling packages and rebuilding all your indexes. This is good in that the system is put back together whether it bombs or not. Bad in that you can waste a lot of time waiting to rerun the script.
    * You need lots of undo! The first time it ran through it appeared to finish and it was not until I looked at the logs did I see that I ran out of undo. I just had a single smallfile undo and it topped out at 32 gig. In the end I created 4 undo datafiles and it appears I needed 100 gig of undo! So I believe you need as much undo as you have SDO_GEOMETRY data. The first thing you want to do afterwards is DESCRIBE MDSYS.SDO_ORDINATE_ARRAY to see if the type was altered. If you see the usual 1048576 then you bombed.
    * Second time through I received an error that I had some spatial indexes in a failed state. Turns out as this is a development box there was an index stuck in "INPROGRS" state due to some flub on my part. This was enough to hose the upgrade. I would suggest folks check for this ahead of time using SELECT * FROM dba_indexes WHERE index_type = 'DOMAIN' AND domidx_status != 'VALID' and drop or rebuild those indexes.
    * Third time through I received the cryptic error
    ERROR at line 1:
    ORA-22324: altered type has compilation errors
    ORA-22332: a dependent object in schema "NAVTEQ_SF" has errors.
    ORA-00600: internal error code, arguments: [qctostiix1], [], [], [], [], [],
    [], [], [], [], [], []I had some sample Navteq data for use with the networking demo I never got functioning. At this point after four days of trying I was getting a bit impatient and just decided to drop that schema and try again. I have no idea why this navteg data caused an issue but the error never happened again with any other datasets.
    * Fourth time through the alter type worked! But the script still crashed with
    ERROR at line 1:
    ORA-00600: internal error code, arguments: [qximgcn1], [], [], [], [], [], [],
    ORA-06512: at line 14After eyeballing the script and the spool file it looks like it failed in the final step where it rebuilds all the spatial indexes. This seems right as I found sixty seven bad spatial indexes afterwards. However, it was easy enough to rebuild those by hand myself (I mean have ArcSDE do so).
    So I call this a success! :)
    So I am looking for anyone else's experiences they'd like to share.
    With the amount of undo required, I think it might be a better route to just use the old school exp to export out all spatial data, run the upgrade and then imp it all back in? Or perhaps just dump out the large tables? Weird 00600 errors cause the DBAs (not part of my organization) that manage my production environment to bleed internally. Ideally I would like to avoid all that pain and suffering. Perhaps just dropping ALL the spatial indexes before the upgrade? I guess I would need to open an SR to see what caused the 00600s. I suspect the indexes.
    So I would like to keep this thread tied to the upgrade process and/or planning/strategy for the upgrade process. There are a lot of other issues that we should start new threads over. For example, exchange of data between standard and uber instances as Dalibor is doing. It sure appears that datapump is never going to work and that only the old-school unsupported imp/exp utility can play this role? I have done some initial testing and ESRI's sdeimport/sdeexport tools seems to work fine between these instances. And none of this even scratches the performance issues.
    So hey Dalibor, I know you went through this. Any comments?
    Cheers!
    Paul

    Hi Mike,
    Nice to hear from you. I would indeed be interested in your thoughts on the upgrade and the actual business case surrounding the upgrade or the decision not to upgrade. I am feeling rather skeptical at this point as the side-effects of the medicine so far are pretty serious. But yet the need to treat the disease remains. You can always drop me an email offline at my first name at my last name dot com or via LinkedIn. The nice things about a super-rare unpronounceable Polish last name is I am easy to find - and that's the bad thing too. Here is an update on my testing.
    Per my earlier SR, the folks are Oracle have provided a backport for bug 10085580 for Linux 32-bit. It looks to work just fine and does the trick - problem solved. If one needs something other than Linux you will need to request the backport for your platform. The bug affects more than SDO_GEORASTER so I would recommend this patch as mandatory.
    Moving along my next issue is that Oracle MapViewer does not seem to work with uber SDO_GEOMETRY.
    MapViewer and uber (Very Large) SDO_GEOMETRY upgrade not compatible?
    This is again a bit of a nonstarter as my client has a couple of applications using MapViewer against production instances. I dutifully submitted an SR on the matter yesterday. Almost to be expected the tech immediately asked why I would want to have such a large geometry and why don't I thin it! :)
    It's no fun being in the middle on these things. I suppose I could ring up FEMA or Fish and Wildlife and tell them Oracle Corporation thinks their polygons are crazy. But as they are ESRI-shop folks, I think they would just be puzzled by the statement. If anyone has an opinion on how to broach the topic nicely with public agencies, I would love to hear it. Do we need to create a "citizens against huge polygons" lobby in DC? Again the ESRI shop folks are smirking.
    The other issue in the thread started by Dalibor where the old imp/exp is erratically failing on the table creation statements is probably going to need an SR too. The work around is to just append the data and create your tables by hand ahead of time. On a more positive note ArcSDE seems utterly oblivious to the type change and I have not found any problems using ESRI tools to move stuff around.
    Cheers,
    Paul

  • Looking for a Great Flex/Flash Engineer

    Hi All,
    Apologies if this isn't an appropriate place for posting such a request, but I'm a long-time user of Adobe Flash and Flex. Despite the uncertainty surrounding the future of Flash and Flex we feel it's still the best platform for delivering rich Internet applications. We're on the hunt for a couple great engineers to join our team, and we're thinking some of you might be on the looking for positions that allow you to leverage your Flash and Flex development talents.
    Information about the UI position is included below. Please check out http://coincident.com for more information about us and to see our other posting(s).
    Thanks!
    -jmh
    President & Founder
    Coincident, Inc.
    User Interface  Engineer
    Coincident. We’d like to  make it a household name but we’re going to need your help! We’re a small clean  energy company in Boston, Massachusetts and we’re developing an  automated energy management platform for residential and small commercial  energy consumers.
    We think it’s a potential  game-changer amongst a sea of competing interests and apparently so does the U.S.  Department of Energy. They’ve backed our engineering efforts with innovation  research grants to help us commercialize our technology.
    We’re on the hunt for a  talented programmer with the ability to fuse design and technology like no  other. You’ll help craft the user interface components that make our energy  management system the most attractive and easy-to-use on the market.  Ease-of-use, visual appeal, and intuitive behavior will be your raison d’être. Bring  a passion for energy efficiency, rich internet applications, consumer  electronics, and mobile development platforms.
    This is a paid full-time position  offering compensation and equity options commensurate with your experience and ability  to make significant contributions to the development of our product.
    If this sounds like a job  you’d love, keep reading to see what we’re looking for.
    Does this sound like you?
    Talent  for developing dynamic and rich Internet applications
    Experience  with Adobe Flash, Flex, HTML 5, and JavaScript
    Versed  in UI development best-practices and supporting technology frameworks
    Knack  for implementing elegant user interface controls and components
    Unparalleled  ability to anticipate user behavior and response to designs
    Ability  to work and collaborate effectively with creative and technical teams
    Experience  integrating web services and Java server-side technologies
    Aptitude  for mastering new technologies in short periods of time
    Ability  to work autonomously on new product features with minimal instruction
    Proficiency  with vector and bitmap graphics libraries, applications, and tools
    Extra  credit for mobile development skills for iOS and Android platforms
    Coincident is located near  South Station in Boston’s Innovation District and is a member company of Greentown Labs, Boston’s first and only clean technology incubator. Resumes and cover letters should be addressed to [email protected].
    United States Citizens and Residents  only, please.

    Another option: I bought a nice one at REI for PWB in March, and now use it for MBP. Has space for my wacom tabet and also small 3x5 or so firewire HD, and of course power adapter and misc stuff. notebook compartment can be removed and carried separately. Very happy with it.
    George

  • Looking for a Template

    New Member
    Posts:  1
    Location:  Ames, IA
    Joined:  11th Dec 2009
    PM
    I'm new to DreamWeaver, but more significant is that this is my first attempt of building a website from scratch. In the past I have used what I would discribe as "Cookie Cutter" applications where about the most exciting thing you can do is fill in the blanks and add a few images. I want to go to the next level where I can be more creative.  I looked and have played around with three programs for the Mac and felt DreamWeaver was the best choice.
    My first attempt is going to be creating a website for a local American Legion Post.  I have a good idea of how I want to approach it from a design standpoint and I'm hoping that I can locate a template that is close to what the picture I have in my head.  The challenge today is going to be describing the design I would like to use, so I guess the best thing to do is to give it a try and hope it makes since to all of you.
    First I need to explain how the American Legion is laid out.  Besides The American Legion Post (TAL) there are sub organizations within the post such as The American Legion Auxiliary (AUX), Sons of American Legion (SAL) and The American Legion Riders (ALR). Each of these groups are tightly intertwined with TAL post, but have specific programs they focus on.  My thought is to have a home page that offers visitors a simple format to accessing all of the information.
    I'm thinking that across the top of the page will be four tabs which when clicked will create a drop down menu showing all of the avaliable pages for each of these groups. obviously each of these pages would focus on events, projects, etc.. of that group.   Down along the left side of the home page would be a series of tabs or buttons that open general pages that contain information on the Post.  Here's an over simplified example:
    Click on the American Legion Riders and a drop down menu appears showing the following pages:
    <American Legion Riders>
         <Welcome>
         <Officers>
         <Chapter History>
         <Event Calendar>
         <Five Star Riders>
         <Star of Excellence>
         <Operation Military Kids>
         <Operation Fiirst Response>
         <Chapter Locator>
         <Membership Requirements>
         <Membership Application>
         <Contact Us>
    Now along the left side of the home page are tabs that will open pages that pertain to the Post:
    <Welcome>
    <Board of Directors>
    <Post History>
    <Post Location>
    <Event Calendar> (events or activities entered into each of the groups calendar would automaticly show up on the Post calendar and each group would be a different color)
    <Post Rental>
    <Rules & Regulations>
    The remainder of the home page would be used to display the latest news, flyers, pictures, etc...
    It would be nice if the template had a patriotic theme; however, a simple color scheme would also work.  I hope I have described what I'm looking for in a manner that is easily understood.  As I mentioned above this is my first attempt at creating a website with a program such as DreamWeaver.  I'm not familiar with all of the technical termology so please be patient with me as I learn.
    I am a Veteran with a service connected disablity and the American Legion has always been there for me, so you will find I am very passionate about what the American Legion stands for and I want this web page to evolve into an easy to navigate site that tells the story of American Legion Post 232 and it's members -past, present and future.
    I am open to other ideas and templates so please feel free to share.  Finally, let me thank everyone in advance for you patience, help and suggestons.  I'm sure I will be on this forum on a very regular basis ask for advice, help and suggestons. With that I wish each of you a very special Holiday Season and please don't forget our young men and women serving and protecting this great nation of ours.
    Oldmanwheeler

    There are some templates that come with InDesign. Click the New From Template button on the splash screen.
    I also found a site with templates:
    http://desktoppub.about.com/od/templatesindesign/Free_Adobe_InDesign_Templates.htm
    But you might want to do it yourself.

  • Looking for iPad App for displaying photos via a projector

    I'm looking for an App that will allow me to display photos using a projector yet permit manual advancing through the slides.
    The included Photo app only works with the projector when in slideshow mode. As soon as I try to manually advance a photo the projector output stops.
    I've seen references to Keynote but I'd rather not have to import 'x' number of photos into Keynote to be able to display them. I'm not convinced Keynote will do what I want anyway.
    There's got to be an app out there somewhere that does this. Isn't there?
    Thanks.

    Locking the iPad so that a user can't exit an app isn't possible for any developer to implement, since the developer kit doesn't provide that sort of access to the low-level routines in iOS. The only way to lock into a single app is to use a case/frame that covers the Home button (and turn off the gesture support in the settings in iOS 5).  A number of companies make kiosk mounts for this purpose.
    Regards.

  • Looking for a howto for an applescript to batch convert PPTS to Keynote...

    Looking for a howto for an applescript to batch convert PPTS to Keynote...
    Hi to group!
    (cross posted this a couple of weeks ago to Keynote forum, no responses) Perhaps the query really belongs here...)
    (I) Have a whole bunch of PPTs to convert to Keynote, now and more as time goes on.
    Looked into applescript to try to automate this a bit (could open PPT file but did not see any way to 'Save' file from a script).
    Also looked into bash scripting/automator too -- way too many options to choose from. Help!
    Anybody done anything similar to this already?
    TIA for pointers. //GH

    A word of caution.
    I have not tried the workflow before.
    I am not an applescript expert.
    These steps were quickly composed using my basic knowledge in Applescript
    What I was planning was to create a script droplet that when a ppt file is dropped upon it, it extracts the name of the file and sets it to a variable to name the keynote file later. You might have to modify it a bit to batch process multiple files.
    Try going through batch processing scripts made for quark or Adobe photoshop ( Not sure if these exist on internet) to see how they have implemented the steps in applescript.
    To GUI Script Keynote, do these steps...
    All the code has to go in here
    <pre title="this text can be pasted into the Script Editor" style="font-family: Monaco, 'Courier New', Courier, monospace; font-size: 10px; padding: 5px; width: 720px; color: #000000; background-color: #E0E0E0; overflow: auto">activate application "Keynote.app"
    tell application "System Events"
       tell process "Keynote"
          -- insert GUI Scripting statements here
       end tell
    end tell
    </pre>
    <pre title="this text can be pasted into the Script Editor" style="font-family: Monaco, 'Courier New', Courier, monospace; font-size: 10px; padding: 5px; width: 720px; color: #000000; background-color: #E0E0E0; overflow: auto">click menu item "Export…"  of menu 1 of menu bar item "File"  of menu bar 1</pre>
    This will click the next.. button provided the default export type is set to PPT
    <pre title="this text can be pasted into the Script Editor" style="font-family: Monaco, 'Courier New', Courier, monospace; font-size: 10px; padding: 5px; width: 720px; color: #000000; background-color: #E0E0E0; overflow: auto">click button 2 of sheet 1 of window 2
    </pre>
    This will click the Export button on the next window
    click button 1 of sheet 1 of window 2
    This piece of code can be used to set the name of the ppt file using the extracted name in the first step
    <pre title="this text can be pasted into the Script Editor" style="font-family: Monaco, 'Courier New', Courier, monospace; font-size: 10px; padding: 5px; width: 720px; color: #000000; background-color: #E0E0E0; overflow: auto">set value of text field 1 of sheet 1 of window 2 to "<string>"
    </pre>
    May be there is a better way out there.
    Thanks for red_menace for his Script formatter script
    Message was edited by: dj9027

  • Looking for sample code of HOW-TO use EntityFacadeImpl class

    I have created the following using JDeveloper Ver 9.0.3.1:
    1. Entity Bean
    Localinterface: userLocal.java
    Local home interface: userLocalHome.java
    Remote interface: user.java
    Remote home interface: userHome.java
    Bean implementation: userBean.java
    2. Facade Session Bean (auto generated by JDeveloper)
    userFacade.xml
    userFacadeColImpl.java
    userFacadeImpl.java
    I am looking for sample client code on how to make use the facade session bean.
    Thanks in advance.

    repost

  • New window manager (with prototype!) [wmii-like] --- looking for help

    I have a prototype for a new window manager in the style of wmii. It is called
    cakewm. I currently have a prototype version implemented in pygame, and would
    like help moving this to use X---making it a real window manager.
    Disclaimer: I have a very limited knowledge of X11 and window manager
    development. The most I've done is add a couple new features to wmfs.
    To get the code
    > git clone git://github.com/saikobee/cakewm.git
    Then run main.py. cakewm depends on pygame.
    Upon running, press Alt-Enter to fullscreen cakewm and intercept keybinds, or
    Alt-Space to just intercept keybinds.  Press Alt-Esc to quit. The window
    manager related keybinds are listed in the file binds.conf.
    Config note: <WSCA-x> means Windows-Shift-Control-Alt-x
    Implementation note: pypixel.py is a large and mostly useless dependency. I
    forked a library I made previously rather than coding straight in pygame.
    cakewm's goals are to be similar to wmii, but with more functionality, easier
    configurability, and saner defaults.
    - cakewm is fully functional using the keyboard. Mouse support can come later.
    - cakewm provides 9 workspaces per monitor.
    - cakewm manages each workspace as a group of columns. Each column is like a
      wmii default split, except each window can have other windows "stacked" on
      top of or behind it.
    - cakewm manages column sizes (and window sizes within columns) using a
      master/slave paradigm, with the ability to adjust the size ratios.
    - cakewm's configuration file is simple key=val pairs, with the ability to
      include other files like in C.
    - cakewm has a slightly larger emphasis on window decorations (adjustable
      size---even in tiled mode) and themes (nothing bloated, like pixmaps or
      gradients---it's all still simple colors).
    - cakewm will have proper support for international text (Japanese text in
      window titles or the wmii status bar generally render as boxes) through the
      use of a more advanced text library such as Pango.
    Please let me know if you have comments, questions, or concerns. If you are
    interested in helping, get in touch with me. If you know somewhere better to
    look for volunteers, please let me know.

    m4co wrote:
    Wow is this forum active. Makes me feel welcome here
    The thing about wireless, I actually like command line, but there are a few things that are worth having a applet or something.
    And wireless is one of those. I guess I can take a look on wicd.
    It's a good idea to have compiz as the WM actually. Would it be lightweight to have it like that?
    Is there anybody here that uses compiz as a WM?
    For the xfce4-panel, is it possible to get transparency on it? That's probably the only thing holding me back with xfce4-panel.
    If "able to run compiz" wasn't a requisite, what other WM would you suggest for my "profile" ?
    I would like to hear other users opinions who like to customize everything on a WM.
    I recommend running Compiz by itself. There is a good wiki page on it in the Arch wiki. Some apps you'll want to go with it are:
    LXAppearance --change GTK/icon theme
    Feh or Nitrogen --Set Wallpaper
    Xfce4-panel --The lightest one that works with Compiz properly
    Or, if you don't want a panel: stalonetray
    Compiz-deskmenu --For a customizable right-click main menu
    Gmrun --Run dialog (Alt+F2 in most DEs)
    And this helped me a lot.
    Thank you all for the replies. I appreciate.
    Xfce4-panel can have transparency.  The only problem is that everything become transparent: text, icons, everything.
    I use Compiz as a standalone WM and it is much lighter than DE+Compiz. My Compiz setup uses about 30MB(out of 1GB) more RAM than my Openbox setup (which are both the same except for the WM).

  • Looking for Simple JSTL Example

    Hi Everyone,
    I'm looking for an example of a simple Web application that uses "JavaServer Pages Standard Tag Library" (JSTL) -- that doesn't use JDeveloper!
    I have OC4J stand-alone 10.1.3.0.0 on Microsoft Windows XP Professional Version 2002 Service Pack2 with JDK 1.5.0_07
    I created and packaged a J2EE application in a EAR file. The EAR file contents:
    META-INF/application.xml
    frstjstl.warContents of "application.xml"
    <?xml version="1.0"?>
    <application
           xmlns="http://java.sun.com/xml/ns/j2ee"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/application_1_4.xsd"
           version="1.4">
      <module>
        <web>
          <web-uri>frstjstl.war</web-uri>
          <context-root>frstjstl</context-root>
        </web>
      </module>
    </application>Contents of "frstjstl.war"
    META-INF/MANIFEST.MF
    index.jsp
    WEB-INF/lib/standard.jar
    WEB-INF/web.xmlContents of "web.xml"
    <?xml version="1.0"?>
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
             version="2.4">
      <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
      </welcome-file-list>
      <jsp-config>
        <taglib>
          <taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>
          <taglib-location>/WEB-INF/lib/standard.jar</taglib-location>
        </taglib>
      </jsp-config>
    </web-app>Contents of "index.jsp"
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <html>
      <head>
        <title>Simplest JSTL</title>
      </head>
      <body>
        &lt;h1>Simplest JSTL</h1>
        <c:forEach var="httpRequestHeaders" items="${headerValues}">
          ${httpRequestHeaders.key} = ${httpRequestHeaders.value}
        </c:forEach>
      </body>
    </html>My JSTL implementation comes from here:
    http://jakarta.apache.org/taglibs/doc/standard-doc/intro.html
    The distribution contains a "standard.jar" file and a "jstl.jar" file (among other things). The "standard.jar" file is included in my WAR (see above) and I have copied the "jstl.jar" file to:
    %J2EE_HOME%\jsp\lib\taglibI launch OC4J from the command prompt like this:
    java -jar oc4j.jarI deploy my EAR using the following command:
    java -jar admin.jar ormi://localhost oc4jadmin xxx -deploy -file frstjstl.ear -deploymentName FirstJSTL -bindWebApp default-web-siteThen I launch my Web browser and enter the following URL:
    http://localhost/frstjstlAnd I get the following error message:
    500 Internal Server Error
    OracleJSP: oracle.jsp.parse.JspParseException: /index.jsp: Line # 8, <c:forEach var="httpRequestHeaders" items="${headerValues}">
    Error: Attribute: items is not a valid attribute nameThanks (for reading),
    Avi.

    Thanks Qiang.
    Yes, when I copy file "index.jsp" to directory "%J2EE_HOME%\default-web-app\testJstl.jsp" it works.
    I use the following URL:
    http://localhost:8888/testJstl.jspAnd this is the output I get:
    [Format modified to be more suitable to post on this forum.]
    Simplest JSTL
    CONNECTION = [Ljava.lang.String;@7348e
    USER-AGENT = [Ljava.lang.String;@10b8d03
    ACCEPT-LANGUAGE = [Ljava.lang.String;@157011e
    ACCEPT-ENCODING = [Ljava.lang.String;@10a8143
    ACCEPT = [Ljava.lang.String;@ac8360 HOST = [Ljava.lang.String;@1e534cb
    [/pre]
    But I guess, since the JSTL related JAR files are part of the default Web application, there is no reason it shouldn't work.
    That's why you said:
    Let us do a sanity test first.So now what?
    (And, by the way, thanks for your help.)
    Cheers,
    Avi.
    Message was edited by:
            Avi Abrami                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • New(?) pattern looking for a good home

    Hi everyone, this is my second post to sun forums about this, I initially asked people for help with the decorator and strategy pattern on the general Java Programming forum not being aware that there was a specific section for design pattern related questions. Since then I refined my solution somewhat and was wondering if anyone here would take a look. Sorry about the length of my post, I know it's best to keep it brief but in this case it just seemed that a fully functional example was more important than keeping it short.
    So what I'd like to ask is whether any of you have seen this pattern before and if so, then what is it called. I'm also looking for some fresh eyes on this, this example I wrote seems to work but there are a lot of subtleties to the problem so any help figuring out if I went wrong anywhere is greatly appreciated. Please do tell me if you think this is an insane approach to the problem -- in short, might this pattern have a chance at finding a good home or should it be put down?
    The intent of the pattern I am giving below is to modify behavior of an object at runtime through composition. In effect, it is like strategy pattern, except that the effect is achieved by wrapping, and wrapping can be done multiple times so the effect is cumulative. Wrapper class is a subclass of the class whose instance is being wrapped, and the change of behavior is accomplished by overriding methods in the wrapper class. After wrapping, the object "mutates" and starts to behave as if it was an instance of the wrapper class.
    Here's the example:
    public class Test {
         public static void main(String[] args) {
              double[] data = { 1, 1, 1, 1 };
              ModifiableChannel ch1 = new ModifiableChannel();
              ch1.fill(data);
              // ch2 shifts ch1 down by 1
              ModifiableChannel ch2 = new DownShiftedChannel(ch1, 1);
              // ch3A shifts ch2 down by 1
              ModifiableChannel ch3A = new DownShiftedChannel(ch2, 1);
              // ch3B shifts ch2 up by 1, tests independence from ch3A
              ModifiableChannel ch3B = new UpShiftedChannel(ch2, 1);
              // ch4 shifts ch3A up by 1, data now looks same as ch2
              ModifiableChannel ch4 = new UpShiftedChannel(ch3A, 1);
              // print channels:
              System.out.println("ch1:");
              printChannel(ch1);
              System.out.println("ch2:");
              printChannel(ch2);
              System.out.println("ch3A:");
              printChannel(ch3A);
              System.out.println("ch3B:");
              printChannel(ch3B);
              System.out.println("ch4:");
              printChannel(ch4);
         public static void printChannel(Channel channel) {
              for(int i = 0; i < channel.size(); i++) {
                   System.out.println(channel.get(i) + "");
              // Note how channel's getAverage() method "sees"
              // the changes that each wrapper imposes on top
              // of the original object.
              System.out.println("avg=" + channel.getAverage());
    * A Channel is a simple container for data that can
    * find its average. Think audio channel or any other
    * kind of sampled data.
    public interface Channel {
         public void fill(double[] data);
         public double get(int i);
         public double getAverage();
         public int size();
    public class DefaultChannel implements Channel {
         private double[] data;
         public void fill(double[] data) {
              this.data = new double[data.length];
              for(int i = 0; i < data.length; i++)
                   this.data[i] = data;
         public double get(int i) {
              if(i < 0 || i >= data.length)
                   throw new IndexOutOfBoundsException("Incorrect index.");
              return data[i];
         public double getAverage() {
              if(data.length == 0) return 0;
              double average = this.get(0);
              for(int i = 1; i < data.length; i++) {
                   average = average * i / (i + 1) + this.get(i) / (i + 1);
              return average;
         public int size() {
              return data.length;
    public class ModifiableChannel extends DefaultChannel {
         protected ChannelModifier modifier;
         public void fill(double[] data) {
              if (modifier != null) {
                   modifier.fill(data);
              } else {
                   super.fill(data);
         public void _fill(double[] data) {
              super.fill(data);
         public double get(int i) {
              if(modifier != null)
                   return modifier.get(i);
              else
                   return super.get(i);
         public double _get(int i) {
              return super.get(i);
         public double getAverage() {
              if (modifier != null) {
                   return modifier.getAverage();
              } else {
                   return super.getAverage();
         public double _getAverage() {
              return super.getAverage();
    public class ChannelModifier extends ModifiableChannel {
         protected ModifiableChannel delegate;
         protected ModifiableChannel root;
         protected ChannelModifier tmpModifier;
         protected boolean doSwap = true;
         private void pre() {
              if(doSwap) { // we only want to swap out modifiers once when the
                   // top call in the chain is made, after that we want to
                   // proceed without it and finally restore doSwap to original
                   // state once ChannelModifier is reached.
                   tmpModifier = root.modifier;
                   root.modifier = this;
                   if(delegate instanceof ChannelModifier)
                        ((ChannelModifier)delegate).doSwap = false;
         private void post() {
              if (doSwap) {
                   root.modifier = tmpModifier;
              } else {
                   if(delegate instanceof ChannelModifier)
                             ((ChannelModifier)delegate).doSwap = true;
         public ChannelModifier(ModifiableChannel delegate) {
              if(delegate instanceof ChannelModifier)
                   this.root = ((ChannelModifier)delegate).root;
              else
                   this.root = delegate;
              this.delegate = delegate;
         public void fill(double[] data) {
              pre();
              if(delegate instanceof ChannelModifier)
                   delegate.fill(data);
              else
                   delegate._fill(data);
              post();
         public double get(int i) {
              pre();
              double result;
              if(delegate instanceof ChannelModifier)
                   result = delegate.get(i);
              else
                   result = delegate._get(i);
              post();
              return result;
         public double getAverage() {
              pre();
              double result;
              if(delegate instanceof ChannelModifier)
                   result = delegate.getAverage();
              else
                   result = delegate._getAverage();
              post();
              return result;
         public int size() {
              //for simplicity no support for modifying size()
              return delegate.size();
    public class DownShiftedChannel extends ChannelModifier {
         private double shift;
         public DownShiftedChannel(ModifiableChannel channel, final double shift) {
              super(channel);
              this.shift = shift;
         @Override
         public double get(int i) {
              return super.get(i) - shift;
    public class UpShiftedChannel extends ChannelModifier {
         private double shift;
         public UpShiftedChannel(ModifiableChannel channel, final double shift) {
              super(channel);
              this.shift = shift;
         @Override
         public double get(int i) {
              return super.get(i) + shift;
    Output:ch1:
    1.0
    1.0
    1.0
    1.0
    avg=1.0
    ch2:
    0.0
    0.0
    0.0
    0.0
    avg=0.0
    ch3A:
    -1.0
    -1.0
    -1.0
    -1.0
    avg=-1.0
    ch3B:
    1.0
    1.0
    1.0
    1.0
    avg=1.0
    ch4:
    0.0
    0.0
    0.0
    0.0
    avg=0.0

    jduprez wrote:
    Hello,
    unless you sell your design better, I deem it is an inferior derivation of the Adapter pattern.
    In the Adapter pattern, the adaptee doesn't have to be designed to support adaptation, and the instance doesn't even know at runtime whether it is adapted.
    Your design makes the "modifiable" class aware of the modification, and it needs to be explicitly designed to be modifiable (in particular this constrains the implementation hierarchy). Overall DesignPattern are meant to provide flexibility, your version offers less flexibility than Adapter, as it poses more constraint on the modifiable class.
    Another sign of this inflexibility is your instanceof checks.
    On an unrelated note, I intensely dislike your naming choice of fill() vs _fill()+, I prefer more explicit names (I cannot provide you one as I didn't understand the purpose of this dual method, which a good name would have avoided, by the way).
    That being said, I haven't followed your original problem, so I am not aware of the constraints that led you to this design.
    Best regards,
    J.
    Edited by: jduprez on Mar 22, 2010 10:56 PMThank you for your input, I will try to explain my design better. First of all, as I understand it the Adapter pattern is meant to translate one interface into another. This is not at all what I am trying to do here, I am trying to keep the same interface but modify behavior of objects through composition. I started thinking about how to do this when I was trying to apply the Decorator pattern to filter some data. The way I would do that in my example here is to write an AbstractChannelDecorator that delegates all methods to the Channel it wraps:
    public abstract class AbstractChannelDecorator implements Channel {
            protected Channel delegate;
    ...// code ommitted
         public double getAverage() {
              return delegate.getAverage();
    ...// code ommitted
    }and then to filter the data I would extend it with concrete classes and override the appropriate methods like so:
    public class DownShiftedChannel extends AbstractChannelDecorator {
         ...// code ommitted
         public double get(int i) {
              return super.get(i) - shift;
           ...// code ommitted
    }(I am just shifting the data here to simplify the examples but a more realistic example would be something like a moving average filter to smooth the data).
    Unfortunately this doesn't get me what I want, because getAverage() method doesn't use the filtered data unless I override it in the concrete decorator, but that means I will have to re-implement the whole algorithm. So that's pretty much my motivation for this, how do I use what on the surface looks like a Decorator pattern, but in reality works more like inheritance?
    Now as to the other points of critique you mentioned:
    I understand your dislike for such method names, I'm sorry about that, I had to come up with some way for the ChannelModifier to call ModifiableChannel's super's method equivalents. I needed some way to have the innermost wrapped object to initiate a call to the topmost ChannelModifier, but only do it once -- that was one way to do it. I suppose I could have done it with a flag and another if/else statement in each of the methods, or if you prefer, the naming convention could have been fill() and super_fill(), get() and super_get(), I didn't really think that it was that important. Anyway, those methods are not meant to be used by any other class except ChannelModifier so I probably should have made them protected.
    The instanceof checks are necessary because at some point ChannelModifier instance runs into a delegate that isn't a ChannelModifier and I have to somehow detect that, because otherwise instead of calling get() I'd call get() which in ModifiableChannel would take me back up to the topmost wrapper and start the whole call chain again, so we'd be in infinite recursion. But calling get() allows me to prevent that and go straight to the original method of the innermost wrapped object.
    I completely agree with you that the example I presented has limited flexibility in supporting multiple implementations. If I had two different Channel implementations I would need two ModifiableChannel classes, two ChannelModifiers, and two sets of concrete implementations -- obviously that's not good. Not to worry though, I found a way around that. Here's what I came up with, it's a modification of my original example with DefaultChannel replaced by ChannelImplementation1,2:
    public class ChannelImplementation1 implements Channel { ... }
    public class ChannelImplementation2 implements Channel { ... }
    // this interface allows implementations to be interchangeable in ChannelModifier
    public interface ModifiableChannel {
         public double super_get(int i);
         public double super_getAverage();
         public void setModifier(ChannelModifier modifier);
         public ChannelModifier getModifier();
    public class ModifiableChannelImplementation1
              extends ChannelImplementation1
              implements ModifiableChannel {
         ... // see DefaultChannel in my original example
    public class ModifiableChannelImplementation2
              extends ChannelImplementation1
              implements ModifiableChannel { ...}
    // ChannelModifier is a Channel, but more importantly, it takes a Channel,
    // not any specific implementation of it, so in effect the user has complete
    // flexibility as to what implementation to use.
    public class ChannelModifier implements Channel {
         protected Channel delegate;
         protected Channel root;
         protected ChannelModifier tmpModifier;
         protected boolean doSwap = true;
         public ChannelModifier(Channel delegate) {
              if(delegate instanceof ChannelModifier)
                   this.root = ((ChannelModifier)delegate).root;
              else
                   this.root = delegate;
              this.delegate = delegate;
         private void pre() {
              if(doSwap) {
                   if(root instanceof ModifiableChannel) {
                        ModifiableChannel root = (ModifiableChannel)this.root;
                        tmpModifier = root.getModifier();
                        root.setModifier(this);
                   if(delegate instanceof ChannelModifier)
                        ((ChannelModifier)delegate).doSwap = false;
         private void post() {
              if (doSwap) {
                   if(root instanceof ModifiableChannel) {
                        ModifiableChannel root = (ModifiableChannel)this.root;
                        root.setModifier(tmpModifier);
              } else {
                   if(delegate instanceof ChannelModifier)
                             ((ChannelModifier)delegate).doSwap = true;
         public void fill(double[] data) {
              delegate.fill(data);
         public double get(int i) {
              pre();
              double result;
              if(delegate instanceof ModifiableChannel)
    // I've changed the naming convention from _get() to super_get(), I think that may help show the intent of the call
                   result = ((ModifiableChannel)delegate).super_get(i);
              else
                   result = delegate.get(i);               
              post();
              return result;
         public double getAverage() {
              pre();
              double result;
              if(delegate instanceof ModifiableChannel)
                   result = ((ModifiableChannel)delegate).super_getAverage();
              else
                   result = delegate.getAverage();
              post();
              return result;
         public int size() {
              return delegate.size();
    public class UpShiftedChannel extends ChannelModifier { ...}
    public class DownShiftedChannel extends ChannelModifier { ... }

Maybe you are looking for

  • How to show skip question again in online exam application

    Hello Everybody...! Now i want to put Skip functionality in my online examination system. I am having two button in my exam page one is Submit and second one is Skip.when user click on skip button he must get next question here user have 100 question

  • Simple button action that goes to a page within the same doc

    I can't figure this out. I have a button I want to use that takes a person back to the first, or second page of the same doc. It's a catalog section with a table of contents. I need to make links for the pdf that takes people to certain pages within

  • Keywords not working correctly

    I've spent a couple of days adding keywords to my project in FCP X but I'm wondering whether it's been a waste of time because now, the wrong clips are appearing when I click a keyword collection in the browser. The keywords are to do with training a

  • MPLS Load Balancing/Sharing with TE or CEF or Both?

    So I am just playing around in GNS3 trying to set up multiple ECMP links between to P routers like this; CE1 -- PE1 -- P1 == P2 -- PE2 -- CE2 (There are actually four links between P1 & P2!) I have set up a pseudoswire xconnect from PE1 to PE2 so CE1

  • Suddenly can't activate adobe flash on some websites.

    Suddenly can't activate adobe flash on websites I regularly visit (colbertreport.cc.com, acorn.tv) on my iMac running 10.6.8. Works fine on youtube.com and other sites I visit, like billmoyers.com.