/**
  * Removes the last returned element from the child iterator that
  * produced it.
  *
  * @throws IllegalStateException if there is no last returned element,
  *  or if the last returned element has already been removed
  */
 public virtual void remove()
 {
     if (lastReturned == -1)
     {
         throw new java.lang.IllegalStateException("No value can be removed at present");
     }
     java.util.Iterator <Object> it = (java.util.Iterator <Object>)(iterators.get(lastReturned));
     it.remove();
 }
 /// <summary>Creates a new instance of a XML Serializer.</summary>
 /// <remarks>
 /// Creates a new instance of a XML Serializer.
 /// <p><b>NOTE:</b> factory features are not used for XML Serializer.
 /// </remarks>
 /// <returns>A new instance of a XML Serializer.</returns>
 /// <exception cref="XmlPullParserException">
 /// if a parser cannot be created which satisfies the
 /// requested configuration.
 /// </exception>
 /// <exception cref="org.xmlpull.v1.XmlPullParserException"></exception>
 public virtual org.xmlpull.v1.XmlSerializer newSerializer()
 {
     if (serializerClasses == null)
     {
         throw new org.xmlpull.v1.XmlPullParserException("Factory initialization incomplete - has not tried "
                                                         + classNamesLocation);
     }
     if (serializerClasses.size() == 0)
     {
         throw new org.xmlpull.v1.XmlPullParserException("No valid serializer classes found in "
                                                         + classNamesLocation);
     }
     java.lang.StringBuilder issues = new java.lang.StringBuilder();
     {
         for (int i = 0; i < serializerClasses.size(); i++)
         {
             System.Type ppClass = (System.Type)serializerClasses.get(i);
             try
             {
                 org.xmlpull.v1.XmlSerializer ser = (org.xmlpull.v1.XmlSerializer)System.Activator.CreateInstance
                                                        (ppClass);
                 return(ser);
             }
             catch (System.Exception ex)
             {
                 issues.append(ppClass.FullName + ": " + ex.ToString() + "; ");
             }
         }
     }
     throw new org.xmlpull.v1.XmlPullParserException("could not create serializer: " +
                                                     issues);
 }
Esempio n. 3
0
        /*
         * Returns a string containing a concise, human-readable description of this
         * {@code PermissionCollection}.
         *
         * @return a printable representation for this {@code PermissionCollection}.
         */
        public override String ToString()
        {
            java.util.ArrayList <String>       elist  = new java.util.ArrayList <String>(100);
            java.util.Enumeration <Permission> elenum = elements();
            String superStr    = base.ToString();
            int    totalLength = superStr.length() + 5;

            if (elenum != null)
            {
                while (elenum.hasMoreElements())
                {
                    String el = elenum.nextElement().toString();
                    totalLength += el.length();
                    elist.add(el);
                }
            }
            int esize = elist.size();

            totalLength += esize * 4;
            java.lang.StringBuilder result = new java.lang.StringBuilder(totalLength).append(superStr)
                                             .append(" ("); //$NON-NLS-1$
            for (int i = 0; i < esize; i++)
            {
                result.append("\n ").append(elist.get(i).toString()); //$NON-NLS-1$
            }
            return(result.append("\n)\n").toString());                //$NON-NLS-1$
        }
Esempio n. 4
0
        static void Main()
        {
            java.util.ArrayList <int> primeNumbers = new java.util.ArrayList <int>();
            primeNumbers.add(1);
            primeNumbers.add(2);
            primeNumbers.add(3);
            primeNumbers.add(5);
            primeNumbers.add(7);

            java.lang.SystemJ.outJ.println("Work with all collection elements");

            java.lang.SystemJ.outJ.println("Using collection with for loop");
            for (int i = 0; i < primeNumbers.size(); i++)
            {
                java.lang.SystemJ.outJ.println(primeNumbers.get(i));
            }

            java.lang.SystemJ.outJ.println("Using collection with iterator while loop");
            java.util.Iterator <int> it = primeNumbers.iterator();
            while (it.hasNext())
            {
                java.lang.SystemJ.outJ.println(it.next());
            }

            java.lang.SystemJ.outJ.println("Using Java collection with .NET foreach loop");
            foreach (int prime in primeNumbers)
            {
                java.lang.SystemJ.outJ.println(prime);
            }

            java.lang.SystemJ.outJ.print("");
        }
Esempio n. 5
0
 protected internal override void onDraw(android.graphics.Canvas canvas)
 {
     android.graphics.drawable.Drawable drawable = mHorizontalDivider;
     if (drawable != null)
     {
         // If we have a horizontal divider to draw, draw it at the remembered positions
         java.util.ArrayList <android.graphics.Rect> rects = mHorizontalDividerRects;
         {
             for (int i = rects.size() - 1; i >= 0; i--)
             {
                 drawable.setBounds(rects.get(i));
                 drawable.draw(canvas);
             }
         }
     }
     drawable = mVerticalDivider;
     if (drawable != null)
     {
         // If we have a vertical divider to draw, draw it at the remembered positions
         java.util.ArrayList <android.graphics.Rect> rects = mVerticalDividerRects;
         {
             for (int i = rects.size() - 1; i >= 0; i--)
             {
                 drawable.setBounds(rects.get(i));
                 drawable.draw(canvas);
             }
         }
     }
 }
Esempio n. 6
0
 public override void initializeInvalidateRegion(int left, int top, int right, int
                                                 bottom)
 {
     android.graphics.RectF region = mPreviousRegion;
     region.set(left, top, right, bottom);
     region.inset(-1.0f, -1.0f);
     if (mFillBefore)
     {
         int count = mAnimations.size();
         java.util.ArrayList <android.view.animation.Animation> animations = mAnimations;
         android.view.animation.Transformation temp = mTempTransformation;
         android.view.animation.Transformation previousTransformation = mPreviousTransformation;
         {
             for (int i = count - 1; i >= 0; --i)
             {
                 android.view.animation.Animation a = animations.get(i);
                 temp.clear();
                 android.view.animation.Interpolator interpolator = a.mInterpolator;
                 a.applyTransformation(interpolator != null ? interpolator.getInterpolation(0.0f) :
                                       0.0f, temp);
                 previousTransformation.compose(temp);
             }
         }
     }
 }
Esempio n. 7
0
        static void Main()
        {
            java.util.ArrayList<int> primeNumbers = new java.util.ArrayList<int>();
            primeNumbers.add(1);
            primeNumbers.add(2);
            primeNumbers.add(3);
            primeNumbers.add(5);
            primeNumbers.add(7);

            java.lang.SystemJ.outJ.println("Work with all collection elements");

            java.lang.SystemJ.outJ.println("Using collection with for loop");
            for (int i = 0; i < primeNumbers.size(); i++)
                java.lang.SystemJ.outJ.println(primeNumbers.get(i));

            java.lang.SystemJ.outJ.println("Using collection with iterator while loop");
            java.util.Iterator<int> it = primeNumbers.iterator();
            while (it.hasNext())
                java.lang.SystemJ.outJ.println(it.next());

            java.lang.SystemJ.outJ.println("Using Java collection with .NET foreach loop");
            foreach (int prime in primeNumbers)
                java.lang.SystemJ.outJ.println(prime);

            java.lang.SystemJ.outJ.print("");
        }
Esempio n. 8
0
 /**
  * Constructs a new MultiRectArea and append rectangle from array
  */
 public MultiRectArea(java.util.ArrayList <java.awt.Rectangle> buf)
     : this()
 {
     for (int i = 0; i < buf.size(); i++)
     { //Basties note: also foreach available...
         add(buf.get(i));
     }
 }
Esempio n. 9
0
 public virtual bool removeHeader(android.view.View v)
 {
     {
         for (int i = 0; i < mHeaderViewInfos.size(); i++)
         {
             android.widget.ListView.FixedViewInfo info = mHeaderViewInfos.get(i);
             if (info.view == v)
             {
                 mHeaderViewInfos.remove(i);
                 mAreAllFixedViewsSelectable = areAllListInfosSelectable(mHeaderViewInfos) && areAllListInfosSelectable
                                                   (mFooterViewInfos);
                 return(true);
             }
         }
     }
     return(false);
 }
Esempio n. 10
0
 internal override android.widget.Filter.FilterResults performFiltering(java.lang.CharSequence
                                                                        prefix)
 {
     android.widget.Filter.FilterResults results = new android.widget.Filter.FilterResults
                                                       ();
     if (this._enclosing.mUnfilteredData == null)
     {
         this._enclosing.mUnfilteredData = new java.util.ArrayList <java.util.Map <string, object
                                                                                   > >(this._enclosing.mData);
     }
     if (prefix == null || prefix.Length == 0)
     {
         java.util.ArrayList <java.util.Map <string, object> > list = this._enclosing.mUnfilteredData;
         results.values = list;
         results.count  = list.size();
     }
     else
     {
         string prefixString = prefix.ToString().ToLower();
         java.util.ArrayList <java.util.Map <string, object> > unfilteredValues = this._enclosing
                                                                                  .mUnfilteredData;
         int count = unfilteredValues.size();
         java.util.ArrayList <java.util.Map <string, object> > newValues = new java.util.ArrayList
                                                                           <java.util.Map <string, object> >(count);
         {
             for (int i = 0; i < count; i++)
             {
                 java.util.Map <string, object> h = unfilteredValues.get(i);
                 if (h != null)
                 {
                     int len = this._enclosing.mTo.Length;
                     {
                         for (int j = 0; j < len; j++)
                         {
                             string   str       = (string)h.get(this._enclosing.mFrom[j]);
                             string[] words     = XobotOS.Runtime.Util.SplitStringRegex(str, " ");
                             int      wordCount = words.Length;
                             {
                                 for (int k = 0; k < wordCount; k++)
                                 {
                                     string word = words[k];
                                     if (word.ToLower().StartsWith(prefixString))
                                     {
                                         newValues.add(h);
                                         break;
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         results.values = newValues;
         results.count  = newValues.size();
     }
     return(results);
 }
        public List <double> testMLPUsingWeka(string[] attributeArray, string[] classNames, double[] dataValues, string classHeader, string defaultclass, string modelName, int hiddelLayers = 7, double learningRate = 0.03, double momentum = 0.4, int decimalPlaces = 2, int trainingTime = 1000)
        {
            java.util.ArrayList classLabel = new java.util.ArrayList();
            foreach (string className in classNames)
            {
                classLabel.Add(className);
            }
            weka.core.Attribute classHeaderName = new weka.core.Attribute(classHeader, classLabel);

            java.util.ArrayList attributeList = new java.util.ArrayList();
            foreach (string attribute in attributeArray)
            {
                weka.core.Attribute newAttribute = new weka.core.Attribute(attribute);
                attributeList.Add(newAttribute);
            }
            attributeList.add(classHeaderName);
            weka.core.Instances data = new weka.core.Instances("TestInstances", attributeList, 0);
            data.setClassIndex(data.numAttributes() - 1);
            // Set instance's values for the attributes
            weka.core.Instance inst_co = new DenseInstance(data.numAttributes());
            for (int i = 0; i < data.numAttributes() - 1; i++)
            {
                inst_co.setValue(i, dataValues.ElementAt(i));
            }

            inst_co.setValue(classHeaderName, defaultclass);
            data.add(inst_co);

            java.io.File path = new java.io.File("/models/");
            weka.classifiers.functions.MultilayerPerceptron clRead = loadModel(modelName, path);
            clRead.setHiddenLayers(hiddelLayers.ToString());
            clRead.setLearningRate(learningRate);
            clRead.setMomentum(momentum);
            clRead.setNumDecimalPlaces(decimalPlaces);
            clRead.setTrainingTime(trainingTime);
            weka.filters.Filter myRandom = new weka.filters.unsupervised.instance.Randomize();
            myRandom.setInputFormat(data);
            data = weka.filters.Filter.useFilter(data, myRandom);
            double classValue = clRead.classifyInstance(data.get(0));

            double[]      predictionDistribution  = clRead.distributionForInstance(data.get(0));
            List <double> predictionDistributions = new List <double>();

            for (int predictionDistributionIndex = 0;
                 predictionDistributionIndex < predictionDistribution.Count();
                 predictionDistributionIndex++)
            {
                string classValueString1 = classLabel.get(predictionDistributionIndex).ToString();
                double prob = predictionDistribution[predictionDistributionIndex] * 100;
                predictionDistributions.Add(prob);
            }
            List <double> prediction = new List <double>();

            prediction.Add(classValue);
            prediction.AddRange(predictionDistributions);
            return(prediction);
        }
        /**
         * Returns the next ordered element from a child iterator.
         *
         * @return the next ordered element
         * @throws NoSuchElementException if no child iterator has any more elements
         */
        public virtual Object next()
        {// throws NoSuchElementException {
            if (hasNext() == false)
            {
                throw new java.util.NoSuchElementException();
            }
            int leastIndex = least();

            if (leastIndex == -1)
            {
                throw new java.util.NoSuchElementException();
            }
            else
            {
                Object val = values.get(leastIndex);
                clear(leastIndex);
                lastReturned = leastIndex;
                return(val);
            }
        }
Esempio n. 13
0
 public override void scaleCurrentDuration(float scale)
 {
     java.util.ArrayList <android.view.animation.Animation> animations = mAnimations;
     int count = animations.size();
     {
         for (int i = 0; i < count; i++)
         {
             animations.get(i).scaleCurrentDuration(scale);
         }
     }
 }
Esempio n. 14
0
 public override object getItem(int position)
 {
     java.util.ArrayList <*****@*****.**> items = this._enclosing
                                                                            .mOverflowOnly ? this.mAdapterMenu.getNonActionItems() : this.mAdapterMenu.getVisibleItems
                                                                                ();
     if (this.mExpandedIndex >= 0 && position >= this.mExpandedIndex)
     {
         position++;
     }
     return(items.get(position));
 }
Esempio n. 15
0
 public override object getItem(int position)
 {
     java.util.ArrayList <*****@*****.**> items = this._enclosing
                                                                            .mMenu.getNonActionItems();
     position += this._enclosing.mItemIndexOffset;
     if (this.mExpandedIndex >= 0 && position >= this.mExpandedIndex)
     {
         position++;
     }
     return(items.get(position));
 }
Esempio n. 16
0
 public override void restrictDuration(long durationMillis)
 {
     base.restrictDuration(durationMillis);
     java.util.ArrayList <android.view.animation.Animation> animations = mAnimations;
     int count = animations.size();
     {
         for (int i = 0; i < count; i++)
         {
             animations.get(i).restrictDuration(durationMillis);
         }
     }
 }
 /**
  * Returns <code>true</code> iff any {@link Iterator}
  * in the given list has a next value.
  */
 private bool anyHasNext(java.util.ArrayList <Object> iters)
 {
     for (int i = 0; i < iters.size(); i++)
     {
         java.util.Iterator <Object> it = (java.util.Iterator <Object>)iters.get(i);
         if (it.hasNext())
         {
             return(true);
         }
     }
     return(false);
 }
Esempio n. 18
0
        /// <summary>
        /// Converts arraylist of java.lang.Integer to a list of integers
        /// </summary>
        /// <param name="javaIntList">arraylist to convert</param>
        /// <returns>the list of integers</returns>
        public static List <int> ToIntList(java.util.ArrayList javaIntList)
        {
            List <int> intList = new List <int>();

            for (int i = 0; i < javaIntList.size(); i++)
            {
                int convertBabySequencer = 0;
                Int32.TryParse(javaIntList.get(i).ToString(), out convertBabySequencer);
                intList.Add(convertBabySequencer);
            }
            return(intList);
        }
Esempio n. 19
0
        public string testEmotionUsingWeka(string[] attributeArray, string[] classNames, double[] dataValues, string classHeader, string defaultclass, string modelName, int hiddelLayers = 7, double learningRate = 0.03, double momentum = 0.4, int decimalPlaces = 2, int trainingTime = 1000)
        {
            List <double> predictions = testMLPUsingWeka(attributeArray, classNames, dataValues, classHeader, defaultclass, modelName, hiddelLayers, learningRate, momentum, decimalPlaces, trainingTime);

            java.util.ArrayList classLabel = new java.util.ArrayList();
            foreach (string className in classNames)
            {
                classLabel.Add(className);
            }
            string classValueString = classLabel.get(Int32.Parse(predictions.ElementAt(0).ToString())).ToString();

            return(classValueString);
        }
Esempio n. 20
0
        public override void setStartTime(long startTimeMillis)
        {
            base.setStartTime(startTimeMillis);
            int count = mAnimations.size();

            java.util.ArrayList <android.view.animation.Animation> animations = mAnimations;
            {
                for (int i = 0; i < count; i++)
                {
                    android.view.animation.Animation a = animations.get(i);
                    a.setStartTime(startTimeMillis);
                }
            }
        }
Esempio n. 21
0
 /// <summary>Starts all animations added since the last call to this function.</summary>
 /// <remarks>
 /// Starts all animations added since the last call to this function.  Used to synchronize
 /// animations.
 /// </remarks>
 /// <param name="listener">
 /// an optional listener to add to the animations. Typically used to know when
 /// to invalidate the surface these are being drawn to.
 /// </param>
 public virtual void startAnimations(android.animation.ValueAnimator.AnimatorUpdateListener
                                     listener)
 {
     {
         for (int i = 0; i < mNeedToStart.size(); i++)
         {
             android.animation.ObjectAnimator anim = mNeedToStart.get(i);
             anim.addUpdateListener(listener);
             anim.addListener(this);
             anim.start();
         }
     }
     mNeedToStart.clear();
 }
Esempio n. 22
0
        public override void setSelectedNavigationItem(int position)
        {
            switch (mActionView.getNavigationMode())
            {
            case NAVIGATION_MODE_TABS:
            {
                selectTab(mTabs.get(position));
                break;
            }

            case NAVIGATION_MODE_LIST:
            {
                mActionView.setDropdownSelectedPosition(position);
                break;
            }

            default:
            {
                throw new System.InvalidOperationException("setSelectedNavigationIndex not valid for current navigation mode"
                                                           );
            }
            }
        }
Esempio n. 23
0
 public virtual void dispatchMenuVisibilityChanged(bool isVisible)
 {
     if (isVisible == mLastMenuVisibility)
     {
         return;
     }
     mLastMenuVisibility = isVisible;
     int count = mMenuVisibilityListeners.size();
     {
         for (int i = 0; i < count; i++)
         {
             mMenuVisibilityListeners.get(i).onMenuVisibilityChanged(isVisible);
         }
     }
 }
Esempio n. 24
0
        //
        // DiscardInstance
        //

        public static void DiscardInstance(SoundEffectInstance discardInstance, SoundEffect discardEffect)
        {
            if (instancesLock.isHeldByCurrentThread())
            {
                return;
            }
            try
            {
                instancesLock.@lock();
                for (int idx = instancesList.size(); idx-- > 0;)
                {
                    var instRef = ([email protected])instancesList.get(idx);
                    var inst    = (SoundEffectInstance)instRef.get();
                    if (inst == discardInstance || inst == null || inst.ShouldDiscard(discardEffect))
                    {
                        instancesList.remove(idx);
                    }
                }
            }
            finally
            {
                instancesLock.unlock();
            }
        }
Esempio n. 25
0
        public override long getStartTime()
        {
            long startTime = long.MaxValue;
            int  count     = mAnimations.size();

            java.util.ArrayList <android.view.animation.Animation> animations = mAnimations;
            {
                for (int i = 0; i < count; i++)
                {
                    android.view.animation.Animation a = animations.get(i);
                    startTime = System.Math.Min(startTime, a.getStartTime());
                }
            }
            return(startTime);
        }
Esempio n. 26
0
 public virtual void setGroupVisible(int group, bool visible)
 {
     java.util.ArrayList <*****@*****.**> items = mItems;
     int itemCount = items.size();
     {
         for (int i = 0; i < itemCount; i++)
         {
             [email protected] item = items.get(i);
             if (item.getGroupId() == group)
             {
                 item.setVisible(visible);
             }
         }
     }
 }
Esempio n. 27
0
 public virtual void setGroupCheckable(int group, bool checkable, bool exclusive)
 {
     java.util.ArrayList <*****@*****.**> items = mItems;
     int itemCount = items.size();
     {
         for (int i = 0; i < itemCount; i++)
         {
             [email protected] item = items.get(i);
             if (item.getGroupId() == group)
             {
                 item.setCheckable(checkable);
                 item.setExclusiveCheckable(exclusive);
             }
         }
     }
 }
Esempio n. 28
0
        public virtual bool hasVisibleItems()
        {
            java.util.ArrayList <*****@*****.**> items = mItems;
            int itemCount = items.size();

            {
                for (int i = 0; i < itemCount; i++)
                {
                    if (items.get(i).isVisible())
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Esempio n. 29
0
        private int findItemIndex(int id)
        {
            java.util.ArrayList <*****@*****.**> items = mItems;
            int itemCount = items.size();

            {
                for (int i = 0; i < itemCount; i++)
                {
                    if (items.get(i).getItemId() == id)
                    {
                        return(i);
                    }
                }
            }
            return(-1);
        }
Esempio n. 30
0
 /// <hide></hide>
 internal virtual void restoreChildrenStartOffset()
 {
     long[] offsets = mStoredOffsets;
     if (offsets == null)
     {
         return;
     }
     java.util.ArrayList <android.view.animation.Animation> children = mAnimations;
     int count = children.size();
     {
         for (int i = 0; i < count; i++)
         {
             children.get(i).setStartOffset(offsets[i]);
         }
     }
 }
Esempio n. 31
0
 public LanguageResult(string languageCode, java.util.ArrayList probabilities)
 {
     Probabilities     = new List <Tuple <string, double> >();
     this.LanguageCode = languageCode;
     for (int i = 0; i < probabilities.size(); ++i)
     {
         string[] values = probabilities.get(i).ToString().Split(':');
         if (values.Length == 2 &&
             values[0].Length > 0 &&
             values[1].Length > 0)
         {
             Probabilities.Add(new Tuple <string, double>(values[0],
                                                          double.Parse(values[1],
                                                                       System.Globalization.NumberStyles.Any,
                                                                       System.Globalization.CultureInfo.InvariantCulture)));
         }
     }
 }
Esempio n. 32
0
        static void Main(string[] args)
        {
            bool mergedOutput = true;

            string projectDir = System.IO.Directory.GetParent(
                System.IO.Directory.GetParent(
                Environment.CurrentDirectory.ToString()).ToString()).ToString() + "\\";

            string saveToPathPrefix = projectDir + @"OUT_MailMergeField";

            // Programmatically configure Common Logging
            // (alternatively, you could do it declaratively in app.config)
            NameValueCollection commonLoggingproperties = new NameValueCollection();
            commonLoggingproperties["showDateTime"] = "false";
            commonLoggingproperties["level"] = "INFO";
            LogManager.Adapter = new Common.Logging.Simple.ConsoleOutLoggerFactoryAdapter(commonLoggingproperties);


            ILog log = LogManager.GetCurrentClassLogger();
            log.Info("Hello from Common Logging");

            // Necessary, if slf4j-api and slf4j-NetCommonLogging are separate DLLs
            ikvm.runtime.Startup.addBootClassPathAssembly(
                System.Reflection.Assembly.GetAssembly(
                    typeof(org.slf4j.impl.StaticLoggerBinder)));

            // Configure to find docx4j.properties
            // .. add as URL the dir containing docx4j.properties (not the file itself!)
            Plutext.PropertiesConfigurator.setDocx4jPropertiesDir(projectDir + @"src\samples\resources\");


            // Create a docx4j docx
            WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
            org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart documentPart = wordMLPackage.getMainDocumentPart();
            documentPart.addObject(addParagraphWithMergeField("Hallo, MERGEFORMAT: ", " MERGEFIELD  kundenname  \\* MERGEFORMAT ", "«Kundenname»"));
            documentPart.addObject(addParagraphWithMergeField("Hallo, lower: ", " MERGEFIELD  kundenname  \\* Lower ", "«Kundenname»"));
            documentPart.addObject(addParagraphWithMergeField("Hallo, firstcap: ", " MERGEFIELD  kundenname  \\* FirstCap MERGEFORMAT ", "«Kundenname»"));
            documentPart.addObject(addParagraphWithMergeField("Hallo, random case: ", " MERGEFIELD  KunDenName  \\* MERGEFORMAT ", "«Kundenname»"));
            documentPart.addObject(addParagraphWithMergeField("Hallo, all caps: ", " MERGEFIELD  KUNDENNAME  \\* Upper MERGEFORMAT ", "«Kundenname»"));
            // " MERGEFIELD  yourdate \@ &quot;dddd, MMMM dd, yyyy&quot; "
            //documentPart.addObject(addParagraphWithMergeField("Date example", " MERGEFIELD  yourdate \\@ 'dddd, MMMM dd, yyyy' ", "«Kundenname»")); // FIXME .. doesn't work via .NET.  Why?
            documentPart.addObject(addParagraphWithMergeField("Number example: ", " MERGEFIELD  yournumber \\# $#,###,###  ", "«Kundenname»"));

            // .. or alternatively, load existing
            //string template = @"C:\Users\jharrop\Documents\tmp-test-docx\HelloWorld.docx";
            //WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage
            //        .load(new java.io.File(template));

            //Console.WriteLine(documentPart.getXML());

		java.util.List data = new java.util.ArrayList();
            // TODO: make more .NET friendly

		// Instance 1
		java.util.Map map = new java.util.HashMap();
		map.put( new DataFieldName("KundenNAme"), "Daffy duck");
		map.put( new DataFieldName("Kundenname"), "Plutext");
		map.put(new DataFieldName("Kundenstrasse"), "Bourke Street");
		// To get dates right, make sure you have docx4j property docx4j.Fields.Dates.DateFormatInferencer.USA
		// set to true or false as appropriate.  It defaults to non-US.
		map.put(new DataFieldName("yourdate"), "15/4/2013");  
		map.put(new DataFieldName("yournumber"), "2456800");
		data.add(map);
				
		// Instance 2
		map = new java.util.HashMap();
		map.put( new DataFieldName("Kundenname"), "Jason");
		map.put(new DataFieldName("Kundenstrasse"), "Collins Street");
		map.put(new DataFieldName("yourdate"), "12/10/2013");
		map.put(new DataFieldName("yournumber"), "1234800");
		data.add(map);		
		
		
		if (mergedOutput) {
			/*
			 * This is a "poor man's" merge, which generates the mail merge  
			 * results as a single docx, and just hopes for the best.
			 * Images and hyperlinks should be ok. But numbering 
			 * will continue, as will footnotes/endnotes.
			 *  
			 * If your resulting documents aren't opening in Word, then
			 * you probably need MergeDocx to perform the merge.
			 */

			// How to treat the MERGEFIELD, in the output?
			org.docx4j.model.fields.merge.MailMerger.setMERGEFIELDInOutput(org.docx4j.model.fields.merge.MailMerger.OutputField.KEEP_MERGEFIELD);
			
//			log.Debug(XmlUtils.marshaltoString(wordMLPackage.getMainDocumentPart().getJaxbElement(), true, true));
			
			WordprocessingMLPackage output = org.docx4j.model.fields.merge.MailMerger.getConsolidatedResultCrude(wordMLPackage, data, true);
			
//			log.Info(XmlUtils.marshaltoString(output.getMainDocumentPart().getJaxbElement(), true, true));
			
            SaveFromJavaUtils.save(output, saveToPathPrefix + ".docx");
			
		} else {
			// Need to keep thane MERGEFIELDs. If you don't, you'd have to clone the docx, and perform the
			// merge on the clone.  For how to clone, see the MailMerger code, method getConsolidatedResultCrude
			org.docx4j.model.fields.merge.MailMerger.setMERGEFIELDInOutput(org.docx4j.model.fields.merge.MailMerger.OutputField.KEEP_MERGEFIELD);


            for (int i = 0; i < data.size(); i++ )
            {
                java.util.Map thismap = (java.util.Map)data.get(i);
                org.docx4j.model.fields.merge.MailMerger.performMerge(wordMLPackage, thismap, true);
                SaveFromJavaUtils.save(wordMLPackage, saveToPathPrefix +  "_" + i + ".docx");
            }			
		}
        log.Info("Done! Saved to " + saveToPathPrefix);

        }
Esempio n. 33
0
            //UPGRADE_TODO: The equivalent of method 'java.lang.Thread.run' is not an override method. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1143"'
            //UPGRADE_NOTE: Synchronized keyword was removed from method 'run'. Lock expression was added. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1027"'
            /// <summary> Simply runs the ChannelListener and lets it process Events.
            /// </summary>
            public override void Run()
            {
                lock (this)
                {
                    List msgEvents = new ArrayList();
                    bool printPrompt = false;

                    while (Enclosing_Instance.running)
                    {
                        Enclosing_Instance.channel.fillEventList(msgEvents);
                        if (!msgEvents.isEmpty())
                        {
                            Enclosing_Instance.stopTimer();
                            System.Text.StringBuilder buffer = new System.Text.StringBuilder();
                            for (int idx = 0; idx < msgEvents.size(); idx++)
                            {
                                MessageEvent event_Renamed = (MessageEvent) msgEvents.get(idx);
                                if (event_Renamed.Type == MessageEvent.PARSE_ERROR || event_Renamed.Type == MessageEvent.ERROR || event_Renamed.Type == MessageEvent.RESULT)
                                {

                                    printPrompt = true;
                                    Enclosing_Instance.lastIncompleteCommand = new System.Text.StringBuilder();
                                }
                                if (event_Renamed.Type == MessageEvent.ERROR)
                                {
                                    //UPGRADE_ISSUE: Method 'java.lang.System.getProperty' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javalangSystemgetProperty_javalangString"'
                                    buffer.Append(exceptionToString((System.Exception) event_Renamed.Message).Trim() + System.getProperty("line.separator"));
                                }
                                //UPGRADE_TODO: The equivalent in .NET for method 'java.Object.toString' may return a different value. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1043"'
                                if (event_Renamed.Type != MessageEvent.COMMAND && !event_Renamed.Message.ToString().Equals("") && !event_Renamed.Message.Equals(Constants.NIL_SYMBOL))
                                {
                                    //UPGRADE_TODO: The equivalent in .NET for method 'java.Object.toString' may return a different value. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1043"'
                                    //UPGRADE_ISSUE: Method 'java.lang.System.getProperty' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javalangSystemgetProperty_javalangString"'
                                    buffer.Append(event_Renamed.Message.ToString().Trim() + System.getProperty("line.separator"));
                                }
                            }
                            msgEvents.clear();
                            Enclosing_Instance.hideCursor();
                            Enclosing_Instance.printMessage(buffer.ToString().Trim(), true);
                            if (printPrompt)
                            {
                                Enclosing_Instance.printPrompt();
                                Enclosing_Instance.moveCursorTo(Enclosing_Instance.lastPromptIndex);
                            }
                            Enclosing_Instance.showCursor();
                            printPrompt = false;
                            Enclosing_Instance.startTimer();
                        }
                        else
                        {
                            try
                            {
                                System.Threading.Thread.Sleep(new System.TimeSpan(10000 * 10));
                            }
                            catch (System.Threading.ThreadInterruptedException e)
                            {
                                // Can be ignored
                            }
                        }
                    }
                    try
                    {
                        Enclosing_Instance.outWriter.Close();
                    }
                    catch (System.IO.IOException e)
                    {
                        // we silently ignore it
                        SupportClass.WriteStackTrace(e, Console.Error);
                    }
                    Enclosing_Instance.gui.Engine.MessageRouter.closeChannel(Enclosing_Instance.channel);
                }
            }
Esempio n. 34
0
 /**
  * Returns a string containing a concise, human-readable description of this
  * {@code PermissionCollection}.
  *
  * @return a printable representation for this {@code PermissionCollection}.
  */
 public override String ToString()
 {
     java.util.ArrayList<String> elist = new java.util.ArrayList<String>(100);
     java.util.Enumeration<Permission> elenum = elements();
     String superStr = base.ToString();
     int totalLength = superStr.length() + 5;
     if (elenum != null)
     {
         while (elenum.hasMoreElements())
         {
             String el = elenum.nextElement().toString();
             totalLength += el.length();
             elist.add(el);
         }
     }
     int esize = elist.size();
     totalLength += esize * 4;
     java.lang.StringBuilder result = new java.lang.StringBuilder(totalLength).append(superStr)
         .append(" ("); //$NON-NLS-1$
     for (int i = 0; i < esize; i++)
     {
         result.append("\n ").append(elist.get(i).toString()); //$NON-NLS-1$
     }
     return result.append("\n)\n").toString(); //$NON-NLS-1$
 }