Spring Batch configuration Formatter Conversion change - printf

I have an Item Writer as below:
<beans:property name="lineAggregator">
<beans:bean class="org.spring...FormatterLineAggregator">
<beans:property name="fieldExtractor">
<beans:bean class="org.springframework..BeanWrapperFieldExtractor">
<beans:property name="names" value="column1" />
</beans:bean>
</beans:property>
<beans:property name="format" value="%05d" />
</beans:bean>
when I tired with format value ="%05d" I getting my expected value as 00012. but when I tried by changing formatter value with value ="%05s"
I am getting getting whitespaces like this " 12" which need to be replaced with zero.
suppose if I have value as AI2 means then my formatted value has to be 000AI2. That's y I am trying to change conversion from d to s.
How to do that :?

%d is used to format numbers only. Usually in fixed lenght file we pad string data with spaces and numbers with "0".
If you have no choise and the data you want to pad with "0" is a String, maybe you can do the conversion logic in the processor of your step ?

Related

How can I generate the density information of vehicles in only SUMO?

This is my sumocfg file code in the SUMO program.
<input>
<net-file value="updated.net.xml"/>
<route-files value="trips.trips.xml"/>
</input>
<time>
<begin value="0"/>
</time>
<report>
<verbose value="true"/>
<no-step-log value="true"/>
</report>
updated.net.xml is network file which I write, and trips.trips.xml is just the vehicle mobility file.
In https://sumo.dlr.de/wiki/Simulation/Output/Lane-_or_Edge-based_Traffic_Measures, there is the density information format, but I don't know how can I generate the additional output file including vehicle density information.
What code should I add here?
As it is stated under 'Instantiating within the Simulation', you need to add an additional file under as follows:
<input>
<net-file value = 'xxx'/>
<route-files value = 'xxx'/>
<additional-files value = 'xxx'/>
</input>
In the additional file, add the required edge and lane ids that are to be measured.

In SQL how to form an XML output with one of attribute value as XML without <,> encoded

I am trying for a query which returns and XML output which has one of the attribute value as XML without <, /> encoded.
Example:
<Event EventLogId="124018" EventCategoryCode="ABC"
EventTypeCode="ERROR"
xmlObject="<attributes><attribute>A1</attribute></attributes>" />
<Event EventLogId="124019" EventCategoryCode="DEF"
EventTypeCode="Warning"
xmlObject="<attributes><attribute>A2</attribute></attributes>" />
I tried this query
SELECT
EventLogId AS EventLogId
,EventCategoryCode AS EventCategoryCode
,EventTypeCode AS EventTypeCode
,CAST(Event.xmlObject AS NVARCHAR(MAX)) as xmlObject
FROM
EventLog Event (NOLOCK)
FOR XML AUTO
But I am getting this output
<Event EventLogId="124018" EventCategoryCode="ABC"
EventTypeCode="ERROR"
xmlObject="<attributes><attribute>A1</attribute></attributes>" />
<Event EventLogId="124019" EventCategoryCode="DEF"
EventTypeCode="Warning"
xmlObject="<attributes><attribute>A2</attribute<</attributes>" />
I want <, /> in place of < and >
It is not valid to have non-escaped (i.e. not entity encoded) characters in attributes or anywhere in XML.
To be 100% accurate, before I get lots of comments, you can use the special DATA syntax, but that is not legal in an attribute. Also it is rare to see this feature used.
You can read the standard here (http://www.w3.org/TR/xml/) The base XML standard is actually quite short and should take you less than an hour to read.

Struts Formatting

I am trying to format a double value to two decimal places in a struts <html:text> tag. ex)
<html:text property="freight" size="9" maxlength="9" />
the value inside freight is a double for example $100. When it displays, it shows it as 100.0, not 100.00 (like I want it to).
I would like to display all double values to two decimal places but the <html:text> does not have a format property.
Could someone please help?
You can use <s:text> tag to do it.
Add a formatting entry to a .properties file (probably package.properties)
format.twodecimalnumber={0,number,#0.00}
Then in your view (JSP) file, the following code can be used for displaying a formatted number
<s:text name="format.twodecimalnumber">
<s:param name="value" value="53.3" />
</s:text>
If you want the formatted number to be displayed in an input textbox, you can wrap the above code inside a <s:textfield> tag. Like so -
<s:textfield>
<s:param name="value">
<s:text name="format.twodecimalnumber">
<s:param name="value" value="53.3" />
</s:text>
</s:param>
</s:textfield>
Refer https://struts.apache.org/release/2.0.x/docs/formatting-dates-and-numbers.html

WIX Property as Integer

I am trying to set a a property to configure the IIS:Website ConnectionTimeout value on a new website that gets created during setup.
However I am unable to, as the value for ConnectionTimeout must be an integer, not string.
In my product.wxs I have the following:
<Control Id="IisConnectionTimeoutLabel" Type="Text" X="45" Y="164" Width="100" Height="15" TabSkip="no" Text="Connection Timeout (sec):" />
<Control Id="IisConnectionTimeoutEdit" Type="Edit" X="45" Y="176" Width="220" Height="18" Property="IIS_CONNECTIONTIMEOUT" Text="{80}" Integer="yes" />
And in my IisConfiguration.wxs I have the following:
<Property Id="IIS_CONNECTIONTIMEOUT" Value="300" />
<iis:WebSite Id="EersWebsite" Description="[IIS_WEBSITENAME]" ConfigureIfExists="yes" Directory="WEBINSTALLDIR" DirProperties="EersWebsiteDirProperties" ConnectionTimeout="[IIS_CONNECTIONTIMEOUT]">
When I build the project I get the following:
The 'ConnectionTimeout' attribute is invalid - The value
'[IIS_CONNECTIONTIMEOUT]' is invalid according to its datatype
'http://www.w3.org/2001/XMLSchema:nonNegativeInteger' - The string
'[IIS_CONNECTIONTIMEOUT]' is not a valid Integer value.
The iis:WebSite/#ConnectionTimeout attribute's value,
'[IIS_CONNECTIONTIMEOUT]', is not a legal integer value. Legal
integer values are from -2,147,483,648 to 2,147,483,647.
Thanks in advance
As the error message states, the value of the <iis:WebSite>'s ConnectionTimeout attribute expects the integer value. The nonNegativeInteger is not a Formatted type, which knows how to extract values out of properties provided in square brackets.
Hence, I don't think you have a way here apart from providing the hard-coded value...
Alternatively, you can create a custom action, which calls for appcmd.exe, and provide the required timeout value in the command-line, and schedule this action deferred after ConfitureIIs... But the efforts seem much bigger than the benefit...

Apache Tiles set html tag attribute using <put-attribute> value

I am using Apache Tiles 2.1 as my templating framework (along with Spring MVC).
I want to know how best to be able to set HTML attribute values from within my Tiles definitions file. For example I have a text box and want to be able to set the maxlength attribute from within my definition. I expected the following to work -
<input id="nameField" type="text"
maxlength="<tiles:insertAttribute name='maxlength' />" />
using this definition -
<definition name="sprint-goal" >
<put-attribute name="maxlength" value="100" />
</definition>
But it seems that Tiles ignores the <insertAttribute/> tag if placed within a HTML tag. It works fine otherwise.
Note: I have tried using a ViewPreparer to set request-scoped values. This will work but is not exactly what I am looking for. I would like to easily set HTML attribute values from within a Tiles definition.
To set the value of html element attributes, your best bet is to use Expression Language. First, expose the tile attribute as a java variable using the tiles useAttribute tag. Then use '${}' to print the variable.
Example:
<tiles:useAttribute name="myMaxLength" id="maxLength" />
<input id="nameField" type="text" maxlength="${myMaxLength}" />
More info:
- updated June 2014: https://tiles.apache.org/2.2/framework/tiles-jsp/tlddoc/tiles/useAttribute.html
- http://docs.oracle.com/javaee/1.4/tutorial/doc/JSPIntro7.html
<put-attribute name="maxlength" value="100" type="string" />
I type isn't defined as "string" it would be taken as a URL to include...