MBExpression Class Reference
| Inherits from | NSObject |
|---|---|
| Declared in | MBExpression.h |
Overview
This class is responsible for evaluating Mockingbird expressions.
See the documentation for the Mockingbird Data Environment for information on how to construct valid expressions.
Evaluating expressions as strings
+ asString:
Evaluates the given expression in the string context.
+ (nullable NSString *)asString:(nonnull NSString *)expr
Parameters
expr |
The expression to evaluate. |
|---|
Return Value
The result of evaluating the expression expr
as a string.
Declared In
MBExpression.h
+ asString:error:
Evaluates the given expression in the string context.
+ (nullable NSString *)asString:(nonnull NSString *)expr error:(MBExpressionErrorPtrPtr)errPtr
Parameters
expr |
The expression to evaluate. |
|---|---|
errPtr |
An optional pointer to a memory location for storing an
|
Return Value
The result of evaluating the expression expr
as a string.
Declared In
MBExpression.h
+ asString:defaultValue:
Evaluates the given expression in the string context.
+ (nullable NSString *)asString:(nonnull NSString *)expr defaultValue:(nullable NSString *)def
Parameters
expr |
The expression to evaluate. |
|---|---|
def |
A default return value to use if the method would
otherwise return |
Return Value
The result of evaluating the expression expr
as a string.
Declared In
MBExpression.h
+ asString:inVariableSpace:defaultValue:error:
Evaluates the given expression in the string context.
+ (nullable NSString *)asString:(nonnull NSString *)expr inVariableSpace:(nonnull MBVariableSpace *)space defaultValue:(nullable NSString *)def error:(MBExpressionErrorPtrPtr)errPtr
Parameters
expr |
The expression to evaluate. |
|---|---|
space |
The |
def |
A default return value to use if the method would
otherwise return |
errPtr |
An optional pointer to a memory location for storing an
|
Return Value
The result of evaluating the expression expr
as a string.
Declared In
MBExpression.h
Evaluating expressions as objects with string interpolation
+ asObject:
Evaluates the given expression in the object context. String interpolation may be used if the expression references more than one value.
+ (nullable id)asObject:(nonnull NSString *)expr
Parameters
expr |
The expression to evaluate. |
|---|
Return Value
The result of evaluating the expression expr
as an object.
Discussion
If an expression contains a reference to only a single value (and does not
also contain any text literals), the return value will be whatever NSObject
instance is referenced by the expression.
String interpolation only applies when an expression references more than one
value, eg. “Hello $firstName! I haven't seen you since $lastTime.
”
With string interpolation, if an expression contains references to multiple
discrete values or if it contains one or more text literals, those values are
coerced into strings and concatenated before being returned as a single
NSString
instance.
If you know you’ll be using an object expression that will result in string
interpolation being used, consider using the asString:
method variants
instead.
You can also use one of the asArray:
method variants to retrieve multiple
values from within an expression without them being concatenated into a
single string.
Declared In
MBExpression.h
+ asObject:error:
Evaluates the given expression in the object context. String interpolation may be used if the expression references more than one value.
+ (nullable id)asObject:(nonnull NSString *)expr error:(MBExpressionErrorPtrPtr)errPtr
Parameters
expr |
The expression to evaluate. |
|---|---|
errPtr |
An optional pointer to a memory location for storing an
|
Return Value
The result of evaluating the expression expr
as an object.
Discussion
If an expression contains a reference to only a single value (and does not
also contain any text literals), the return value will be whatever NSObject
instance is referenced by the expression.
String interpolation only applies when an expression references more than one
value, eg. “Hello $firstName! I haven't seen you since $lastTime.
”
With string interpolation, if an expression contains references to multiple
discrete values or if it contains one or more text literals, those values are
coerced into strings and concatenated before being returned as a single
NSString
instance.
If you know you’ll be using an object expression that will result in string
interpolation being used, consider using the asString:
method variants
instead.
You can also use one of the asArray:
method variants to retrieve multiple
values from within an expression without them being concatenated into a
single string.
Declared In
MBExpression.h
+ asObject:defaultValue:
Evaluates the given expression in the object context. String interpolation may be used if the expression references more than one value.
+ (nullable id)asObject:(nonnull NSString *)expr defaultValue:(nullable id)def
Parameters
expr |
The expression to evaluate. |
|---|---|
def |
A default return value to use if the method would
otherwise return |
Return Value
The result of evaluating the expression expr
as an object.
Discussion
If an expression contains a reference to only a single value (and does not
also contain any text literals), the return value will be whatever NSObject
instance is referenced by the expression.
String interpolation only applies when an expression references more than one
value, eg. “Hello $firstName! I haven't seen you since $lastTime.
”
With string interpolation, if an expression contains references to multiple
discrete values or if it contains one or more text literals, those values are
coerced into strings and concatenated before being returned as a single
NSString
instance.
If you know you’ll be using an object expression that will result in string
interpolation being used, consider using the asString:
method variants
instead.
You can also use one of the asArray:
method variants to retrieve multiple
values from within an expression without them being concatenated into a
single string.
Declared In
MBExpression.h
+ asObject:inVariableSpace:defaultValue:error:
Evaluates the given expression in the object context. String interpolation may be used if the expression references more than one value.
+ (nullable id)asObject:(nonnull NSString *)expr inVariableSpace:(nonnull MBVariableSpace *)space defaultValue:(nullable id)def error:(MBExpressionErrorPtrPtr)errPtr
Parameters
expr |
The expression to evaluate. |
|---|---|
space |
The |
def |
A default return value to use if the method would
otherwise return |
errPtr |
An optional pointer to a memory location for storing an
|
Return Value
The result of evaluating the expression expr
as an object.
Discussion
If an expression contains a reference to only a single value (and does not
also contain any text literals), the return value will be whatever NSObject
instance is referenced by the expression.
String interpolation only applies when an expression references more than one
value, eg. “Hello $firstName! I haven't seen you since $lastTime.
”
With string interpolation, if an expression contains references to multiple
discrete values or if it contains one or more text literals, those values are
coerced into strings and concatenated before being returned as a single
NSString
instance.
If you know you’ll be using an object expression that will result in string
interpolation being used, consider using the asString:
method variants
instead.
You can also use one of the asArray:
method variants to retrieve multiple
values from within an expression without them being concatenated into a
single string.
Declared In
MBExpression.h
Evaluating expressions as objects without string interpolation
+ asArray:
Evaluates the given expression in the object context without using string interpolation. Discrete values within the expression are returned as items in an array.
+ (nullable NSArray *)asArray:(nonnull NSString *)expr
Parameters
expr |
The expression to evaluate. |
|---|
Return Value
The result of evaluating the expression expr
as an array of
objects.
Discussion
An expression may contain zero or more literal values and inner expressions;
this method gathers any individual literals and inner expression values
encountered while evaluating the passed-in expression, and returns an
NSArray
containing the results.
Declared In
MBExpression.h
+ asArray:error:
Evaluates the given expression in the object context without using string interpolation. Discrete values within the expression are returned as items in an array.
+ (nullable NSArray *)asArray:(nonnull NSString *)expr error:(MBExpressionErrorPtrPtr)errPtr
Parameters
expr |
The expression to evaluate. |
|---|---|
errPtr |
An optional pointer to a memory location for storing an
|
Return Value
The result of evaluating the expression expr
as an array of
objects.
Discussion
An expression may contain zero or more literal values and inner expressions;
this method gathers any individual literals and inner expression values
encountered while evaluating the passed-in expression, and returns an
NSArray
containing the results.
Declared In
MBExpression.h
+ asArray:inVariableSpace:error:
Evaluates the given expression in the object context without using string interpolation. Discrete values within the expression are returned as items in an array.
+ (nullable NSArray *)asArray:(nonnull NSString *)expr inVariableSpace:(nonnull MBVariableSpace *)space error:(MBExpressionErrorPtrPtr)errPtr
Parameters
expr |
The expression to evaluate. |
|---|---|
space |
The |
errPtr |
An optional pointer to a memory location for storing an
|
Return Value
The result of evaluating the expression expr
as an array of
objects.
Discussion
An expression may contain zero or more literal values and inner expressions;
this method gathers any individual literals and inner expression values
encountered while evaluating the passed-in expression, and returns an
NSArray
containing the results.
Declared In
MBExpression.h
Evaluating expressions as numeric values
+ asNumber:
Evaluates the given expression in the numeric context, coercing the result into a number if necessary (and possible).
+ (nullable NSDecimalNumber *)asNumber:(nonnull NSString *)expr
Parameters
expr |
The expression to evaluate. |
|---|
Return Value
The result of evaluating the expression expr
as a numeric
expression.
Discussion
Mathematical expressions may be used in the numeric context.
Declared In
MBExpression.h
+ asNumber:error:
Evaluates the given expression in the numeric context, coercing the result into a number if necessary (and possible).
+ (nullable NSDecimalNumber *)asNumber:(nonnull NSString *)expr error:(MBExpressionErrorPtrPtr)errPtr
Parameters
expr |
The expression to evaluate. |
|---|---|
errPtr |
An optional pointer to a memory location for storing an
|
Return Value
The result of evaluating the expression expr
as a numeric
expression.
Discussion
Mathematical expressions may be used in the numeric context.
Declared In
MBExpression.h
+ asNumber:defaultValue:
Evaluates the given expression in the numeric context, coercing the result into a number if necessary (and possible).
+ (nullable NSDecimalNumber *)asNumber:(nonnull NSString *)expr defaultValue:(nullable NSDecimalNumber *)def
Parameters
expr |
The expression to evaluate. |
|---|---|
def |
A default return value to use if the method would
otherwise return |
Return Value
The result of evaluating the expression expr
as a numeric
expression.
Discussion
Mathematical expressions may be used in the numeric context.
Declared In
MBExpression.h
+ asNumber:inVariableSpace:defaultValue:error:
Evaluates the given expression in the numeric context, coercing the result into a number if necessary (and possible).
+ (nullable NSDecimalNumber *)asNumber:(nonnull NSString *)expr inVariableSpace:(nonnull MBVariableSpace *)space defaultValue:(nullable NSDecimalNumber *)def error:(MBExpressionErrorPtrPtr)errPtr
Parameters
expr |
The expression to evaluate. |
|---|---|
space |
The |
def |
A default return value to use if the method would
otherwise return |
errPtr |
An optional pointer to a memory location for storing an
|
Return Value
The result of evaluating the expression expr
as a numeric
expression.
Discussion
Mathematical expressions may be used in the numeric context.
Declared In
MBExpression.h
Evaluating expressions as boolean values
+ asBoolean:
Evaluates the given expression in the boolean context.
+ (BOOL)asBoolean:(nullable NSString *)expr
Parameters
expr |
The expression to evaluate. |
|---|
Return Value
The result of evaluating the expression expr
as a boolean
expression.
Declared In
MBExpression.h
+ asBoolean:error:
Evaluates the given expression in the boolean context.
+ (BOOL)asBoolean:(nullable NSString *)expr error:(MBExpressionErrorPtrPtr)errPtr
Parameters
expr |
The expression to evaluate. |
|---|---|
errPtr |
An optional pointer to a memory location for storing an
|
Return Value
The result of evaluating the expression expr
as a boolean
expression.
Declared In
MBExpression.h
+ asBoolean:defaultValue:
Evaluates the given expression in the boolean context.
+ (BOOL)asBoolean:(nullable NSString *)expr defaultValue:(BOOL)def
Parameters
expr |
The expression to evaluate. |
|---|---|
def |
A default return value to use if there was a problem evaluating
|
Return Value
The result of evaluating the expression expr
as a boolean
expression.
Declared In
MBExpression.h
+ asBoolean:inVariableSpace:defaultValue:error:
Evaluates the given expression in the boolean context.
+ (BOOL)asBoolean:(nullable NSString *)expr inVariableSpace:(nonnull MBVariableSpace *)space defaultValue:(BOOL)def error:(MBExpressionErrorPtrPtr)errPtr
Parameters
expr |
The expression to evaluate. |
|---|---|
space |
The |
def |
A default return value to use if there was a problem evaluating
|
errPtr |
An optional pointer to a memory location for storing an
|
Return Value
The result of evaluating the expression expr
as a boolean
expression.
Declared In
MBExpression.h
Value type coercion
+ booleanFromValue:
Exposes the mechanism the expression evaluator uses for coercing arbitrary object values into booleans.
+ (BOOL)booleanFromValue:(nullable id)val
Parameters
val |
The object to interpret as a boolean |
|---|
Return Value
The boolean representation of val
Declared In
MBExpression.h
+ stringFromBoolean:
Exposes the mechanism the expression evaluator uses for representing boolean values as strings.
+ (nonnull NSString *)stringFromBoolean:(BOOL)val
Parameters
val |
The boolean value |
|---|
Return Value
The string representation of val
; either kMBMLBooleanStringTrue
or kMBMLBooleanStringFalse
.
Declared In
MBExpression.h
+ numberFromValue:
Exposes the mechanism the expression evaluator uses for coercing arbitrary object values into numbers.
+ (nullable NSDecimalNumber *)numberFromValue:(nullable id)val
Parameters
val |
The object to interpret as a number |
|---|
Return Value
If val
can be interpreted as a number, the return value is an
NSDecimalNumber
containing that number. If val
cannot be
interpreted as a number, or if the resulting number is equal to
[
NSNumber notANumber
]
, nil
will be returned.
Declared In
MBExpression.h
Comparing values
+ value:isEqualTo:
Exposes the mechanism the expression evaluator uses for determining if two objects have equal values.
+ (BOOL)value:(nullable id)lValue isEqualTo:(nullable id)rValue
Parameters
lValue |
The left value of the comparison |
|---|---|
rValue |
The right value of the comparison |
Return Value
The return value of [
lValue isEqual:rValue
]
if
lValue
and rValue
are of the same type. Otherwise, falls back on
[MBExpression compareLeftValue:lValue againstRightValue:rValue]
.
Declared In
MBExpression.h
+ compareLeftValue:againstRightValue:
Exposes the mechanism the expression evaluator uses to determine the relative order of two object values.
+ (NSComparisonResult)compareLeftValue:(nullable id)lValue againstRightValue:(nullable id)rValue
Parameters
lValue |
The left value of the comparison |
|---|---|
rValue |
The right value of the comparison |
Return Value
NSOrderedAscending
if lValue
is less than rValue
;
NSOrderedDescending
if lValue
is greater than rValue
;
NSOrderedSame
if lValue
is equal to rValue
.
Declared In
MBExpression.h


Brazil government leader in Senate says administrative reform may be delayed to next year
BRASILIA (Reuters) - Brazil’s government leader in the Senate, Fernando Bezerra, said on Tuesday that ‘administrative reform’, a plank of the Economy Ministry’s far-reaching legislative agenda, may be pushed back to next year.
The bill, aimed at curbing growth in mandatory federal expenditure by changing the rules for new public sector employees, was due to be unveiled this week, before President Jair Bolsonaro said on Monday that it would likely be delayed.


void StpCallback_EnableForwarding ( const STP_BRIDGE* bridge, unsigned int portIndex, unsigned int treeIndex, bool enable, unsigned int timestamp );
Application-defined function that must enable or disable forwarding on a physical port.
StpCallback_EnableForwarding
is a placeholder name used throughout this documentation. The
application may name this callback differently.
true
if forwarding is to be enabled,
false
if the forwarding is to be disabled.In complex networks, and especially in MSTP mode, the STP library can call this function dozens of times in a row, with various combinations of parameters. This is due to the protocol itself (i.e., it is not a characteristic of this particular library). For that reason, the implementation of this function should not take more than a few milliseconds. Usually all this function needs to do is write a few bytes to the internal registers of the switch IC.
This function must wait until the hardware has finished enabling or disabling forwarding (i.e., it must not just initiate the hardware action and return).


(current)
Facebook
Twitter
Soundcloud
Matteo Gouveia
I try my hardest to do the best that I can at everything I do.
Music
Contact


timeago.js
a tiny / simple library
What ?
timeago.js is a tiny(2kb) library used to format date with `*** time ago`. eg: '3 hours ago'. No dependency. and support automatically updating fuzzy timestamps (e.g. "4 minutes ago" or "about 1 day ago"). Download, view the examples, and enjoy.
Test for native DOM
You opened this page
You opened this page .
Test for Jquery DOM ?
You opened this page .
You opened this page .


EPXDeviceAttachment
@interface EPXDeviceAttachment : NSObject
Represents payload attached to a device in Estimote Cloud. The attachments can be configured by visiting https://cloud.estimote.com/# and selecting a device’s settings. See https://github.com/Estimote/iOS-Proximity-SDK/blob/master/README.md for more info.
-
Device identifier that has the attachment.
Declaration
Objective-C
@property (readonly, strong, nonatomic) NSString *_Nonnull deviceIdentifier;
Swift
var deviceIdentifier: String { get }
-
Payload attached to the device (tag parsed to payload).
Declaration
Objective-C
@property (readonly, strong, nonatomic) NSDictionary<NSString *, id> *_Nonnull payload;
Swift
var payload: [String : Any] { get }
-
Init is disabled for this class.
Declaration
Objective-C
- (nonnull instancetype)init;
-
New is disabled for this class.
Declaration
Objective-C
+ (nonnull instancetype) new;
-
Designated initializer.
Declaration
Objective-C
- (nonnull instancetype) initWithDeviceIdentifier:(nonnull NSString *)deviceIdentifier payload:(nonnull NSDictionary<NSString *, id> *)payload;
Swift
init(deviceIdentifier: String, payload: [String : Any])
Parameters
deviceIdentifier
Device identifier that has the attachment.
payload
Payload attached to the device (tag parsed to payload).
-
Compare attachment objects. For both obhects, this method invokes
-[NSString isEqualToString:]
ondeviceIdentifier
and-[NSDictionary isEqualToDictionary:]
onattachmentPayload
.Declaration
Objective-C
- (BOOL)isEqualToAttachment:(nonnull EPXDeviceAttachment *)other;
Swift
func isEqual(to other: EPXDeviceAttachment) -> Bool
-
Compare pointer values, classes and invoke
-isEqualToAttachment
.Declaration
Objective-C
- (BOOL)isEqual:(nullable id)other;
Swift
func isEqual(_ other: Any?) -> Bool
-
deviceIdentifier
hash XORed withattachmentPayload
hash.Declaration
Objective-C
- (NSUInteger)hash;
Swift
func hash() -> UInt


The unit called MakeMatrix is an input unit that creates a 2-dimensional
matrix. The user can choose the dimensions of the matrix (not necessarily
square). The user can also choose to fill the matrix with values. Choices
are to fill with:
zeros;
random numbers, chosen from a uniform distribution between 0 and 1;
successive integers starting from zero and increasing first across rows,
then down columns ("IntegersByRow");
successive integers starting from zero and increasing first down columns,
then across rows ("IntegersByColumn").
If the matrix is square, the user can also choose to fill it in a symmetric,
diagonal, or antisymmetric way. In the case of filling with integers, the
method attempts to follow the appropriate algorithm but places new integers
only where the symmetry constraints allow.
Using MakeMatrix
MakeMatrix's parameter window (double-click on the unit while holding down
the Control key) is used to implement the choices given above.


{{draggableObj | json}}
{{destObject | json}}
{{draggableString}}
{{destString}}
{{draggableExcel}}
{{destAnything | json}}


{{define "main"}}
{{ partial "hero.html" .}}
{{ partial "client.html" .}}
{{ partial "service.html" .}}
{{ partial "operational.html" .}}
{{ partial "integrationSection.html" .}}
{{ partial "pricePackage.html" .}}
{{ partial "team.html" .}}
{{ partial "blogSection.html" .}}
{{ partial "cta.html" .}}
{{end}}


The visualization assignment is about the data scandal in 2018. Here are the two companies got invovles


I'm the chair of OSGeo:UK and it's my great pleasure to welcome you to this event.
Flickr: Bob Duran CC-BY-2.0
FOSS4GUK Online 2020 is an event run by the UK Chapter of the global Open Source Geospatial Foundation, so it's my great pleasure to introduce the President of OSGeo, Angelos Tzotsos, to say a few words about the foundation and what it is for, then I'll say a bit more about the UK chapter.
...
OSGeo:UK was conceived as an idea at FOSS4G 2006, and had it's first meetup in 2008...
The original aims of the UK Chapter were to help campaign for open geospatial data, and to promote the use of open source software in the UK. OS Open Data wasn't yet a thing, OpenStreetMap was very basic, and Open Source wasn't widely used.
Looking back at FOSS4G 2006...
QGIS was at version 0.8
PostGIS was at version 1.2
GRASS GIS was the most widely used desktop GIS, evidenced by the fact that it had several conference streams all to itself!
Things have progressed...What OSGeo:UK does now is facilitate and sometimes organise events, previously IRL but now online.
We use the funds we make from running these events to financially support open source geospatial development.
We also provide a community for UK-based users and developers.
Now you're all part of our community!
Before I hand you over to the people you're actually here to see, some thanks and some housekeeping
Everyone for attending
Everyone who made a donation
My lovely fellow committee members who've done much more than me
Our volunteer hosts and co-hosts
We have a Code of Conduct, which now specifically covers online events. If you experience any issues or have any concerns throughout the day then the committee are here to help. Get in touch with us by emailing<EMAIL_ADDRESS>Pikrepo.com
We are recording all the talks and will get them processed and up onto our YouTube Channel as soon as we can
Needpix.com
We have two twitter hashtags for the event. Use #FOSS4GUKOnline for general comments (though remember there's a person at the end of every tweet or mention), and use #FOSS4GUKHelp for tech support. We'll be monitoring that hashtag and will do what we can to help.
Needpix.com
Remember... this is the first time any of us have organised anything like this, so if something doesn't go according to plan, try not to worry and we'll do our best to sort it out
Flickr: Cameron Bennett CC-BY-NC-2.0
If you would like to show your appreciation for the effort that the speakers and organisers have put in, then donate! To any charity of your choice! Any amount!
Details are at uk.osgeo.org/foss4gukonline2020
Jo Cook, and the rest of the OSGeo:UK Committee


Struct for storing basic information about a type used by TypeMap.
More...
#include <TypeMap.h>
|
|
bool | operator== (const TypeInfo &rhs) const |
| |
|
bool | is_pointer () const |
| | Is this a pointer type.
|
| |
|
bool | is_small () const |
| | Returns false if this type is more bytes than a pointer.
|
| |
|
bool | is_triv_dest () const |
| | Is it ok to not call this type's destructor.
|
| |
|
bool | is_reference () const |
| | Is this a reference type.
|
| |
|
|
std::size_t | hash |
| | The types unique hash code.
|
| |
|
unsigned char | flags = 0 |
| | A bit array of useful information on this type.
|
| |
Struct for storing basic information about a type used by TypeMap.
Definition at line 17 of file TypeMap.h.
◆ get()
template<typename T >
| static const TypeInfo nta::utils::TypeInfo::get |
( |
| ) |
|
|
inlinestatic |
This is the only method that should be used for creating a TypeInfo
The name is subject to change
Definition at line 25 of file TypeMap.h.
The documentation for this struct was generated from the following file:


Philosophy Girl’s Trail
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 719 Accepted Submission(s): 208
Problem Description
Philosophy Girl Krolia was always on the go. No one could figure out where she was. It’s said that she traveled all over the world with only two kinds of items:books and staffs.
Krolia had a knapsack which is composed of n*m grids, and every item can be fit into grids. All the books’ size is 1*2(2*1), and the staffs’ is 1*3(3*1) and each of them can be rotated 90, 180 or 270 degrees. Every item is assigned a value and Krolia wanted
to go with the maximal value.
Krolia had a knapsack which is composed of n*m grids, and every item can be fit into grids. All the books’ size is 1*2(2*1), and the staffs’ is 1*3(3*1) and each of them can be rotated 90, 180 or 270 degrees. Every item is assigned a value and Krolia wanted
to go with the maximal value.
Input
The first line comes with one integer T (T=100) which denotes the test cases.
In the first line of each case, there is four integers n (1<=n<=500), m (1<=m<=500), n1 (1<=n1<=10000) and n2 (1<=n2<=10000) which indicates the size of the knapsack, the number of the optional books and staffs.
The next line contains n1 integers which indicate the value bi (0<=bi<=1000) of every book.
The last line contains n2 integers si (0<=si<=1000) which indicate the value of every staff.
In the first line of each case, there is four integers n (1<=n<=500), m (1<=m<=500), n1 (1<=n1<=10000) and n2 (1<=n2<=10000) which indicates the size of the knapsack, the number of the optional books and staffs.
The next line contains n1 integers which indicate the value bi (0<=bi<=1000) of every book.
The last line contains n2 integers si (0<=si<=1000) which indicate the value of every staff.
Output
For each test case, output one line.
First, output "Case #C: ", where C is the number of test case, from 1 to T. Then output the maximal value.
First, output "Case #C: ", where C is the number of test case, from 1 to T. Then output the maximal value.
Sample Input
2 2 3 2 2 1 2 1 2 4 4 4 4 1 1 2 2 10 10 10 10
Sample Output
Case #1: 4 Case #2: 44Hintn,m,n1 and n2 <=100 in 20 cases. 50<=n,m<=500 and 1000<=n1,n2<=2000 in 50 cases. 100<=n,m<=200 and 9000<=n1,n2<=10000 in 30 cases.
Author
哲学少女系列@Krolia Fans Club
Source
贪心证明见：http://acm.hdu.edu.cn/discuss/problem/post/reply.php?postid=4547&messageid=1&deep=0
AC代码：
#include<algorithm> #include<iostream> #include<cstdio> using namespace std; #define maxn 10010 int m,n,n1,n2; int mb,ms; int b[maxn],s[maxn]; int cmp(int t1,int t2){ return t1>t2; } int main(){ int T; scanf("%d",&T); for(int cas=1;cas<=T;cas++){ scanf("%d%d%d%d",&n,&m,&n1,&n2); s[0]=b[0]=0; for(int i=1;i<=n1;i++) scanf("%d",&b[i]); sort(b+1,b+1+n1,cmp); for(int i=1;i<=n2;i++) scanf("%d",&s[i]); sort(s+1,s+1+n2,cmp); for(int i=1;i<=n1;i++) b[i]+=b[i-1]; for(int i=1;i<=n2;i++) s[i]+=s[i-1]; if(n<=1 && m<=1){ printf("Case #%d: 0\n",cas); } else{ if(n>m) swap(n,m); int ans=0; mb=min(n1,n*m/2); if(n==1) ms=min(n2,n*m/3); else if(n==2 && m%3==2) ms=min(n2,n*m/3-1); else ms=min(n2,n*m/3); int msize=n*m; for(int i=0;i<=ms;i++){ int tmp=0; int j=(msize-i*3)/2; tmp+=s[i]; if(j<=mb) tmp+=b[j]; else tmp+=b[mb]; if(tmp>ans) ans=tmp; } printf("Case #%d: %d\n",cas,ans); } } return 0; }
版权声明：本文为博主原创文章，未经博主允许不得转载。
(adsbygoogle = window.adsbygoogle || []).push({});
回复duola：参考“插件常见问题”。
哈哈~ 当然是祝cnFrag越办越好 然后我自己要新年大变身，好运滚滚来！
good !
DFS方法的原理还是不太清楚啊
秒！~
这个.. 真没看出来
第二种解法如果数组有重复元素 就不正确
沙发呢，我抢到了沙发
这个问题别太纠结了，不同的编译器结果不一
刚开始学习，为啥会报错了，你试过了吗
6题应该就是算概率的吧
2的64次方是多少？ 这到底是在考什么啊
非常不错
能不能说下这个是用的什么算法策略？
第2题，TCP不支持多播，多播和广播仅应用于UDP。所以B选项是不对的。第2题，TCP不支持多播，多播和广播仅应用于UDP。所以B选项是不对的。
.net中char类型不是两个字节么


[gecode-users] Reporting memory usage
Gustavo Gutierrez
ggutierrez at atlas.puj.edu.co
Thu Oct 30 12:10:09 CET 2008
On Thu, Oct 30, 2008 at 12:01 PM, Christian Schulte <cschulte at kth.se> wrote:
> Hi,
>
>
>
> The only reason to allocate globally and not from a space is if the
> allocated entities are shared among several spaces. That's the case for
> complete set variables as they use BDDs that might indeed be shared across
> spaces.
>
It is also our case, in which a graph variable is partially represented by a
boost graph which is shared among spaces. If i understand you correctly
there is a way to allocate memory from the space and another one to allocate
memory from a "global" heap (still managed by gecode). Is this right?, or
when you talk about allocate globally you mean allocate from the operating
system?.
Regards,
Gustavo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.ps.uni-sb.de/pipermail/users/attachments/20081030/8d355a6e/attachment.htm>
More information about the gecode-users
mailing list


Before Change
http_response = self._uri_opener.GET(urllist_url, cache=True)
if not is_404(http_response):
if self._is_urllist_txt(base_url, http_response.get_body()):
// Save it to the kb!
desc = "A urllist.txt file was found at: "%s", this file might"\
" expose private URLs and requires a manual review. The"\
" scanner will add all URLs listed in this files to the"\
" analysis queue."
desc = desc % urllist_url
i = Info("urllist.txt file", desc, http_response.id,
self.get_name())
i.set_url(urllist_url)
kb.kb.append(self, "urllist.txt", i)
om.out.information(i.get_desc())
// Even in the case where it is NOT a valid urllist.txt it might be
// the case where some URLs are present, so I"m going to extract them
// from the file as if it is a valid urllist.txt
url_generator = self._extract_urls_generator(base_url,
http_response.get_body())
// Send the requests using threads:
After Change
if is_404(http_response):
return
if not self._is_urllist_txt(base_url, http_response.get_body()):
return
// Save it to the kb!
desc = ("A urllist.txt file was found at: "%s", this file might"
" expose private URLs and requires a manual review. The"
" scanner will add all URLs listed in this files to the"
" analysis queue.")
desc %= urllist_url
i = Info("urllist.txt file", desc, http_response.id, self.get_name())
i.set_url(urllist_url)
kb.kb.append(self, "urllist.txt", i)
om.out.information(i.get_desc())
// Even in the case where it is NOT a valid urllist.txt it might be
// the case where some URLs are present, so I"m going to extract them
// from the file as if it is a valid urllist.txt


This Electron app tests various latencies for different IPC roundtrip scenarios.Time reported in total milliseconds.
Stringify JSON before sending
Show percentage values
Wait time [ms]
Payload:
Node.js , Chromium , Electron .


What is code?
- A way to tell the computer what to do
The three Web languages
- HTML organizes the content
- CSS makes it look good
- JavaScript makes it interactive
Looking up HTML
Try looking up how to:
- Make a pull quote (hint: search for "html pull quote")
- Add a line break in your paragraph.
- Make a link to another page.
Don't worry about CSS right now. We'll get there soon!
Coding is a process
Like writing, don't expect success on the first try. It's about writing, editing and re-writing.
What CSS is used for
- Change color and background color
- Make text larger, bold and italic
- Use a different font altogether
- Add borders and spacing
- Make things big and small
Looking up CSS
Try looking up how to:
- Underline text with CSS (hint: "css underline")
- Italicize text with CSS
- Make text uppercase with CSS
- Put a border around your paragraph


--- layout: doc title: Documentation ---
LEGO proof script mode is a mode derived from proof script mode for editing LEGO scripts. An important convention is that proof script buffers must start with a module declaration. If the proof script buffer’s file name is ‘fermat.l’, then it must commence with a declaration of the form
Module fermat; |
If, in the development of the module ‘fermat’, you require material from other module e.g., ‘lib_nat’ and ‘galois’, you need to specify this dependency as part of the module declaration:
Module fermat Import lib_nat galois; |
No need to worry too much about efficiency. When you retract back to a module declaration to add a new import item, LEGO does not actually retract the previously imported modules. Therefore, reasserting the extended module declaration really only processes the newly imported modules.
Using the LEGO Proof General, you never ever need to use administrative LEGO commands such as ‘Forget’, ‘ForgetMark’, ‘KillRef’, ‘Load’, ‘Make’, ‘Reload’ and ‘Undo’ again (7).
| 10.1 LEGO specific commands | ||
| 10.2 LEGO tags | ||
| 10.3 LEGO customizations |
In addition to the commands provided by the generic Proof General (as discussed in the previous sections) the LEGO Proof General provides a few extensions. In proof scripts, there are some abbreviations for common commands:
intros
Intros
Refine
You might want to ask your local system administrator to tag the directories ‘lib_Prop’, ‘lib_Type’ and ‘lib_TYPE’ of the LEGO library. See Support for tags, for further details on tags.
We refer to chapter Customizing Proof General, for an introduction to the customisation mechanism. In addition to customizations at the generic level, for LEGO you can also customize:
The directory of the tags table for the lego library
The default value is "/usr/lib/lego/lib_Type/"
.
Lego home page URL.
This document was generated by Erik Martin-Dorel on September 18, 2016 using texi2html 1.82.


We redefine infrastructure!
- extend killer communities
- empower sticky users
- strategize e-business e-markets
- target front-end models
- grow compelling web services
- matrix integrated interfaces
- generate sexy niches
- incentivize interactive e-business
- target ubiquitous schemas
- architect leading-edge web services
- harness granular e-commerce
- reinvent cross-media e-tailers
- integrate value-added networks


This section describes the more advanced uses of ZendService\StrikeIron\StrikeIron.
Some StrikeIron services may have a PHP wrapper class available, such as those described in Bundled Services. However, StrikeIron offers hundreds of services and many of these may be usable even without creating a special wrapper class.
To try a StrikeIron service that does not have a wrapper class available, give the wsdl option to getService() instead of the class option:
1 2 3 4 5 6 7 8 9 10 11 12 | $strikeIron = new ZendService\StrikeIron\StrikeIron(array('username' => 'your-username',
'password' => 'your-password'));
// Get a generic client to the Reverse Phone Lookup service
$phone = $strikeIron->getService(
array('wsdl' => 'http://ws.strikeiron.com/ReversePhoneLookup?WSDL')
);
$result = $phone->lookup(array('Number' => '(408) 253-8800'));
echo $result->listingName;
// Zend Technologies USA Inc
|
Using StrikeIron services from the WSDL will require at least some understanding of the WSDL files. StrikeIron has many resources on its site to help with this. Also, Jan Schneider from the Horde project has written a small PHP routine that will format a WSDL file into more readable HTML.
Please note that only the services described in the Bundled Services section are officially supported.
All communication with StrikeIron is done using the SOAP extension. It is sometimes useful to view the XML exchanged with StrikeIron for debug purposes.
Every StrikeIron client (subclass of ZendService\StrikeIron\Base) contains a getSoapClient() method to return the underlying instance of SOAPClient used to communicate with StrikeIron.
PHP‘SOAPClient has a trace option that causes it to remember the XML exchanged during the last transaction. ZendService\StrikeIron\StrikeIron does not enable the trace option by default but this can easily by changed by specifying the options that will be passed to the SOAPClient constructor.
To view a SOAP transaction, call the getSoapClient() method to get the SOAPClient instance and then call the appropriate methods like __getLastRequest() and __getLastRequest():
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | $strikeIron =
new ZendService\StrikeIron\StrikeIron(array('username' => 'your-username',
'password' => 'your-password',
'options' => array('trace' => true)));
// Get a client for the Sales & Use Tax Basic service
$taxBasic = $strikeIron->getService(array('class' => 'SalesUseTaxBasic'));
// Perform a method call
$taxBasic->getTaxRateCanada(array('province' => 'ontario'));
// Get SOAPClient instance and view XML
$soapClient = $taxBasic->getSoapClient();
echo $soapClient->__getLastRequest();
echo $soapClient->__getLastResponse();
|
The source code of this file is hosted on GitHub. Everyone can update and fix errors in this document with few clicks - no downloads needed.


Throughout the development of Go2, I have tried to maintain a balance between features and cleanliness. I avoided needing preferences at all, but with Go2 1.3 I believe there are enough modifications to the user interface that someone might want to change how things are displayed. So, a proper preferences window was necessary.
To open the preferences window, press the hotkey “⌘,” or select "Go2", and "Preferences..." It should look something like this:
Here you can select which of the default libraries to show, if your bookmarks should be available to Spotlight or not, and if you would like for Go2 to run only in the status bar or if you would like it in the Dock as well.
If you choose not to have Go2 run in the Dock, the menu options are available in a new button that appears in the bottom left hand corner of the main Go2 window, or as a right click (or control click ) menu from the status bar icon.
The second tab in the preferences sets the system wide shortcut for Go2's status bar quick search.
A Note On Spotlight
In version 1.2, Go2 could write anywhere on the filesystem that you had access to. Go2 took advantage of this by using your Public folder as a data folder for it's bookmarks, making them available to Spotlight. In version 1.3, Go2 runs in a high security container called a sandbox, so it can no longer write files to your Public folder. So, it writes the files to a folder here:
~/Library/containers/com.farmdog.go2/data/Desktop/go2data
I'm still working on getting Spotlight to reliably index this folder, but if you would like to use another launcher like Quicksilver or Launchbar, simply have them index this folder and they will work as expected.


UIDAI - Aadhaar
Modify Address
{{street}}
{{vtc}}
{{landmark}}
{{po}}
{{subdist}}
{{dist}}
{{pc}}
{{state}}
{{country}}
Update Changes


{% extends "global/Page.html" %} {% load otree static %} {% block title %} Decisions {% endblock %} {% block content %}
Your decision is to tell us how many of your initial 10 quarters you will send to your counterpart in this part of the experiment.
{% formfield group.investor_decision1 %}
{% formfield group.investor_decision2 %}
{% formfield group.investor_decision3 %}
{% formfield group.investor_decision4 %}
{% formfield group.investor_decision5 %}
{% next_button %} {% endblock %} {% block styles %} {% endblock %}


-
Undocumented
Declaration
Swift
public let value: Float
-
Undocumented
Declaration
Swift
public override var description: String { get }
-
Undocumented
Declaration
Swift
public init(value: Float)


Fight Club A film review by Marty Mapes Copyright 1999 Marty Mapes
***1/2 (out of 4) "If you could fight one celebrity, who would you fight?" That's what Edward Norton asks of Brad Pitt.
Their two perfect answers? Ernest Hemingway and William Shatner. Both Hemingway and Shatner (as Captain Kirk) fought, almost as a Zen-like expression of being human. That focus, that concentration of reality, is what Fight Club is all about (although there's more to it than meets the eye).
FIGHT CLUB's long setup is the funniest stuff Fincher has ever directed, and it hits its corporate, materialistic target with better accuracy than Mike Judge's OFFICE SPACE.
Norton plays a cube-dweller/business traveler. His job, he narrates, is to apply The Formula. Working for a major car maker, he weighs the cost of a manufacturer's recall against the cost of a lawsuit. The lack of a human element in the equation is turning him off his job.
He can't sleep nights and his doctor refuses to prescribe pills. Taking an offhand remark seriously, he goes to a testicular cancer support group and cries in the arms of Bob (Meat Loaf). That night, he sleeps.
Crying at support groups becomes his sole means of emotional outlet, and his sole cure for insomnia. He joins every support group he can find.
The details of this setup are hilarious, and the pacing is rapid-fire. It's one of the funniest half-hours in any movie this year.
The movie changes tone and tempo a little when Brad Pitt is introduced. The two meet on a plane and share their thoughts on the single-serving lifestyle. They amiably trade business cards and go their separate ways.
Norton arrives home from the airport to discover that his apartment has been blown to bits. All his perfect furniture lies charred and smoldering out front. He calls the only phone number he has --Pitt's.
The two get drunk together and agree that Norton has to stay with Pitt. On their way out of the bar, Pitt insists that Norton hit him as hard as he can. It is exhilarating for both of them, so they fight some more in the parking lot.
Fistfights become better than crying for Norton's insomnia. The two main characters start fighting behind that same bar every week. Soon, a few other guys join in and the whole endeavor is given a name: Fight Club.
Pitt takes Fight Club further. There's now a Tuesday and a Thursday group that Pitt formed without Norton's knowing. It becomes so popular that Norton begins to worry. Meanwhile, Pitt seems to relish the idea of forming his own loyal little army. The tone of the movie now changes drastically. What was funny has gone too far. Norton wants to apply the brakes but Pitt won't stop. In fact, he's accelerating, and now he even has a political agenda. In place of a good laugh, the movie now gives us a dose of tension and horror.
Although David Ansen of Newsweek was on to something when he called it a "mess," presumably referring to the multiple shifts in style and tone, it really didn't seem to hurt the movie a bit. FIGHT CLUB is comedy, action, horror/thriller, and eventually, romance, but the plot and characters drive the transitions. Norton's dissatisfaction is funny, but what helps cure it naturally leads to the action segment. Letting the action escalate to extremes leads naturally to the horror/thriller stage, and so on. So even if it seems "a mess," it still holds together well.
FIGHT CLUB is great looking. That's not surprising coming from Fincher, who has directed only solidly-stylized movies(SEVEN and THE GAME). The opening sequence is a little like the great solar-system pull-back in Contact, only this time, the "camera" pulls out of neurons and synapses before coming out of a pore in Edward Norton's face. Later sequences make great use of new camera/computer techniques that tightly control the motion and speed of the images and motion on screen.
Thematically, FIGHT CLUB compares well to another recent "modern malaise" movie: AMERICAN BEAUTY.
In AMERICAN BEAUTY, Kevin Spacey gives up on his pretty and "successful," but unfulfilling life. He regresses to adolescence and finds vivacious existence in drugs, cheerleaders, and muscle cars. In FIGHT CLUB, Norton is suffering from the same vague dissatisfaction, and finds solace in the reality of pain and the exhilaration of physicalizing his weekly routine. (Both characters have strikingly similar scenes in which they solve their "day job" problem.)
I really liked FIGHT CLUB and foundit lacking in almost no areas. The acting was very good, the production looked great, and the story was always interesting and entertaining.
Perhaps the biggest complaint is that it made the mistake every "on-the-lam" movie makes: it overestimates the public's sympathy for the anti-hero. A movie audience can sympathize with an on-screen rogue who has the right sort of charm, but that just doesn't happen outside of a movie. In the case of FIGHT CLUB, screenwriter Jim Uhls assumes that LOTS of men would be interesting in joining Pitt's fistfighting army, and I think he's wrong. There's one scene where it is particularly distracting, which I can't mention without giving something away. Write to me if you want to know.
But any reservations about the movie are more than made up for by its wit, its energy, and its wonderful attention to detail. Fincher packed a lot of stuff into FIGHT CLUB, and maybe that makes it a mess. I prefer to call it "getting your money's worth."
Check out more current movie reviews at http://www.moviehabit.com
-- Marty Mapes<EMAIL_ADDRESS>Movie Habit http://www.moviehabit.com
The review above was posted to the
rec.arts.movies.reviews newsgroup (de.rec.film.kritiken for German reviews).
The Internet Movie Database accepts no responsibility for the contents of the
review and has no editorial control. Unless stated otherwise, the copyright
belongs to the author.
Please direct comments/criticisms of the review to relevant newsgroups.
Broken URLs inthe reviews are the responsibility of the author.
The formatting of the review is likely to differ from the original due
to ASCII to HTML conversion.
Related links: index of all rec.arts.movies.reviews reviews


Click to write to us..
how do you like our service? :)

Name

Email address

Phone

Remember me
Submit

Firstname
Lastname
Email
Phone
Delete record
John
Doe
<EMAIL_ADDRESS>1234567890
Delete
Mary
Moe
<EMAIL_ADDRESS>1234567891
Delete
July
Dooley
<EMAIL_ADDRESS>1234567892
Delete
Add row
Hide Table


Build chatbots for Web, Slack, Facebook and Telegram with Xenioo:
Build Once, Publish Anywhere!
Get Started


Display a list of links as a horizontal menu:
default span display
A display property with a value of "block" results in
a line break between the two elements.
overrided display value
A display property with a value of "block" results in
a line break between the two elements.


Home
Configure
Pebuilt Configurations
JcasC.yml
---End of editor---
packager-config.yml
---End of editor---
Download JcasC YAML
Download WAR File
Download DockerFile
Add Plugins to Configuration
Create Pull Request
Submit
Pull Request Details
View Pull Request


We'll be back in 5 days!
Sorry for the inconvenience but we’re performing some maintenance at the moment. If you need to you can always contact us via phone numbers below. Otherwise we’ll be back online shortly!
—SR Akshay Academy
Sorry for the inconvenience but we’re performing some maintenance at the moment. If you need to you can always contact us via phone numbers below. Otherwise we’ll be back online shortly!
—SR Akshay Academy


| Allocation Category | % Of Income | ||
|---|---|---|---|
| {{ category.name }} | {{ category.percentage }} |
|
|
| Total | {{ vm.percentageTotal() }} | {{ 100 - vm.percentageTotal() }}% unallocated. Total should be 100%. Over-allocated by {{ vm.percentageTotal() - 100 }}%. Total should not exceed 100% |


Products
Personal
Kids
Business
Search
Personal Events
Kids
Business
Festivals
Boxes
What is GUP?
Get started offers
Fridge Magnets
Stickers
Decals
Posters
Calender
Envelopes
Labels
Tags
Wrapping paper
Vinyl Lettering
Cling Stickers
Cards
Cards
Top Category
stickers
cards
birthday
school
wedding
Top Products
brand stickers
foodlabels
magnet
tag
wallpapers
Featured
decals
foodlabels
logostickers
magnet
winelabels
BABYSHOWER
Some quick example text to build on the card title and make up the bulk of the card's content.
BIRTHDAYS
Some quick example text to build on the card title and make up the bulk of the card's content.
BOTTLE LABELS
Some quick example text to build on the card title and make up the bulk of the card's content.
DECALS
Some quick example text to build on the card title and make up the bulk of the card's content.


When you receive a phone call, Flashback shows you recent calls and SMS messages to/from the person calling you.
Download Flashback for Android now!
Get support for Flashback by e-mailing feedback@flashbackapp.co.uk


This is the project for the C# version of the Mixpanel plugin for Unity 3D. If you prefer to work in Javascript, then use this project.
If you want to track user behavior on your Unity3D application, first download the mixpanel-cs.unitypackage file.
Next, import mixpanel-cs.unitypackage
into your Unity project by selecting the "Assets" menu, hovering over "Import Package", and clicking "Custom Package".
Locate the mixpanel-cs.unitypackage
file you just downloaded and click "Open". You will see this window:
From this window you can select the individual files you want to import into your Unity project. The only two required files for the API are Mixpanel.cs
and LitJson.dll
. The example.unity
and MixpanelExample.cs
files are for tutorial purposes only and not required to use the API. If you want you may uncheck these two optional files or delete them later from your project at any time.
Mixpanel.cs
- This is a required file which contains the core Mixpanel API for Unity3D.LitJson.dll
- This is a required file which is used by Mixpanel.js to translate Unity data types into JSON, the language understood by Mixpanel.MixpanelExample.cs
- This is an optional file containing example source code demonstrating how to use the Mixpanel API. This tutorial is similar to the contents of this file, but doesn't follow it exactly.example.unity
- This is an optional scene file containing an object with the MixpanelExample.cs
script attached. You can open the scene in the Unity editor and test out the API from this scene.Click the "Import" button to finish importing the Mixpanel API into your project.
As an alternative to simply downloading mixpanel-cs.unitypackage
, you may also clone the git repository, in which case you can simply copy the API files from the repository:
git clone https://github.com/waltdestler/Mixpanel-Unity-CSharp.git
This repository contains an entire Unity3D project, which is set in a mode to work with version control systems such as Git. This mode automatically creates additional Mixpanel.cs.meta
, LitJson.dll.meta
, MixpanelExample.cs.meta
, and example.unity.meta
files. You do not need to copy these additional ".meta
" files into your own project.
The first thing you need to do in order to use Mixpanel is to initialize the Mixpanel
class. At the very least you must set your unique Mixpanel.Token
string. We recommend doing this in the Start
method of a script in the very first scene of your application.
public void Start()
{
Mixpanel.Token = "YOUR MIXPANEL TOKEN HERE";
}
After initializing the Mixpanel
class, you are ready to track events. Sending an event with no properties is very easy, and you can do this from anywhere in any of your scripts:
Mixpanel.SendEvent("name of event");
If you want to add properties to the event you can do the following:
Mixpanel.SendEvent("name of event", new Dictionary<string, object> {
{"name of property 1", value_of_property1}, // Most common types such as int, float, double, and string are supported.
{"name of property 2", value_of_property2},
});
Super properties are an easy way to store data about your users. They are global properties that get attached to everything you are tracking. More information can be found here.
If you want to register a super property for your current user, you can do it as follows:
Mixpanel.SuperProperties.Add("name of super_property", value_of_super_property); // Most common types such as int, float, double, and string are supported.
It's often useful to log data about your application with all events. For example, we can add some super properties to the Start
method we created earlier:
public void Start()
{
Mixpanel.Token = "YOUR MIXPANEL TOKEN HERE";
// Set some "super properties" to be sent with every event.
Mixpanel.SuperProperties.Add("platform", Application.platform.ToString());
Mixpanel.SuperProperties.Add("quality", QualitySettings.names[QualitySettings.GetQualityLevel()]);
Mixpanel.SuperProperties.Add("fullscreen", Screen.fullScreen);
Mixpanel.SuperProperties.Add("resolution", Screen.width + "x" + Screen.height);
}
Mixpanel uses a one-way hash of the MAC address of the current device as its default identifier. You can easily change the identifier with the following call:
Mixpanel.DistinctID = "the distinct ID string of your user";
Typically this would be done in that Start
method, so our Start
method from earlier could be further expanded like this:
public void Start()
{
Mixpanel.Token = "YOUR MIXPANEL TOKEN HERE";
Mixpanel.DistinctID = "the distinct ID string of your user";
// Set some "super properties" to be sent with every event.
Mixpanel.SuperProperties.Add("platform", Application.platform.ToString());
Mixpanel.SuperProperties.Add("quality", QualitySettings.names[QualitySettings.GetQualityLevel()]);
Mixpanel.SuperProperties.Add("fullscreen", Screen.fullScreen);
Mixpanel.SuperProperties.Add("resolution", Screen.width + "x" + Screen.height);
}


#assign index="active">
| License | Source | API Docs | Issues | Releases |
|---|---|---|---|---|
| Apache2 | Github | Javadoc | Github |
A lightweight wrapper to the JDK 11+ Java Http Client.
Some introductions to the JDK HttpClient:
We can define a java interface with annotations and have a Java annotation processor generate the client implementation (similar to Retrofit, Feign and JAX-RS client).
This client API generation targets avaje-http-client / JDK HttpClient only and uses source code generation via annotation processing so there is no use of reflection/dynamic proxies to slow things down.
@Client interface GitHub { @Get("/repos/{owner}/{repo}/contributors") List<|Contributor> contributors(String owner, String repo); }
HttpClient client = HttpClient.builder() .baseUrl("https://api.github.com") //.bodyAdapter(new JsonbBodyAdapter()) .build(); // obtain API implementation GitHub github = client.create(GitHub.class); try { // use the api/interface List<|Contributor> contributors = github.contributors("rbygrave", "junk"); } catch (HttpException ex) { if (ex.getCause() != null) { // some IO/Interrupted exception happened while sending request. } else { //Use HttpException utility methods to access response status and handle/deserialize error body } } }
@Client interface GitHub { @Get("/repos/{owner}/{repo}/contributors") HttpCall<|Contributor> contributors(String owner, String repo); }
Add avaje-http-client as a dependency.
io.avaje avaje-http-client ${avaje.http.client.version}
For the client API generation, we need to add avaje-http-api as a dependency.
io.avaje avaje-http-api ${avaje.http.api.version}
Add the avaje-http-client-generator annotation processor.
io.avaje avaje-http-client-generator ${avaje.http.api.version} provided
Add dependencies for avaje-http-client and jackson-databind.
dependencies { implementation 'com.fasterxml.jackson.core:jackson-databind:2.14.2' implementation 'io.avaje:avaje-http-client:1.35' ... }
When using Client API we additionally need avaje-http-api and the avaje-http-client-generator annotation processor.
dependencies { implementation 'io.avaje:avaje-http-client:1.35' implementation 'io.avaje:avaje-http-api:1.17' annotationProcessor 'io.avaje:avaje-http-client-generator:1.35' ... }
Current notable limitations are:
Create an HttpClient with a base URL and BodyAdapter (plus other options as necessary like retry, interceptors etc). It can be used to create requests. Requests can be executed synchronously or asynchronously with CompletableFuture.
HttpClient client = HttpClient.builder() .baseUrl(baseUrl) .bodyAdapter(new JsonbBodyAdapter()) //.bodyAdapter(new JacksonBodyAdapter()) //.bodyAdapter(new GsonBodyAdapter(new Gson())) .build();
Customer customer = client.request() .path("customers/42") .GET() .bean(Customer.class); List<|Product> products = client.request() .path("products") .GET() .list(Product.class); HttpResponse<|String> hres = client.request() .path("health") .GET() .asString();
client.request() .path("hello") .GET() .async().asString() // CompletableFuture<|HttpResponse<|String>> .whenComplete((hres, throwable) -> { if (throwable != null) { // CompletionException ... } else { // HttpResponse<|String> int statusCode = hres.statusCode(); String body = hres.body(); ... } });
We can make requests in simple blocking manner or via async()
which uses CompletableFuture
.
The JDK HttpClient provides a number of BodyHandlers
including reactive Flow based subscribers. When executing the requests in
asynchronous style the responses are processed in a reactive way. Generally
CompletableFuture.whenComplete()
will be called only when the
response is ready.
Using withHandler(...) we can use any of the existing handlers or make our own HttpResponse.BodyHandler implementation.
With Loom we will be able to use simple blocking requests and get a similar
performance as the async()
requests. This is an important factor
to keep in mind. To use loom, simply add a virtual thread executor to the http client builder.
See 10K requests - Loom vs Async
HttpClient is effectively a wrapper of java.net.http.HttpClient
with extra features for request interception, body adapters, retry, etc.
Create a HttpClient with a base URL and a BodyAdapter (e.g. JsonbBodyAdapter). Set other options like retry and request interceptors as necessary.
Reference HttpClient.Builder
HttpClient client = HttpClient.builder() .baseUrl(baseUrl) .bodyAdapter(new JsonbBodyAdapter()) // .bodyAdapter(new JacksonBodyAdapter()) // .bodyAdapter(new GsonBodyAdapter(new Gson())) .build();
From the HttpClient instance we create requests and execute them.
HttpResponse<|String> hres = client.request() .path("hello") .GET() .asString();
avaje-http-client provides a BodyAdapter interface with implementations for Jackson, Gson and Avaje-Jsonb to adapt request and response body content from JSON to java types and from java types to JSON.
To use avaje-jsonb for serialization of request and response body content to and from JSON we need to:
io.avaje avaje-jsonb ${avaje.jsonb.version}
Register the JsonbBodyAdapter with the HttpClient builder. We can supply a jsonb instance to JsonbBodyAdapter or just use defaults. For example:
Jsonb jsonb = Jsonb.builder().build(); HttpClient client = HttpClient.builder() .baseUrl(baseUrl) .bodyAdapter(new JsonbBodyAdapter(jsonb)) .build();
Avaje-jsonb uses APT source code generation to generate
adapters for types annotated with @Json
. This makes it a fast and light dependency, especially good for
http clients, CLI applications and use with GraalVM native images.
To use Jackson for serialization of request/response body content to/from JSON we need to:
com.fasterxml.jackson.core jackson-databind 2.14.2
Register a JacksonBodyAdapter with the HttpClient builder. We cab provide JacksonBodyAdapter an ObjectMapper that has modules and configuration. For example:
ObjectMapper objectMapper = new ObjectMapper().registerModule(new JavaTimeModule()); HttpClient client = HttpClient.builder() .baseUrl(baseUrl) .bodyAdapter(new JacksonBodyAdapter(objectMapper)) .build();
To use Gson for serialization of request/response body content to/from JSON we need to:
com.google.code.gson gson 2.8.9
Register the GsonBodyAdapter with the HttpClient builder. For example:
HttpClient client = HttpClient.builder() .baseUrl(baseUrl) .bodyAdapter(new GsonBodyAdapter(new Gson())) .build();
Instances of java.net.http.HttpRequest.BodyPublisher are used to send request body content. The JDK HttpClient comes with a number of implementations for different situations. You can use your own implementation as well if you so desire.
avaje-http-client adds URL encoded form and body adapters using Jackson and Gson to convert body content to/from JSON and java beans/types.
When we create the HttpClient, we can register a message body handler. When these are registered, we can call body(object)
to write the body content as JSON.
Hello bean = new Hello(42, "rob", "hello world"); HttpResponse<|Void> res = client.request() .path("hello") .body(bean) .POST() .asVoid();
Calling formParam()
adds URL encoded name-value pairs, and send body content as application/x-www-form-urlencoded
.
HttpResponse<|Void> res = client.request() .path("register/user") .formParam("name", "Bazz") .formParam("email"<EMAIL_ADDRESS>.formParam("url", "http://foo.com") .formParam("startDate", "2020-12-03") .POST() .asVoid();
This uses HttpRequest.BodyPublishers.ofFile(file)
to
stream file content as the request body.
Path file = ...; HttpResponse<|String> res = client.request() .path("upload") .body(file) .PUT() .asString();
This uses HttpRequest.BodyPublishers.ofInputStream(supplier)
to stream the request body content from the InputStream.
InputStream inputStream = ...; HttpResponse<|String> res = client.request() .path("upload") .body(inputStream) .PUT() .asString();
We can pass any HttpRequest.BodyPublisher
into body()
. Refer to HttpRequest.BodyPublishers
for ones that come with JDK HttpClient.
HttpResponse<|Void> res = client.request() .path("whazzzup") .body(HttpRequest.BodyPublishers.ofString("silly example")) .PUT() .asVoid();
| BodyPublishers.noBody() | Sends no request body. |
| BodyPublishers.ofByteArray() | byte[] |
| BodyPublishers.ofString() | String, additional charset option |
| BodyPublishers.ofInputStream() | InputStream |
| BodyPublishers.ofFile(Path file) | Path with various options |
| BodyPublishers.fromPublisher(...) | various options |
java.net.http.HttpResponse.BodyHandler is the interface used to handle response bodies. The JDK HttpClient provides a number of BodyHandlers including reactive Flow based subscribers.
avaje-http-client has APIs to use the common ones such as String, Void, byte[] etc
and withHandler()
to use any BodyHandler implementation.
Return the response via BodyAdapter as a java bean/type (typically JSON). The BodyAdapter
decodes from a byte[]
. Gzip decoding occurs based on Content-Encoding header.
If the HTTP status code is in the error range this throws an HttpException. From the HttpException we can get the underlying HttpResponse and error response body.
Customer customer = client.request() .path("customers/42") .GET() .bean(Customer.class);
Return the response via BodyAdapter as a list of java beans/type (typically JSON). The BodyAdapter
decodes from byte[]
. Gzip decoding occurs based on Content-Encoding header.
If the HTTP status code is in the error range this throws an HttpException. From the HttpException we can get the underlying HttpResponse and error response body.
List<|Customer> customers = client.request() .path("customers") .GET() .list(Customer.class);
Return the response via BodyAdapter as a stream of java beans/type.
The response media type is expected to be application/x-json-stream
.
Internally this uses HttpResponse.BodyHandlers.asLines()
to
get a stream of lines Stream<String>
. In this case the BodyAdapter
decodes from String
content and there is no gzip decoding supported.
If the HTTP status code is in the error range this throws an HttpException. From the HttpException we can get the underlying HttpResponse and error response body.
Stream<|Customer> customers = client.request() .path("customers") .GET() .stream(Customer.class);
Return as HttpResponse<Void>
but the response
content is still available to be read in the case of error response.
If the HTTP status code is in the error range this throws an HttpException. From the HttpException we can get the underlying HttpResponse and error response body.
HttpResponse<|Void> hres = client.request() .path("hello") .GET() .asVoid();
Return a HttpResponse<Void>
but the response
content is always discarded. Unlike asVoid()
, error content will not be available.
We use asDiscarding() when we only ever want the status code and headers etc and never want the response body.
HttpResponse<|Void> hres = client.request() .path("hello") .GET() .asDiscarding();
Return as HttpResponse<String>
.
HttpResponse<|String> hres = client.request() .path("hello") .GET() .asString();
Return as HttpResponse<T>
.
HttpResponse<|T> hres = client.request() .path("hello") .GET() .as(T.class);
Using withHandler()
we can use any BodyHandler to process the response.
HttpResponse<|InputStream> hres = client.request() .path("hello/stream") .GET() .withHandler(BodyHandlers.ofInputStream());
| BodyHandlers.discarding() | Discards the response body |
| BodyHandlers.ofByteArray() | byte[] |
| BodyHandlers.ofString() | String, additional charset options |
| BodyHandlers.ofLines() | Stream<String> |
| BodyHandlers.ofInputStream() | InputStream |
| BodyHandlers.ofFile(Path file) | Path with various options |
| BodyHandlers.ofByteArrayConsumer(...) | |
| BodyHandlers.fromSubscriber(...) | various options |
| BodyHandlers.fromLineSubscriber(...) | various options |
An HttpException is thrown when the status code is not in the 2XX range and the call is one of bean(), list(), stream(), asVoid().
HttpException effectively wraps the HttpResponse and provides helper methods to get the response body as String, byte[] or bean (via the registered body adapter).
int statusCode = httpException.statusCode(); // the underlying HttpResponse HttpResponse> httpResponse = httpException.httpResponse() int statusCode = httpResponse.statusCode(); // helper methods to read the response body String errorBodyString = httpException.bodyAsString(); byte[] errorBodyBytes = httpException.bodyAsBytes(); // helper method to read the response body as a bean (typically using Jackson/Gson) MyErrorBean errorResponse = httpException.bean(MyErrorBean.class);
Reference javadoc HttpException
All requests can be made using async
returning CompletableFuture
.
Commonly the whenComplete()
callback will be used to process the async responses.
The bean(), list(), stream() and asVoid() responses throw a
HttpException
if the status code is not in the 2XX range.
Reference API javadoc HttpAsyncResponse
client.request() .path("hello/world") .GET() .async().asString() .whenComplete((hres, throwable) -> { if (throwable != null) { ... } else { int statusCode = hres.statusCode(); String body = hres.body(); ... } });
client.request() .path("customer").path(42) .GET() .async().bean(Customer.class) .whenComplete((customer, throwable) -> { if (throwable != null) { HttpException httpException = (HttpException) throwable.getCause(); int statusCode = httpException.getStatusCode(); // maybe convert json error response body to a bean (using Jackson/Gson) MyErrorBean errorResponse = httpException.bean(MyErrorBean.class); .. } else { // use customer ... } });
The example below is a line subscriber processing response content line by line.
CompletableFuture<|HttpResponse<|Void>> future = client.request() .path("hello/lineStream") .GET().async() .withHandler(HttpResponse.BodyHandlers.fromLineSubscriber(new Flow.Subscriber<>() { @Override public void onSubscribe(Flow.Subscription subscription) { subscription.request(Long.MAX_VALUE); } @Override public void onNext(String item) { // process the line of response content ... } @Override public void onError(Throwable throwable) { ... } @Override public void onComplete() { ... } })) .whenComplete((hres, throwable) -> { int statusCode = hres.statusCode(); ... });
When writing tests using .async()
we can use .join()
such that the current
thread waits for the async processing to complete. We then execute asserts knowing the async processing
has completed.
client.request() .path("customer").path(42) .GET() .async().bean(Customer.class) .whenComplete((customer, throwable) -> { ... }).join(); // wait for async processing to complete // can assert here after the join() if desired assertThat(...)
JDK-8204339 - HTTP Client Dependent tasks should run in the common pool
means that by default, async callbacks are executed using the ForkJoinPool.commonPool()
even when an
Executor
is assigned to the HttpClient
. This can be unexpected behavior, also refer
to this stackoverflow discussion
on this behavior.
If we are creating an API and want the client code to choose to execute
the request asynchronously or synchronously then we can use call()
.
This is similar to Retrofit Call for people who are familiar with that.
The client can then choose to execute() the request synchronously or choose async() to execute the request asynchronously.
Reference API javadoc HttpCall
HttpCall<|List<|Customer>> call = client.request() .path("customers") .GET() .call().list(Customer.class); // Either execute synchronously List<|Customer> customers = call.execute(); // Or execute asynchronously call.async() .whenComplete((customers, throwable) -> { ... });
To add Retry funtionality, use .retryHandler(yourhandler)
on the builder to provide your retry handler.
The RetryHandler interface provides two methods, one for status exceptions (e.g. you get a 4xx/5xx from the server) and another for exceptions thrown by the underlying client (e.g. server times out or client couldn't send request).
Here is example implementation of RetryHandler.
public final class ExampleRetry implements RetryHandler { private static final int MAX_RETRIES = 2; @Override public boolean isRetry(int retryCount, HttpResponse> response) { final var code = response.statusCode(); if (retryCount >= MAX_RETRIES || code <= 400) { return false; } return true; } @Override public boolean isExceptionRetry(int retryCount, HttpException response) { //unwrap the exception final var cause = response.getCause(); if (retryCount >= MAX_RETRIES) { return false; } if (cause instanceof ConnectException) { return true; } return false; }
avaje-http-client has built in support for basic auth and bearer token based authorisation.
We can use BasicAuthIntercept
to intercept all requests adding a Authorization: Basic ...
header.
HttpClient client = HttpClient.builder() .baseUrl(baseUrl) ... .requestIntercept(new BasicAuthIntercept("myUsername", "myPassword")) <|!-- HERE .build();
For Authorization using Bearer tokens that are obtained and expire after some time, implement
AuthTokenProvider
and register that when building the HttpClient.
class MyAuthTokenProvider implements AuthTokenProvider { @Override public AuthToken obtainToken(HttpClientRequest tokenRequest) { MyAuthTokenResponse res = tokenRequest .url("https://foo/v2/token") .header("content-type", "application/json") .body(authRequestAsJson()) .POST() .bean(MyAuthTokenResponse.class); Instant validUntil = Instant.now().plusSeconds(res.expiresIn()).minusSeconds(60); return AuthToken.of(res.accessToken(), validUntil); } }
HttpClient client = HttpClient.builder() .baseUrl("https://foo") ... .authTokenProvider(new MyAuthTokenProvider()) <|!-- HERE .build();
All requests using the HttpClient will automatically get an Authorization header with the retrivedBearer token added. The token will be obtained for the initial request and then renewed when the token has expired.
By default request response logging is built in (via RequestLogger
)
and we enable it via setting the log level to DEBUG
or TRACE
for io.avaje.http.client.RequestLogger
Summary logging that includes the response status code and execution time is logged
at DEBUG
level.
Logging that includes the request and response headers plus the body
content is logged at TRACE
level.
Logging is suppressed for Authorization headers and requests used by
AuthTokenProvider. Additionally logging can be
suppressed on requests via HttpClientRequest.suppressLogging()
.
We can define an interface and have the implementation generated. Similar to JAX-RS Client, Retrofit, Feign.
When using Client API we need to add a dependency for avaje-http-api which has the annotations and also add the annotation processor avaje-http-client-generator.
Goto Getting started with Client API for step by step instructions to get started.
If we are creating the interface we can put @Client
on the interface
to indicate that the generator should generate an implementation for it.
@Client interface GitHub { @Get("/repos/{owner}/{repo}/contributors") List<|Contributor> contributors(String owner, String repo); }
If the interface is already defined (in say another project) then we can instead
use @Client.Import
to indicate to the generator that it should
generate an implementation for the interface defined by @Client.Import
.
We can put the @Client.Import
on a package-info
or any type.
Most commonly we would put it on the top level package-info.
@Client.Import(types = org.foo.MyInterface.class) package org.bar; import io.avaje.http.api.Client;
We obtain the API implementation via httpClient.create(T)
passing
our client interface type T.
final HttpClient httpClient = HttpClient.builder() .baseUrl("https://api.github.com") .bodyAdapter(new JsonbBodyAdapter()) .build(); // obtain API implementation final Github github = httpClient.create(Github.class); // use it List<|Contributor> contributors = github.contributors("ebean-orm", "ebean");
The avaje-http-client-generator annotation processor generates the
implementation as java source code. The generated source is typically found in:
target/generated-sources/annotations
For more on IntelliJ IDEA setup of generated source.
The generated code for the Github
interface above is:
package org.example.httpclient; import io.avaje.http.api.*; import io.avaje.http.client.HttpClient; import java.util.List; import org.example.Contributor; import org.example.Github; @Generated("avaje-http-client-generator") public class Github$HttpClient implements Github { private final HttpClient clientContext; public Github$HttpClient(HttpClient ctx) { this.clientContext = ctx; } // GET /repos/{owner}/{repo}/contributors @Override public List<|Contributor> contributors(String owner, String repo) { return clientContext.request() .path("repos").path(owner).path(repo).path("contributors") .GET() .list(Contributor.class); } }
Below is a table of the API response types can be used and the resulting generated code.
| Method response type | Generated code |
|---|---|
| void | asVoid() |
| String | asPlainString().body() |
| T | bean(T.class) |
| List<T> | list(T.class) |
| Stream<T> | stream(T.class) |
| HttpResponse<Void> | asVoid() |
| HttpResponse<String> | asString() |
| HttpResponse<T> | as(T.class) |
| HttpResponse<byte[]> | asByteArray() |
| HttpResponse<InputStream> | asInputStream() |
| HttpResponse<Stream<String>> | asLines() |
| CompletableFuture<T> | async().bean(T.class) |
| CompletableFuture<List<T>> | async().list(T.class) |
| CompletableFuture<Stream<T>> | async().stream(T.class) |
| CompletableFuture<HttpResponse<Void>> | async().asVoid() |
| CompletableFuture<HttpResponse<String>> | async().asString() |
| CompletableFuture<HttpResponse<T>> | async().as(T.class) |
| CompletableFuture<HttpResponse<byte[]>> | async().asByteArray() |
| CompletableFuture<HttpResponse<InputStream>> | async().asInputStream() |
| CompletableFuture<HttpResponse<Stream<String>>> | async().asLines() |
| HttpCall<T> | call().bean(T.class) |
| HttpCall<List<T>> | call().list(T.class) |
| HttpCall<Stream<T>> | call().stream(T.class) |
| HttpCall<HttpResponse<Void>> | call().asVoid() |
| HttpCall<HttpResponse<String>> | call().asString() |
| HttpCall<HttpResponse<T>> | call().as(T.class) |
| HttpCall<HttpResponse<byte[]>> | call().asByteArray() |
| HttpCall<HttpResponse<InputStream>> | call().asInputStream() |
| HttpCall<HttpResponse<Stream<String>>> | call().asLines() |
The method can also declare one parameter of type java.net.http.HttpResponse.BodyHandler
and this will be used to handle the response body. This can be a specific generic type like
BodyHandler<Path>
or more general type like BodyHandler<T>
.
@Get("/{id}") HttpResponse<|Path> getWithHandler(String id, HttpResponse.BodyHandler<|Path> myHandler, String other);
The generated code uses the BodyHandler parameter to handle the response body. The resulting generated code
includes .withHandler(myHandler)
:
// GET /{id} @Override public HttpResponse<|Path> getWithHandler(String id, BodyHandler<|Path> myHandler, String other) { return clientContext.request() .path(id) .queryParam("other", other) .GET() .withHandler(myHandler); }
We can also use a more general handler like HttpResponse.BodyHandler<T>
.
For example:
@Get("/{id}") <|T> HttpResponse<|T> getWithGeneralHandler(String id, HttpResponse.BodyHandler<|T> myHandler);
The generated code uses the BodyHandler parameter to handle the response body.
// GET /{id} @Override public <|T> HttpResponse<|T> getWithGeneralHandler(String id, BodyHandler<|T> myHandler) { return clientContext.request() .path(id) .GET() .withHandler(myHandler); }
The method can also declare one parameter of type java.net.http.HttpRequest.BodyPublisher
and this will be used for the request body.
@Post("/{id}/foo/{name}") HttpResponse<|Void> postWithBody(String id, String name, HttpRequest.BodyPublisher body);
The generated code uses the BodyPublisher parameter as the request body .body(body)
// POST /{id}/foo/{name} @Override public HttpResponse<|Void> postWithBody(String id, String name, BodyPublisher body) { return clientContext.request() .path(id).path("foo").path(name) .body(body) .POST() .asVoid(); }
We can optionally put @Path
on the interface type. This path is prefixed to the
paths defined on the verb annotations @Get, @Post, @Put ...
.
For example, with @Path("/api/cats")
all the paths defined have /api/cats
prefixed.
@Client @Path("/api/cats") public interface Cats { @Get("{id}") Cat byId(UUID id); @Get("{id}/operations") List<|Operation> operations(UUID id, OffsetDateTime since); @Get("all") Stream<|Cat> all(); @Post void create(Cat cat); }
The generated paths for the methods above all have /api/cats
prefix:
// GET {id} .path("api").path("cats").path(id) // GET {id}/operations .path("api").path("cats").path(id).path("operations") // GET all .path("api").path("cats").path("all") // POST .path("api").path("cats")
Path parameters start with {
and end with }
and matched
to method parameter names. So unlike JAX-RS we do not need a @PathParam
annotation.
For example {id}
, {startDate}
, {type}
in the path are matched to method parameters of the same name.
@Get("/{id}/{startDate}/{type}") List<|Bazz> findBazz(long id, LocalDate startDate, String type);
The generated code includes .path(id).path(startDate).path(type)
:
// GET /{id}/{startDate}/{type} @Override public List<|Bazz> findBazz(long id, LocalDate startDate, String type) { return clientContext.request() .path(id).path(startDate).path(type) .GET() .list(Bazz.class); }
Unlike JAX-RS we do not need a @PathParam
annotation.
Use @RequestTimeout
to override the global response timout for a specific request.
@Client interface CustomerApi { @Get("/{id}") @RequestTimeout(value = 1, ChronoUnit.SECONDS) //defaults to milliseceonds Customer getById(long id); }
Use @Header
for a header parameter.
It the header parameter name is not explicitly specified then
it is the init caps snake case of the parameter name.
userAgent
-> User-Agent
lastModified
-> Last-Modified
@Post Bar postIt(Foo payload, @Header("User-Agent") String userAgent); // explicit @Post Bar postIt(Foo payload, @Header String userAgent); // User-Agent @Post Bar postIt(Foo payload, @Header Collectionaccept); // Accept @Get Bazz find(@Header String lastModified); // Last-Modified
We can use @Header
with a Map<String, ?>
, Map<String, String>
or Map<String, Object>
.
@Get("{type}") List<|Cat> searchByType(String type, String query, @Header Map<|String, ?> myHeaders);
The generated code includes .header(myHeaders)
// GET {type} @Override public List<|Cat> searchByType(String type, String query, Map<|String,?> myHeaders) { return clientContext.request() .header(myHeaders) .path("api").path("cats").path(type) .queryParam("query", query) .GET() .list(Cat.class); }
We explicitly specify query parameters using @QueryParam
.
// Explicit query parameter order-by @Get("/{bornAfter}") List<|Cat> findCats(LocalDate bornAfter, @QueryParam("order-by") String orderBy);
The generated code includes .queryParam("order-by", orderBy)
// GET /{bornAfter} @Override public List<|Cat> findCats(LocalDate bornAfter, String orderBy) { return clientContext.request() .path(bornAfter) .queryParam("order-by", orderBy) .GET() .list(Cat.class); }
Query parameters can be implied by not being a path parameter. That is, if a method parameter does not match a path parameter then it is implied to be a query parameter.
The following 3 declarations are exactly the same with all 3 having
a query parameters for orderBy
@Get("/{bornAfter}") List<|Cat> findCats(LocalDate bornAfter, @QueryParam("orderBy") String orderBy); @Get("/{bornAfter}") List<|Cat> findCats(LocalDate bornAfter, @QueryParam String orderBy); @Post("/{bornAfter}") List<|Cat> findCats(LocalDate bornAfter, String orderBy); // orderBy implied as query parameter
We must explicitly use @QueryParam
when the query parameter
is not a valid java identifier. For example, if the query parameter includes a hyphen
then we must use @QueryParam
explicitly.
We can use @QueryParam
with a Map<String, ?>
, Map<String, String>
or Map<String, Object>
@Post void newCat(Cat cat, String myParam, @QueryParam Map<|String,?> extraParams);
The generated code includes .queryParam(extraParams)
// POST @Override public void newCat(Cat cat, String myParam, Map<|String,?> extraParams) { clientContext.request() .path("api").path("cats") .queryParam("myParam", myParam) .queryParam(extraParams) .body(cat) .POST() .asVoid(); }
@BodyString
.
@Post("/stringbody") List<|Cat> addCats(@BodyString String body);
The generated code will be:
@Override public List<|Cat> addCats(String body) { return clientContext.request() .path("stringbody") .body(body) .GET() .list(Cat.class); }
When we have a lot of query parameters or if we have query parameters
that are common to many endpoints then we look to use @BeanParam
.
We can create a bean and all the properties on the bean default to being
query parameters and annotate this with @BeanParam
.
public record Common( Long firstRow, Long maxRows, String sortBy, Listfilters) { }
Use a record type or any type that has getter methods, record style getter methods or public fields.
public class Common { public Long firstRow; public Long maxRows; public String sortBy; public Listfilters; }
We annotate the method parameter with @BeanParam
@Get("search/{type}") List<|Cat> searchCats(String type, @BeanParam Common commonParams);
Generated code has queryParam()
for each of the properties:
// GET search/{type} @Override public List<|Cat> searchCats(String type, Common commonParams) { return clientContext.request() .path("search").path(type) .queryParam("firstRow", commonParams.firstRow()) .queryParam("maxRows", commonParams.maxRows()) .queryParam("sortBy", commonParams.sortBy()) .queryParam("filters", commonParams.filters()) .GET() .list(Cat.class); }
Our @BeanParam is the same as JAX-RS @BeanParam except the properties default to being query parameters. With JAX-RS we need to explicitly annotate each of the properties. We can do this because we also have @Form and "Form beans".
The properties on a "bean" default to being query parameters. We put @Header on properties that are instead headers.
public record Common( Long firstRow, Long maxRows, String sortBy, String filter, @Header("X-Mod") String modification) { }
We then get the modification
value set as a header.
.header("X-Mod", commonParams.modification())
If a method has both @Post
and @Form
then the
method parameters default to be form parameters.
In the following example name, email and url all default to be form parameters.
@Form @Post("register") void register(String name, String email, String url);
The generated code includes .formParam()
for name, email and url.
// POST register @Override public void register(String name, String email, String url) { clientContext.request() .path("register") .formParam("name", name) .formParam("email", email) .formParam("url", url) .POST() .asVoid(); }
For the example above we could alternatively use explicit @FormParam
on each of the form parameters rather than @Form
. We then get:
@Post("register") void register(@FormParam String name, @FormParam String email, @FormParam String url);
The expectation is that we most often would use @Form
because it reduces
"annotation noise" and that we will very rarely use @FormParam
. Potentially
we only use @FormParam if the parameter name includes hyphen or similar characters that
are not valid Java/Kotlin identifiers.
We can use @FormParam
with a Map<String, ?>
, Map<String, String>
or Map<String, Object>
.
@Put("{id}") void register(UUID id, @FormParam Map<|String, ?> params);
The generated code includes .formParam(params)
// PUT {id} @Override public void register(UUID id, Map<|String,?> params) { clientContext.request() .path("api").path("cats").path(id) .formParam(params) .PUT() .asVoid(); }
In the case where we are posting a form with a lot of parameters we can define a bean with properties for each of the form parameters rather than have a method with lots of arguments.
public record RegisterForm(String name, String email, String url) { }
@Form @Post("register") void register(RegisterForm myForm);The generated code for the above is:
// POST register @Override public void register(RegisterForm myForm) { clientContext.request() .path("register") .formParam("name", myForm.name()) .formParam("email", myForm.email()) .formParam("url", myForm.url()) .POST() .asVoid(); }
"Form beans" are nice with large forms because they help de-clutter our code and the generated code takes care of putting the values into our bean properties so that we don't have to write.
This use of @Form is very similar to JAX-RS @BeanParam except that the
bean properties default be being form parameters. With JAX-RS we would put a @FormParam
on every property that is a form parameter which becomes a lot of annotation noise on a large form.
The properties on a "form bean" default to being form parameters. We put @QueryParam, @Header on properties that are instead query params, headers or cookies.
public record RegisterForm( String name, String email, String url, @QueryParam Boolean overrideFlag, @Header String xModified) { }
The generated code includes queryParam()
and header()
for
those parameters:
// POST register @Override public void register(RegisterForm myForm) { clientContext.request() .path("register") .formParam("name", myForm.name()) .formParam("email", myForm.email()) .formParam("url", myForm.url()) .queryParam("overrideFlag", myForm.overrideFlag()) .header("X-Modified", myForm.xModified()) .POST() .asVoid(); }
If using java modules with generated Client Interfaces, in the module-info.java
we need to:
import io.avaje.http.client.HttpClient.GeneratedComponent module org.example { requires io.avaje.http.api; requires io.avaje.http.client // you must define the fully qualified class name of the generated classes. if you use an import statement, compilation will fail provides GeneratedComponent with org.example.GeneratedHttpComponent; }
In the example above, org.example.GeneratedHttpComponent
is generated code typically found in
target/generated-sources/annotations
.
The following is a very quick and rough comparison of running 10,000 requests using Async vs Loom.
The intention is to test the thought that in a "future Loom world" the
desire to use async()
execution with HttpClient reduces.
TLDR: Caveat, caveat, more caveats ... initial testing shows Loom to be just a touch faster (~10%) than async.
To run my tests I use Jex as the server (Jetty based) and have it running using Loom. For whatever testing you do you will need a server that can handle a very large number of concurrent requests.
The Loom blocking request (make 10K of these)
HttpResponse<|String> hres = httpClient.request() .path("s200") .GET() .asString();
The equivalent async request (make 10K of these joining the CompletableFuture's).
CompletableFuture<|HttpResponse<|String>> future = httpClient.request() .path("s200") .GET() .async() .asString() .whenComplete((hres, throwable) -> { ... });
Use .async()
to execute the requests which internally is using JDK
HttpClient's reactive streams. The whenComplete()
callback is invoked
when the response is ready. Collect all the resulting CompletableFuture
and wait for them all to complete.
Outline:
// Collect all the CompletableFuture's List<|CompletableFuture<|HttpResponse<|String>>> futures = new ArrayList<>(); for (int i = 0; i < 10_000; i++) { futures.add(httpClient.request().path("s200") .GET() .async().asString() .whenComplete((hres, throwable) -> { // confirm 200 response etc ... })); } // wait for all requests to complete via join() ... CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join();
With Loom Java 17 EA Release we can use Executors.newVirtualThreadExecutor()
to return an ExecutorService that uses Loom Virtual Threads. These are backed
by "Carrier threads" (via ForkedJoinPool).
Outline:
// use Loom's Executors.newVirtualThreadExecutor() try (ExecutorService executorService = Executors.newVirtualThreadExecutor()) { for (int i = 0; i < 10_000; i++) { executorService.submit(this::task); } }
private void task() { HttpResponse<|String> hres = httpClient.request().path("s200") .GET() .asString(); // confirm 200 response etc ... }
Caveat: Proper performance benchmarks are really hard and take a lot of effort.
Running some "rough/approx performance comparison tests" using Loom
build 17 EA 2021-09-14 / (build 17-loom+7-342)
vs Async for my environment
and 10K request scenarios has loom execution around 10% faster than async.
It looks like Loom and Async run in pretty much the same time although it currently looks that Loom is just a touch faster (perhaps due to how it does park/unpark). More investigation required.
Date: 2021-06
Build: 17 EA 2021-09-14 / (build 17-loom+7-342)
.
openjdk version "17-loom" 2021-09-14 OpenJDK Runtime Environment (build 17-loom+7-342) OpenJDK 64-Bit Server VM (build 17-loom+7-342, mixed mode, sharing)


--- # Layouts must stay in HTML --- {% include header.html %} {{ page.title }} {{ content }} Back to top {% include footer.html %} {% include closure.html %}


Large Tables - handling scroll and column re-ordering
Browser Scroll - traditional
Browser Scroll - fixed elements
Table with Inner Scroll


We're so glad you're here :-)
Contact us
Please don't submit me twice - even if it looks like it didn't work, it probably did


|
Perl Weekly
Issue #22 - 2011-12-26 - Perl 6 and MetaCPAN contest
latest | archive | by Gabor Szabo
|
|
Hi,
This is the last issue of the Perl Weekly for 2011, number #22 since I started it in August. The subscriber list steadily grew to be well over 2000. Mostly with your help.
It was a joy putting these issues together. The small number of unsubscribes and the large number of clicks indicate that most of you have also enjoyed receiving this newsletter.
In the next year I'll have to find new ways to promote the newsletter, so it can reach an even larger audience. I shall ask your help in this next year.
In the meantime enjoy your Holidays...
|
|
|
Headlines
|
FOSDEM 2012 Perl dev-room: Call For Speakers
Claudio Ramirez (nxadm, El-Che) writes: FOSDEM is the biggest free and non-commercial European event organized by and for the community. The Perl community has a growing presence at this event that helps promoting Perl and distributing knowledge. It would be awesome to see some of you offer a talk there.
|
|
The 2011 Perl 6 Coding Contest
The thing is that this contest can be interesting to anyone who like programming and likes challenges. If you are a 'Perl 5 fan' or a Pythonista, forget about it for a minute. What if this was a Haskell contest? Yeah, I know, you would want to do it as that's one of the coolest language. Writing in Perl 6 is even more interesting. See the announcement of Carl Mäsak
|
|
|
|
Citrus Perl Release 12
Mark Dootson wrote about the new release of Citrus Perl which was especially designed to build and distribute desktop applications written in wxPerl.
|
|
Articles
|
Introducing nginx-perl
Alexandr Gomoliako announces the first public release of perl embedded in the Nginx web server. I have not tried Nginx yet but I should.
|
|
Trying Marpa to parse CSS
I am sure some of you are already fed-up with Jeffrey Kegler constantly writing about Marpa. So I am happy to tell you that this time it is Wolfgang Kinkeldei who shows how he used Marpa to parse CSS.
|
|
STF - A Distributed Object Store
lestrrat writes about Livedoor, his employer releasing STF, their internal distributed object store under and open source license. This sounds interesting.
|
|
TWiki I/O Architecture Explained
In the Perl community we mostly talk and read about modules and how to use while in corporations they mostly care about large and complex applications. I think it is very important to read about large and complex open source applications such as Twiki. I'd be very interested in how do they do development and testing of the whole system.
|
|
Sanitizing supposed UTF-8 data
Jon Jensen wrote how he had to convert strings in various encodings, some of them even mangled to UTF-8. He used Encoding::FixLatin and found a few other useful modules for when you need to convert legacy data to UTF-8.
|
|
Discussion
|
|
|
Testing
|
one more reason to dislike mutability
Usually we see examples on how things should be written so it is very educational that Ricardo Signes (RJBS) shows us an example of a failure. Based on the comments it seems that this particular issue has biten many good programmers.
|
|
Code
|
|
|
Slides
|
Perl 6
|
|
|
Other
|
The Perl 5.15.6 Epigraph
Dave Rolsky has released Perl 5.15.6, the latest development version of Perl. Each release includes an epigraph.  Every Week. Free of charge!
|


The controller (bottom right) will control what level of logs actually make
it through.
Select a level and then try test log messages using the
form below, you should only see a message if you select a level greater than
or equal to what you select in the controller.


Appearance
After evolution, outwardly, this Pokemon does not change much. Although his tail is missing. The limbs become completely brown in color and iron bracelets appear on them. They are the same length and two fingers on them.


Turntable
Share your music with the world.
This site was designed and published as part of the COMP
333 Software Engineering class at Wesleyan University.
The described platform is not publicly
available but rather is created as a training exercise.
Features
Social
Follow what your friends are loving
and expand your musical horizons.
Footprint
Keep track of how your taste is evolving
and have your own personal musical footpring.
Community
Find those people who share your
niche interests, as wacky as they may be!
Reviews
"I finally have an outlet for the sponaneous speeches I
give to the strangers on my morning commute. With Turntable,
I can find people who actually care!"
- Annoying Friend
"I met my girlfriend on Turntable. She followed my
'Kurt Cobain = Jesus' playlist and we started chatting about our shared hatred
for Taylor Swift."
- Angsty Teen
"two stars."
- Elodie Frey
Our Team
Nina Criswell is a Junior at Wesleyan University.
This is her first HTML/CSS project.
She is seeking enthusiastic engineers and musicians to help bedazzle her new app!
If you have strong feelings about Nina's music taste, Turntable might be for you!


</2
</2 – The left expression is less than the right expression
>/2 – The left expression is greater than the right expression
=:=/2 – The left and right expressions are equal
=\=/2 – The left and right expressions are not equal
=</2 – The left expression is less than or equal to the right
>=/2 – The left expression is greater than or equal to the right
FORMS
Expression1 < Expression2
Expression1 > Expression2
Expression1 =:= Expression2
Expression1 =\= Expression2
Expression1 =< Expression2
Expression1 >= Expression2
DESCRIPTION
Both arguments to each relational operator should be instantiated to
expressions which can be evaluated by is/2. The relational operator succeeds if the relation holds for the value of the
two arguments, and fails otherwise. A relational operator will fail if one or
both of its arguments cannot be evaluated.
EXAMPLES
?- -7*0 =< 1+1.
yes.
?- 1+1 =< 7*0.
no.
ERRORS
The ISO Prolog Standard requires that a calculation error be thrown when the
arguments cannot be evaluated a for these operators. At this time, ALS Prolog
does not conform to this requirement.


Auto
-Editor
Drag and drop files or click here to browse
Export Quality
Low
Medium
High
Export Resolution
720p
1080p
4K (Coming Soon!)
Export To
Video File
Adobe Premiere (Coming Soon!)
Final Cut Pro (Coming Soon!)
DaVinci Resolve (Coming Soon!)
Audio File (Coming Soon!)
Advanced Options
Min Clip Length(in frames)
Min Cut Length(in frames)
Audio Bitrate
CRF
Video Speed(0.1x-10x)
Silent Speed(0.1x-10x)
Export
Find us on GitHub
Hosted on Oracle


You are seeing this page because you donated to this project. It is appreciated, and my hope is to use these donations and ad revenue to make speedtest better!